Convert ahk to python

I am learning both autohotkey and python. I wrote this script in ahk (and it works!), Which automatically joins tables (using tableninja) in the pokerstars client -

^q:: Loop { Send q Sleep 500 Send {PgUp} Sleep 500 Send w Sleep 60000 } return 

I would like to convert this to python - could you please give me an idea of ​​which modules I can use for this?

What python script needs to do is type (while looping) in the letter (in the notepad that has already opened), go down two lines, enter another letter, and then wait one minute before starting.

I think -

 import module to auto-type letters import module that works as timer def function type letter q enter enter def function type letter w def function sleep while True function function function 

I teach how to code. I haven't gotten to this part about python modules yet. Thanks!

+6
source share
3 answers

Assuming you are working on windows (don't think that AHK is working on anything else), you should check sendkeys . This will make sending keystrokes a piece of cake. If you want something a little more reliable take a look at pywinauto

For a quick access part, see pyhook

+7
source

I suggest these modules:

  • SendKeysCtypes for any sending keystrokes and sending shortcuts to the window. SendKeysCtypes is a new and more stable version of SendKeys. I had problems with SendKeys in the past.

  • PYHK for working with global hot keys - get hot keys and trigger functions. PYHK is based on pyHook and makes registering hotkey very easy. I wrote this because I had the same idea as you - I wanted to use the AHK functionality in python.

  • win32gui to handle windows, such as resizing. I personally prefer win32gui for short, simple tasks. I use pywinauto for more complex tasks. For example, if I had to access a menu inside a program (for example, File-New).

  • mouse.py to control the mouse. This is the most reliable way I've found so far. The version I'm using is an extension of the module I found here in stackoverflow - ctypes mouse_events.

I personally made several poker programs using python. I released the source code of my small programs. You can find them with a source on my site schurpf.com/poker-software.

+6
source

there is also AutoPy , a cross-platform library for this purpose.

+2
source

Source: https://habr.com/ru/post/891863/


All Articles