I wrote a keylogger that tweets every 140 characters I type http://twitter.com/keytweeter
I know this is more conceptual than the usual ofw-interactive-installation-stuff, but still – it wouldn’t have been possible without ofw
I used:
-
ofxXmlSettings to store some information like username, password, and filtered words (passwords, credit card numbers, ssn) that I consider “control” rather than “information”.
-
ofxThread to do the posting and keylogging asynchronously, so keys aren’t lost when posts are being made.
-
Some code I posted at http://forum.openframeworks.cc/t/hiding-command-window-and-minimizing-to-system-tray/1244/0 for handling window hiding (I use the Home and End keys to show and hide the debug console)
-
ofEvents were used for the keylogger’s callbacks. e.g.:
ofAddListener(logger.keyPressed, this, &AutoTweet::keyPressed);
See ofxKeyLogger for my windows-specific keylogger implementation. I know Arturo has some linux specific code and zach has some osx specific code – both from oflab – for doing keylogging. I tried to write ofxKeyLogger so that it could be extended for other OSes.
- I used the cURL binary and system() to invoke it. http://curl.haxx.se/
The biggest pain was getting some unicode sent to Twitter correctly to represent the arrow and return keys. I could represent the unicode in a string using \u escape sequences, but it would store it in multiple bytes – so the character count was off. wstring correctly reported the size() of the buffer, but didn’t like being sent to _wsystem. In the end I wrote a wrapper called ofxString that let me store ints instead of characters, with the ints corresponding to the OF_KEY mappings.
If you’d like to run the app yourself, just add a bin/data/config.xml that looks like this:
<username>twitterUsername</username>
<password>twitterPassword</password>
<safe>somePassword</safe>
<safe>creditCardNumber</safe>
<safe>SSN</safe>
And be sure to add the cURL binary to /bin or your system path.