Open AlexanderPolenov opened 8 years ago
Is there a stacktrace? Likely a bug in PyHook, which we use for events on Windows.
http://stackoverflow.com/questions/27363268/how-can-i-avoid-typeerror-mouseswitch-missing-8-required-positional-arguments https://sourceforge.net/p/pyhook/bugs/1/
Unfortunately the project doesn't seem to be maintained. This leaves us in a tricky situation.
No, there is no stacktrace. Only this error message.
A possible workaround for the bug in PyHook is to use a simpler mechanism when hooking on Windows. That is what I use in pynput (see here: https://github.com/moses-palmer/pynput/blob/master/lib/pynput/_util/win32.py#L244).
The strange requirement for a DLL-function is not imposed for the hooks used by PyUserInput, so a simple ctypes based approach works, and the native code from PyHook is not strictly necessary.
Relying on ctypes brings the additional benefit of making the final projects easier to distribute.
I'd be in favour of replacing PyHook with ctypes or cffi if anyone has the knowledge and time to pull it off. I certainly don't with exams coming up.
I've done some research on this topic which you can find here: https://github.com/ActivityWatch/aw-watcher-afk/issues/12
I need this functionality for the project which the linked issue belongs to, might investigate ctypes or cffi but since the scope of the functionality I need is much smaller than the scope of PyUserInput I might end up not doing the full thing. I'll update the linked issue with details as it's resolved.
OS: Windows 10. When I change active window, program crashes with error:
TypeError: MouseSwitch() missing 8 required positional arguments: 'msg', 'x', 'y', 'data', 'flags', 'time', 'hwnd', and 'window_name'
I also get almost the same error when use PyKeyboardEvent.