# pyautomation
pyautomation is a set of Python modules designed to automate the Microsoft Windows GUI, specifically without interacting with the mouse cursor and keyboard. At its simplest, it allows you to post mouse and keyboard events to Windows dialogs and controls.
With the pyautomation package, you can control your GUI automatically while simultaneously controlling the mouse and keyboard physically, similar to how selenium automates web browsers.
### Create virtual environment(Recommended)
```bash
python -m venv myvenv
```
```bash
source ./myvenv/Scripts/activate
```
### Installation
```bash
pip install python-automation
```
### How to use
```python
## Handle Usage
import os, time
import pyautomation.pyauto as pyapp
os.system ('notepad.exe')
time.sleep(3)
window = pyapp.msauto.WindowControl(searchDepth=1, ClassName='Notepad')
config = pyapp.ConfigLoader.load_config(desired_parent_name= window.Name, desired_child_name= "Text editor")
wa = pyapp.WinAuto(config=config)
result, depth = wa.walk_and_find(window)
wa.type_text(result.NativeWindowHandle, "hello notepad!")
## Load configuration
# config_path = r'.\config\pyauto.json'
# config = pyauto.ConfigLoader.load_config(config_path)
config = pyapp.ConfigLoader.load_config(desired_parent_name= "test.py - python-autoevent - Visual Studio Code", desired_child_name= "Docker", monitor_index=1)
wa = pyapp.WinAuto(config=config)
## search parent and child
root = pyapp.msauto.PaneControl(Name=config.desired_parent_name)
child, child_depth = wa.walk_and_find(root, debug=True)
wa.get_info(child, child_depth, "Target")
wa.get_info(child.GetParentControl(), child_depth-1, "Target Parent")
## click relative location
x, y = wa.get_relative_location(root, child)
wa.click_relative_location(root, x, y)
## click absolute location
wa.click_at(38, 864, visible=False)
# wa.click_at(4501, 1394, visible=True)
## get current mouse location & drag mouse
wa.get_mouse_location()
# wa.drag_mouse([100, 1], [150, 100], time=1, visible=False)
## Image feature matching
import pyautomation.pyautovision as vs
min_match_count=15
template_path= r".\imgs\fcfb.jpg"
a = vs.image_matcher(monitor_index=0, min_match_count=min_match_count, template_path=template_path, show=False)
print(a.object_center, a.object_location)
## click from image
# if a.object_center is not None:
wa.click_at(a.object_center[0], a.object_center[1], visible=False)
## monitor info
import pyautomation.displayinfo as pydis
print(pydis.DisplayInfo().get_scale_factor(pydis.DisplayInfo().get_Qapp()))
print(pydis.DisplayInfo().get_screen_info())
```
### How to download inspect.exe
Click this [git repo](https://github.com/changgwak/python-automation/tree/master/inspect) or [MS Official Website for inspect](https://learn.microsoft.com/en-us/windows/win32/winauto/inspect-objects)
Raw data
{
"_id": null,
"home_page": "https://github.com/changgwak/python-automation",
"name": "python-automation",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "pyauto, rpa, python rpa, python automation, window selenium, pyautomation, autoclick",
"author": "changgwak",
"author_email": "iamtony.ca@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a3/b9/9ee153ff5c56976f81e7770179f9737518acc7a7a963dd0c07ce60cae28d/python-automation-0.6.4.tar.gz",
"platform": null,
"description": "# pyautomation\r\n\r\npyautomation is a set of Python modules designed to automate the Microsoft Windows GUI, specifically without interacting with the mouse cursor and keyboard. At its simplest, it allows you to post mouse and keyboard events to Windows dialogs and controls.\r\n\r\nWith the pyautomation package, you can control your GUI automatically while simultaneously controlling the mouse and keyboard physically, similar to how selenium automates web browsers.\r\n\r\n### Create virtual environment(Recommended)\r\n\r\n```bash\r\npython -m venv myvenv\r\n```\r\n```bash\r\nsource ./myvenv/Scripts/activate\r\n```\r\n\r\n### Installation\r\n\r\n```bash\r\npip install python-automation\r\n```\r\n\r\n### How to use\r\n```python\r\n\r\n## Handle Usage\r\nimport os, time\r\nimport pyautomation.pyauto as pyapp\r\nos.system ('notepad.exe')\r\ntime.sleep(3)\r\nwindow = pyapp.msauto.WindowControl(searchDepth=1, ClassName='Notepad')\r\n\r\nconfig = pyapp.ConfigLoader.load_config(desired_parent_name= window.Name, desired_child_name= \"Text editor\")\r\nwa = pyapp.WinAuto(config=config)\r\nresult, depth = wa.walk_and_find(window)\r\nwa.type_text(result.NativeWindowHandle, \"hello notepad!\")\r\n\r\n\r\n\r\n## Load configuration\r\n# config_path = r'.\\config\\pyauto.json'\r\n# config = pyauto.ConfigLoader.load_config(config_path)\r\nconfig = pyapp.ConfigLoader.load_config(desired_parent_name= \"test.py - python-autoevent - Visual Studio Code\", desired_child_name= \"Docker\", monitor_index=1)\r\n\r\nwa = pyapp.WinAuto(config=config)\r\n\r\n\r\n## search parent and child\r\nroot = pyapp.msauto.PaneControl(Name=config.desired_parent_name)\r\n\r\nchild, child_depth = wa.walk_and_find(root, debug=True)\r\nwa.get_info(child, child_depth, \"Target\")\r\nwa.get_info(child.GetParentControl(), child_depth-1, \"Target Parent\")\r\n\r\n\r\n## click relative location\r\nx, y = wa.get_relative_location(root, child)\r\nwa.click_relative_location(root, x, y)\r\n\r\n\r\n## click absolute location\r\nwa.click_at(38, 864, visible=False)\r\n# wa.click_at(4501, 1394, visible=True)\r\n\r\n\r\n## get current mouse location & drag mouse\r\nwa.get_mouse_location()\r\n# wa.drag_mouse([100, 1], [150, 100], time=1, visible=False) \r\n\r\n\r\n## Image feature matching\r\nimport pyautomation.pyautovision as vs\r\nmin_match_count=15\r\ntemplate_path= r\".\\imgs\\fcfb.jpg\"\r\n\r\na = vs.image_matcher(monitor_index=0, min_match_count=min_match_count, template_path=template_path, show=False)\r\nprint(a.object_center, a.object_location)\r\n\r\n\r\n## click from image\r\n# if a.object_center is not None:\r\nwa.click_at(a.object_center[0], a.object_center[1], visible=False)\r\n\r\n\r\n## monitor info\r\nimport pyautomation.displayinfo as pydis\r\nprint(pydis.DisplayInfo().get_scale_factor(pydis.DisplayInfo().get_Qapp()))\r\nprint(pydis.DisplayInfo().get_screen_info())\r\n\r\n```\r\n\r\n### How to download inspect.exe\r\nClick this [git repo](https://github.com/changgwak/python-automation/tree/master/inspect) or [MS Official Website for inspect](https://learn.microsoft.com/en-us/windows/win32/winauto/inspect-objects) \r\n\r\n\r\n\r\n\r\n\r\n",
"bugtrack_url": null,
"license": null,
"summary": "window automation package",
"version": "0.6.4",
"project_urls": {
"Homepage": "https://github.com/changgwak/python-automation"
},
"split_keywords": [
"pyauto",
" rpa",
" python rpa",
" python automation",
" window selenium",
" pyautomation",
" autoclick"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c319d49e50af2b72038d462e84c8b95d54d6145355e34fa819a933a27a20001a",
"md5": "d55ae7175069ef0c1fc6df1f851161a1",
"sha256": "30393a79b4a1aa10c270007f861e84fed13faa1f2cb7033e5e7f3829a8e876e2"
},
"downloads": -1,
"filename": "python_automation-0.6.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d55ae7175069ef0c1fc6df1f851161a1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 211170,
"upload_time": "2024-11-23T04:25:04",
"upload_time_iso_8601": "2024-11-23T04:25:04.812428Z",
"url": "https://files.pythonhosted.org/packages/c3/19/d49e50af2b72038d462e84c8b95d54d6145355e34fa819a933a27a20001a/python_automation-0.6.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a3b99ee153ff5c56976f81e7770179f9737518acc7a7a963dd0c07ce60cae28d",
"md5": "3fa9c9502dd8cf4914cfdb30c584505a",
"sha256": "fd9489cda2bc85a36882c3e1bdb8d4cf181a29261601fd755eeafefe39dad347"
},
"downloads": -1,
"filename": "python-automation-0.6.4.tar.gz",
"has_sig": false,
"md5_digest": "3fa9c9502dd8cf4914cfdb30c584505a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 191911,
"upload_time": "2024-11-23T04:25:07",
"upload_time_iso_8601": "2024-11-23T04:25:07.041838Z",
"url": "https://files.pythonhosted.org/packages/a3/b9/9ee153ff5c56976f81e7770179f9737518acc7a7a963dd0c07ce60cae28d/python-automation-0.6.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-23 04:25:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "changgwak",
"github_project": "python-automation",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"test_requirements": [],
"lcname": "python-automation"
}