Skip to main content

window automation package

Project description

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)

python -m venv myvenv
source ./myvenv/Scripts/activate

Installation

pip install python-automation

How to use

## 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)




## Image feature matching
import pyautomation.pyautovision as vs
min_match_count=15
template_path= r".\imgs\fcfb.jpg"

a = vs.image_matcher(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 or MS Official Website for inspect

How to update PYPI (for only project manager)

Revision codes

  1. Update on Github after modifying codes.

Update version

  1. Update __version__ in __init__.py file in package
  2. Update version in setup.py file (Same setting as first step)
  3. Update after addtion, if install_requires is added in setup.py

Generate whl file

python setup.py sdist bdist_wheel
python setup.py bdist_wheel

Upload whl file

python -m twine upload dist/*
twine upload dist/pyautomation-X.X.X-py3-none-any.whl

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_automation-0.5.7.tar.gz (190.2 kB view details)

Uploaded Source

Built Distribution

python_automation-0.5.7-py3-none-any.whl (209.4 kB view details)

Uploaded Python 3

File details

Details for the file python_automation-0.5.7.tar.gz.

File metadata

  • Download URL: python_automation-0.5.7.tar.gz
  • Upload date:
  • Size: 190.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for python_automation-0.5.7.tar.gz
Algorithm Hash digest
SHA256 b80b25c8f30acf5d4b666426a53855ec8bc96a32c23425129d06d06dd5d59931
MD5 093506fb664fecc8ec033229ba2e153c
BLAKE2b-256 3e386503d224bc4f368cbbb386ca457654c9ca1263a8c58baee02b3caa8347b9

See more details on using hashes here.

File details

Details for the file python_automation-0.5.7-py3-none-any.whl.

File metadata

File hashes

Hashes for python_automation-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 df6b830663e72da33698330231bab146d778a713f4a3db3431fa4ed626d763cc
MD5 fc4323675f1362883f2a3176a19d7177
BLAKE2b-256 4fa5512a4524604532e7cc656a6a8f5d73f4f361b3117d8f6b7177724b9979b9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page