GithubHelp home page GithubHelp logo

answeror / pyhook_py3k Goto Github PK

View Code? Open in Web Editor NEW
75.0 7.0 40.0 130 KB

A Python3 fork of pyHook (a python wrapper for global input hooks in Windows), fixed some bugs and compatible with cx-freeze.

License: MIT License

Python 100.00%

pyhook_py3k's Introduction

Python3 fork of pyHook

Introduction

Copy from official site:

pyHook is a python wrapper for global input hooks in Windows. Specifically it wraps the Windows SetWindowsHookEx API function using low-level keyboard (WH_KEYBOARD_LL) and mouse (WH_MOUSE_LL) hooks. The pyHook package provides callbacks for global mouse and keyboard events in Windows. Python applications register can event handlers for user input events such as left mouse down, left mouse up, key down, etc. and set the keyboard and/or mouse hook. The underlying C library reports information like the time of the event, the name of the window in which the event occurred, the value of the event, any keyboard modifiers, etc. Events can be logged and/or filtered.

Install

Build with MSVC9

Make sure you are under "Visual Studio 2008 Command Prompt".

python setup.py build_ext --swig=path-to-swig.exe
pip install .

About this fork

Unicode

Fixed unicode decoding bug of window title. This bug may cause crashing on exit randomly. Usually with console output:

TypeError: MouseSwitch() takes exactly 9 arguments (1 given)

or

TypeError: KeyboardSwitch() takes exactly 9 arguments (1 given)

Freezing

Original pyHook will cause "cannot find _cpyHook module" error when using PyInstaller or cx-freeze to freeze python app. You need manually rename pyHook._cpyHook to _cpyHook. Now it's compatible with cx-freeze.

pyhook_py3k's People

Contributors

answeror avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyhook_py3k's Issues

Unicode title error

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\pyHook\HookManager.py", line 348, in KeyboardSwitch
event = KeyboardEvent(msg, vk_code, scan_code, ascii, flags, time, hwnd, win_name)

builtins.SystemError: <class 'pyHook.HookManager.KeyboardEvent'> returned a result with an error set

I can't find pkg [help]

sabrina@johnmelody:~/Desktop/Webscrap$ sudo pip3 install python-pyxhook
The directory '/home/sabrina/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/sabrina/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. checkthe permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting python-pyxhook
  Could not find a version that satisfies the requirement python-pyxhook (from versions: )
No matching distribution found for python-pyxhook

Access violation, try/catch?

Mouse hook (all) doesn't work on my end creating access violation and silently exit the program.
It looks like that when I move the mouse quickly to the top edge it exits with access violation. I found the bug is on the line

win_name_decoded = PyUnicode_DecodeFSDefault(win_name);

and later on

Py_DECREF(win_name_decoded);

A temporary solution was to completely disable decode
win_name_decoded = win_name; //PyUnicode_DecodeFSDefault(win_name);

and it works fine on python but when I create exe out of it

pyinstall.exe myfile.py

the bug is still there and access violation appears.

And my question is why there is no try/catch on the cpyHook.i ?
Can anyone help me how to include the entire code in a try/catch so it will not silently exit the program upon error? I find very bad design from the original developer having an entire project without any try/catch.

I couldn't pass it at compile time

I encountered some error messages
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe' failed with exit status -1073741515

error: command 'swig.exe' failed: No such file or directory

No entiendo cual es el problema cuando intento instalarlo... Necesito ayuda por favor.
Al intentar instalarlo me sale esto en concrecto.

python setup.py build_ext
running build_ext
building 'pyHook._cpyHook' extension
swigging cpyHook.i to cpyHook_wrap.c
swig.exe -python -o cpyHook_wrap.c cpyHook.i
error: command 'swig.exe' failed: No such file or directory

对中文标题窗口的支持貌似依然存在bug

在pycharm下运行程序,英文标题下能够正常输出按键信息,但是当中文标题窗口被激活时,按下的按键很久才有反应,之后pycharm中运行的脚本崩溃,但是没有任何异常报告。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.