SendKey via AutoIT Interface

As AutoIT has been specifically created to deeply interact with Windows, I would recommend considering the interface to AutoIT whenever sphisticated control of Windows internals is required. Example: Sending keystrokes.

AutoIT can do that in an exhaustive way, and the interface between Python and AutoIT is VERY simple and elegant.
I cannot think of any keystroke, that cannot be sent with AutoIT.

See example below.

In addition, AutoIT is free and of relatively small size (18 MB).

from win32com.client import Dispatch
au = Dispatch("AutoItX3.Control")   # Access to AutoIT

...

# this sends "right, right, shift+right"
au.Send("{RIGHT}{RIGHT}+{RIGHT}")
txta = str.format("+{0}{1}{2}","{DOWN ",number,"}")
# this sends "shift+down" a 'number' of times
au.Send(txta)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.