Hack: Griffin AirClick USB for use with iFlash

I got a cheap used Griffin AirClick for USB to control my older laptop Macintosh by remote control. Another remote I like better (KeyPOINT) has been acting up so I got the Griffin as a replacement. The downside with Griffin is that it has fewer buttons, no mouse control, and a limited set of applications that it works with. One of the applications that I want to use the remote with is the best flashcard program on the Macintosh, iFlash. I use this almost every day to practice Korean vocab and other languages. Since this is not one of the supported applications, this afternoon I hacked the AirClick.app program that comes with the remote to add support for iFlash. You may download my modified version of the AirClick application here.

For those who wish to add support for their own program I briefly outline how I did the hack below:

1. Open the Package contents for AirClick.app (right click and show package contents in the finder).
2. Using a word processor like BBEdit, modify the file Contents/Resources/functions.plist. Copy and paste one of the dictionary entries (I used the radioShark entry) and change the script that each button points to the name of your scripts for each button (I used iflash_[button name].scpt). This will add a menu item for your application (in my case iFlash) in the menu for AirClick.
3. Using Script Editor, write applescripts for each button. AirClick.app has its own applescript dictionary, the most important comamnds being “simulate ascii key code” and “simulate virtual key code.” For example, my iflash_playpause.scpt is attached to the space key, which marks words correct:

tell application “AirClick”
simulate ascii key code 32
end tell

and my iflash_fforward.scpt is set to click the right arrow key:

tell application “AirClick”
simulate virtual key code 124 –I don’t know why, but 124 is the right arrow
end tell

and my iflash_rewind.scpt is set to the down arrow key:

tell application “AirClick”
simulate virtual key code 126 –I don’t know why, but 126 is the down arrow
end tell

4. You need put in your root/user password, but save these scripts as text (not as regular scpt files) and make sure they have .scpt not .applescript as the extension. inside the AirClick.app/Contents/Resources folder.

That is all I had to do to get it work. I wasted the most time to figure out that the scpt files in the Resources folder are not real binary scpt files but just regular text files, which prevented my scripts from running correctly.