{"id":26849245,"url":"https://github.com/nucs/nucs.automation","last_synced_at":"2025-05-04T08:39:59.807Z","repository":{"id":73821459,"uuid":"69783199","full_name":"Nucs/nucs.Automation","owner":"Nucs","description":"Automate/simulate actions with mouse and keyboard","archived":false,"fork":false,"pushed_at":"2017-03-11T22:23:38.000Z","size":1268,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T21:33:27.082Z","etag":null,"topics":["automation","bot","botting","keyboard","mouse"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nucs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-02T06:43:45.000Z","updated_at":"2024-03-13T02:53:34.000Z","dependencies_parsed_at":"2023-07-09T06:01:13.134Z","dependency_job_id":null,"html_url":"https://github.com/Nucs/nucs.Automation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nucs%2Fnucs.Automation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nucs%2Fnucs.Automation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nucs%2Fnucs.Automation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nucs%2Fnucs.Automation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nucs","download_url":"https://codeload.github.com/Nucs/nucs.Automation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252137040,"owners_count":21700128,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","bot","botting","keyboard","mouse"],"created_at":"2025-03-30T21:32:51.577Z","updated_at":"2025-05-03T03:23:16.277Z","avatar_url":"https://github.com/Nucs.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nucs.Automation\n\nAutomation library aims to provide a simple async-task library to simulating both keyboard and mouse with essential classes to provide a way to automate any action on your pc.\n\n#### Capabilities\n\n##### Simulating\n- `Mouse` - static mouse simulator (instance of `MouseController` w/o interface).\n    - `Move(Point xy, double velocity)` - moves the cursor in a realistic way.\n    - `MoveAbsolute(Point)` - moves the cursor instantly to the given point.\n    - `Click(MouseButton)` - click in the current location.\n    - `DoubleClick(MouseButton)` - you guessed it!\n    - `MoveRelative()` - Move the mouse relativly to the mouse current location.\n    - `MiddleClick()` ,`RightClick()` ,`DragDrop(Point from, Point to)`, `LeftDown()`, `LeftUp()`, `WheelDown()`, `WheelUp()` and so on...\n- `Keyboard` - static keyboard simulator (instance of `KeyboardController` that implements `IModernKeyboard`).\n    - `Keyboard.Write(string)` - types down a string\n    - `Keyboard.Press(KeyCode)` - presses a keyboard button - duhh\n    - `Keyboard.Control(KeyCode)` - presses a button while holding Control, exists for `Shift`, `Win` and `Alt`.\n    - Some more similar actions\n\n##### Mirroring  - Windows Reflection\n- SmartProcess - A cached version of an existing `Process` type with some neat features\n    - `WaitForExitAsync()` - async wait for the process to exit.\n    - `WaitForRespondingAsync()` - async wait for the process to be able to accept input.\n    - `Windows` - property - returns all instances of `Window` associated to this window.\n    - `MainWindow` - property - returns an instance of `Window` of the MainWindow of this process\n    - All methods available in Process including `OGProcess` prop to access the native process\n    - Static Methods\n        - `SmartProcess.Get(string processname)` - Gets cached or caches the first process with the name `processname`\n        - `SmartProcess.Get(Process)` - Gets cached or caches the passed process.\n        - `SmartProcess GetCached(Guid)` - Gets a cached SmartProcess that has the given guid (accessable from SmartProcess instance `smartproc.GUID`)\n- Window\n    - `WaitForRespondingAsync()` - async wait for the process to be able to accept input.\n    - `ChangeWindowState(WindowState)` - minimize, maximaze or normal the window.\n    - `SetWindowSize(Size)` - changes the window size.\n    - `SetWindowPosition(x, y)` - moves the window to the given xy.\n    - `IsFocused` - is it foreground atm?\n    - `Title` - returns the window's title.\n    - `IsVisible` - is it currently visible on the screen otherwise it is a part of a UI window.\n    - `IsValid` - does the window still exist?\n    - `Position` - returns a `Rectangle` of the window's position and size.\n    - `BringToFront` - sets the window as foreground / focused.\n    - `Mouse` - is an instance of `RelativeMouse` that any clicks using this property will result in relative clicking to the window's boundries.\n    - `Keyboard` - is essentially same as static `Keyboard`.\n    - Static Methods\n        - `Create(SmartProcess process, HWND handle)` creates a window object.\n       \n##### AutoBasic - a static class with basic automation methods\n\t- `Run(string application)`- runs a program using WIN+R with administrator elevation.\n\t- `RunUsingProcessStart(string application)` - runs a program in the oldschool with highest possible elevation.\n\t- `Cmd(params string[] scripts)` - starts a cmd and runs a sequence of commands.\n\t\n#### Real-World Example\nThis example will run a program using WIN+R and will return the process that has opened.\n```C#\n\nvar application = \"notepad++.exe\"\n\nvar sproc = SmartProcess.Get(\"explorer\"); //Find the explorer process\nawait Task.Yield(); //Make the rest code below async!\n_recapture:\n//Find a window in explorer process that is a Run window.\nvar win = sproc.Windows.FirstOrDefault(w =\u003e w.Type == WindowType.Run); \nif (win == null) { //if it does not already exist - create one.\n\tKeyboard.Window(KeyCode.R); //press WIN+R\n\tgoto _recapture;\n}\n\nwin.BringToFront(); //make sure it is in the front\nawait win.WaitForRespondingAsync(); //wait till the window is able to accept input - important for slow PCs\n\nwin.Keyboard.Write(application); //Equivalent to Keyboard.Write(...) but this call makes sure it is sent to the window!\nwin.Keyboard.Enter(); //Press enter which will launch the run-line command\nThread.Sleep(200); //some delay to let the program actually open\n\n//Get the process\n\n\tvar p = Process.GetProcesses().ToArray();\nvar foreground = SmartProcess.GetForeground();\nif (foreground.ProcessName == application) //is foreground the new application?\n\treturn foreground;\n//Foreground is not the given application! find the newest from all processes\nvar newest = Process.GetProcesses().Where(proc=\u003eproc.ProcessName==application).OrderByDescending(pp =\u003e {\n\t\ttry {\n\t\t\treturn pp.StartTime.Ticks;\n\t\t} catch {\n\t\t\treturn 0;\n\t\t}\n\t}).FirstOrDefault();\n}\nreturn newest;\n\n```\n---\n#### MIT License\n\nCopyright (c) 2016 Eli Belash\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnucs%2Fnucs.automation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnucs%2Fnucs.automation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnucs%2Fnucs.automation/lists"}