Python is a beautiful programming language, anybody that is not convinced please read my python article to get convinced… But one thing is missing, a python automation module to help automating tasks like autohotkey. I wish there was a single python ahk module.
Python and AHK
I discovered autohotkey in 2007. It was rather simple to learn and I did program several scripts to help me in my everyday life at the computer in no time. As simple as it was too learn, I soon hit its limitations. Autohotkey was pretty annoying to pass variables in functions and process any variable or text was just a pain.
Fortunately, I found python in 2009. It was superior to autohotkey in all circumstance except that I had a rather hard time doing the very simplest automation. I did countless hours of research and testing. I even developed my own module PYHK to master python automation. The result are 5 modules that will make python automation simple. I will call those 5 modules the python automation package. From now on you will be able to automate any task in python.
Python automation package
SendKeysCtypes allows you to send keystrokes and shortcuts to any window. It is very powerful. SenkeysCtypes is a new and more stable version of SendKeys. I have had some small issues with SendKeys in the past which SendKeysCtypes solves. There is no documentation on SendKeysCtypes, but you can use the documentation from Rutherfurd for his module SendKeys.
PYHK helps you receive global hotkeys and trigger functions. PYHK is based on pyHook and makes hotkey registration very simple. The project is developed and hosted by schurpf.com. See the PYHK end user documentation for help.
I use win32gui for simple window handling such as moving and resizing. I personally prefer win32gui for short, simple tasks. There is one problem with win32gui, there is no real help file. Fortunately, there are plenty of examples out there. Google is your friend.
I use pywinauto for more complex window tasks. An example would be if I had to access a menu within a program (like File-New). For the most part it is enough to simply use win32gui. Please refer to the pywinauto documentation for help. If you are starting out with python automation, I recommend you to just use pywinauto.
Mouse is a small module to control the mouse. This is the most robust way I have found so far. The version I use is an extension of a module I found at stackoverflow – ctypes mouse_event. You can find more info on mouse in my blog post Mouse.py – Control your mouse in python.
The python automation package should allow you to automate any task in python. Let me know if you have any questions. Happy coding!