tungsteno74 / pywinhook Goto Github PK
View Code? Open in Web Editor NEWA fork of pyHook from Peter P. with some updates
License: Other
A fork of pyHook from Peter P. with some updates
License: Other
A pyHook fork with some updates for support latest Visual Studio compilers. See the website, http://pyhook.sourceforge.net/, for the original pyHook project. Known bugs ---------- - PyInstaller can't build single-file executables using pyWinhook. This may be fixed in 1.5.1, but hasn't been tested. - pyWinhook is reported to break dead keys on non-US-english keyboards. - WM_CHAR messages are not intercepted by pyWinhook, even if SubscribeKeyChar() or SubscribeKeyAll() are used to set the callback function. Limitations ----------- - pyWinhook will not work on Win9x (no messages show up) as it uses hooks which are not present in Windows systems prior to NT 4.0 SP3.
Code
import pyWinhook
hm = pyWinhook.HookManager()
Error
Exception ignored in: <function HookManager.__del__ at 0x00000260F1A4E558>
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pyWinhook\HookManager.py", line 279, in __del__
self.UnhookKeyboard()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pyWinhook\HookManager.py", line 299, in UnhookKeyboard
if self.keyboard_hook:
AttributeError: 'HookManager' object has no attribute 'keyboard_hook'
Exception ignored in: <function HookManager.__del__ at 0x00000260F1A4E558>
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pyWinhook\HookManager.py", line 279, in __del__
self.UnhookKeyboard()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pyWinhook\HookManager.py", line 299, in UnhookKeyboard
if self.keyboard_hook:
AttributeError: 'HookManager' object has no attribute 'keyboard_hook'
Exception ignored in: <function HookManager.__del__ at 0x00000260F1A4E558>
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pyWinhook\HookManager.py", line 279, in __del__
self.UnhookKeyboard()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pyWinhook\HookManager.py", line 299, in UnhookKeyboard
if self.keyboard_hook:
AttributeError: 'HookManager' object has no attribute 'keyboard_hook'
Solution
Open HookManager.py
and change all key_hook
words to keyboard_hook
I just installed pyWinhook on windows with python 3.6 and it threw an exception on import.
After looking into it, I changed from HookManager import *
to from .HookManager import *
and
import cpyHook
to from . import cpyHook
and it seems to work fine so far.
I'm basically using the example.py
supplied in this repo, but with a time.sleep(1)
added at the end of OnKeyboardEvent(event)
. Is there any way to make it so this sleep (or any other slow code) doesnt interfere with mouse movement and normal keyboard inputs?
you can see the "issue(?)" in the gif below; when I start typing, the mouse starts lagging and I can only type 1 letter per second:
https://i.gyazo.com/bda25fe6d8f92a8935621fb7927dc9b7.mp4
When I open the window of the program "everything" (an portable version, not an installation version) and perform keyboard input and mouse click operations, pywinhook will no longer work properly and cannot obtain any keyboard and mouse messages. My os is win10 and and I use everything v1.4.1
Whenever I'm running a script that uses pyHook in the background if I use the caret character, it gets input twice on my computer (actually typing in 2 times).
I am using a French AZERTY layout keyboard where pressing the ^ or ¨ key is not supposed to print any character, but rather wait for another character input to combine it. For example pressing ^ then e should print ê, but pressing ^ twice should print ^^.
EDIT: Just learnt about "dead keys" and how it's a known issue with pyWinhook, we can consider this issue closed as insolvable then.
Hey everybody,
just wanted to report that the installation on Windows on arm fails with error: command 'swig.exe' failed: None
.
Let me know if I could support to make pyWinhook Windows on arm compatible.
Greetings
Edit: ok, same on amd64 based system - so I guess it's probably unrelated to arm/amd64...
if I switch widows than show this error message.
TypeError: KeyboardSwitch() missing 8 required positional arguments: 'msg', 'vk_code', 'scan_code', 'ascii', 'flags', 'time', 'hwnd', and 'win_name'
can you fix this error?
please help
I'm not sure what went wrong there, maybe the release tag points to the wrong commit; in any case, when retrieving the source zip from https://github.com/Tungsteno74/pyWinhook/releases/tag/1.6.1, the archive contains pyWinhook
1.6.0, not 1.6.1. The sdist on PyPI is correct.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.