Most viewed recipes tagged "keylogger"http://code.activestate.com/recipes/tags/keylogger/views/2011-11-21T14:53:52-08:00ActiveState Code RecipesParser Keylogger based on a Finite State Machine (Python)
2011-11-21T14:53:52-08:00Filippo Squillacehttp://code.activestate.com/recipes/users/4174931/http://code.activestate.com/recipes/577952-parser-keylogger-based-on-a-finite-state-machine/
<p style="color: grey">
Python
recipe 577952
by <a href="/recipes/users/4174931/">Filippo Squillace</a>
(<a href="/recipes/tags/keylogger/">keylogger</a>, <a href="/recipes/tags/parser/">parser</a>, <a href="/recipes/tags/state_machine/">state_machine</a>).
Revision 3.
</p>
<p>This program parses the logfile given by the execution of the keylogger
command <strong>'script -c "xinput test ID_CODE" | cat LOG_FILE'</strong> and
it is based on a Finite State Machine (FSM) to manage all
the possible combinations of the modifiers that represent the state of the FSM.
The parser gets the mapping between the couple of keycode and modifier typed
and the corresponding char by xmodmap command. The parser is able to manage also extended
combinations such as Control or Super that don't give a real char.
To introduce new possible states that represent new combinations between modifiers,
it's just necessary to update the list of state (<em>mod_keys</em>) and add new rules in the transition function properly.
For example to introduce the Caps Lock state just add it in mod_keys and the data structure transition has to handle
the release event of the corresponding key.
For the dependency of xmodmap the parser works only in X11 based systems.</p>