How can you read keystrokes when the python program is not in the foreground?

I am trying to analyze my keystrokes over the next month and would like to create a simple program for this. I don’t want to write down commands exactly, but just generate general statistics on my keystrokes.

I am the most convenient code in python, but I am open to other suggestions. Is this possible, and if so, which python modules should I look at? Is it already done?

I am on OSX, but will also be interested in this in the Ubuntu window and Windows XP.

+5
source share
4 answers

, http://patorjk.com/keyboard-layout-analyzer/

, , , .

, Linux /dev/event * , . , cat /dev/event0 > keylogger. struct input_event. . http://www.linuxjournal.com/article/6429.

Python struct - .

OSX logkext. http://code.google.com/p/logkext/

+4

, , , , , .

Windows PyHook .

Linux Python X Library ( , ).

pykeylogger. (., , pyxhook.py), , . , , .

+2

X- , pykeylogger Linux . evdev demo. , , , .

import evdev
keyboard_location = '/dev/input/event1'  # get the correct one from HAL or so
keyboard_device = evdev.Device(keyboard_location)

, :

keyboard_device.poll()
+2

, , , ; Workrave - , , . , , , ( / ). (++), , .

0

All Articles