learncodebygaming / pydirectinput

Python mouse and keyboard input automation for Windows using Direct Input.
Other
501 stars 88 forks source link

Keep track of whether desired number of keyboard events were inserted into the input stream #13

Closed cetteup closed 3 years ago

cetteup commented 3 years ago

I had some issues recently where I suspected that input events were not actually inserted into the input stream.

The SendInput documentation state that SendInput returns a UINT of the number of events actually inserted into the input stream. The docs also mention that this method is not perfect, as input events could still have been blocked by UIPI.

This is, however, a method of tracking whether SendInput itself is aware of any errors. Simply keep track of how many events you wanted to insert and how many you did insert.

Existing users will not be impacted by this change as they most likely don't capture a return value of keyUp, keyDown or press (since there was None).

learncodebygaming commented 3 years ago

Thanks @cetteup this looks great!