capturing text typed in a document

Dear Adam (Bell),

Thanks for the response! Could you give me an idea (or point to an example) how to “capture what was typed from the document”? It sounds better than capturing keystrokes, too, because the user can switch documents or applications without having to switch the script off and back on.

For completeness, here’s the original text to which you responded:

To be useful in that application, however, the script would have to capture each letter as it was typed. As far as I know, there is no AppleScript way to find out that a character was added to a document except by polling it faster than folks are likely to add letters and grabbing the last five whenever the last five changed. An on idle script can do that, but would be rather CPU instensive because of the frequent runs. Perhaps others can suggest a better way.

I’m sorry, but the requested behavior of this code smacks of malware. If you want to help users input 5 digits, then why not simply set the clipboard to the needed input and paste?

  1. Do you think “on change” could work?
  2. Yes, I was afraid it would be slow/CPU-intensive. The other response to my earlier post suggested using a Cocoa object for AppleScript Studio. Do you know where I should look for likely candidates? I have no experience at all with C or object C.

Marc Anthony/malware: I’m sorry, but beauty lies in the eyes of the beholder. The intended function is like the nifty things you can now do with fonts like Zapfino: automating access to special glyphs.