[python-win32] Win32 SendInput function?

Dane Finlay Danesprite at posteo.net
Thu Dec 12 21:18:49 EST 2019


Dear all,

I've noticed that the Win32 SendInput
<https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput>
API function is not currently exposed by any pywin32 module. I was
wondering if this function could be exposed in win32api, where the
related keybd_event and mouse_event functions are already present. I am
aware that SendInput can be used via ctypes, I just think it would be
nice if the function could also be used via pywin32.

As I see it, the main benefit of using SendInput over the keybd_event
and mouse_event functions is that you can pass an array of events for
the system to send, rather than one event per call. Microsoft's
documentation also states that the aforementioned functions have been
superseded by SendInput. The INPUT
<https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-input>
structures expected by SendInput can also be used to specify timestamps
for each keyboard and mouse event.

SendInput could be exposed via a wrapper function taking a single list
or tuple to be converted to the array of INPUT structures required for
the |||pInputs| parameter. The cInputs and cbSize parameters could then
be derived from the list internally. Each list element could be a tuple
of struct members starting with the INPUT type (0-2). Alternatively, the
new function could require each list item to use Python structs defined
in win32api or elsewhere.

While I do have some experience working with the C-Python API, I don't
think I could implement and test this myself because it looks like
pywin32's build process is /very/ complicated.

Let me know your thoughts!

All the best,
Dane Finlay

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20191213/659d9132/attachment-0001.html>


More information about the python-win32 mailing list