kennyhml / pyinterception

Modern Python port & wrapper for the interception device driver
MIT License
124 stars 26 forks source link

"auto_capture_devices" and spontaneously press of button #23

Closed Luciener closed 4 months ago

Luciener commented 1 year ago

When use function "auto_capture_devices" and when the script runs in the background, happens spontaneously press of button (if I am in the gallery, then a full-screen picture opens for me). In file "inpunt.py" via the print function:

print('Interception: ', num, stroke)

I found out that the button is pressed by this line:

interception.send(num, stroke)

when such values appear in it:

10 MouseStroke(state=<MouseState.MOUSE_MIDDLE_BUTTON_UP: 32>, flags=0, rolling=0, x=0, y=0, information=0)

Is there any way to prevent the actual pressing of the button?

Thank you for your work.

kennyhml commented 4 months ago

Sorry for the late reply, ive been quite busy.

The reason it sends that stroke is so that the listener thread can pick it up and thus figure out that the device number works. Mouse middle button up was the most convenient stroke I could find since it didnt trigger anything as far as I was aware.

The only way I could see it cause issues if is you require the mouse wheel to be held down during the capture for some reason.

kennyhml commented 4 months ago

Actually @Luciener, while refactoring some parts of the code I noticed something potentially very useful. It seems like the IOControl call to obtain a device hardware ID will only return valid strings for devices that are usable to send inputs on.

At least personally, I was able to send inputs through any of the devices that returned a valid HWID.

This solution to determine usable devices would solve your problem of the button presses to test devices. Please let me know if you would be willing to test it out!