keyboard: Overflowerror with Python 3.7 on Windows
The add_hotkey function doesn’t work on Windows with Python 3.7 (64-bit):
import keyboard, time
keyboard.add_hotkey('a', print)
time.sleep(5)
The traceback:
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python37\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Python37\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Python37\lib\site-packages\keyboard\__init__.py", line 292, in listen
_os_keyboard.listen(self.direct_callback)
File "C:\Python37\lib\site-packages\keyboard\_winkeyboard.py", line 560, in listen
prepare_intercept(callback)
File "C:\Python37\lib\site-packages\keyboard\_winkeyboard.py", line 553, in prepare_intercept
keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_callback, GetModuleHandleW(NULL), NULL)
ctypes.ArgumentError: argument 3: <class 'OverflowError'>: int too long to convert
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 7
- Comments: 15 (1 by maintainers)
Commits related to this issue
- Tighten Windows ctype functions #186 #186 — committed to boppreh/keyboard by boppreh 6 years ago
I m also having this issue with python3.7 and windows 10. Quick and dirty fix: removing the call to
GetModuleHandleWseems to work for my simple use case.Not just the hotkeys, any attempt to create a hook fails.
Issue still present using keyboard.is_pressed with python 3.7 and Python 3.7.1rc1 (v3.7.1rc1:2064bcf6ce, Sep 26 2018, 15:15:36) [MSC v.1914 64 bit (AMD64)] on win32