tags:

views:

99

answers:

1

Hello, I am writing a program to sit in the background on osx 10.6, listen to keystrokes and record them, grouping them by window title. (No, I am not writing malicious software. I do not need this program to be sneaky in any way, I just want to have a safety net for when I have typed a huge email and then accidentally refresh the page (APPLE-R) instead of opening a new tab (APPLE-T)) I have already found apple's EventMonitorTest example for the keystroke capturing code, now I just need to find the "key window" title.

Does anyone know where I can find examples for this kind of functionality? Thank you!

+3  A: 

A couple of possibilities:

  1. You could use the Accessibility API (though of course keep in mind that 64-bit Carbon does not support this)
  2. You could use the CGWindow functions introduced in Leopard

I suspect the first option will be easier to do this with, since the CGWindow API is somewhat low-level and treats all windows (application windows, menu bars, dock icons, etc.) more or less equally.

Chuck