Manipulating a NSTextField via AppleScript

Posted by Garry on Stack Overflow See other posts from Stack Overflow or by Garry
Published on 2010-05-17T06:11:08Z Indexed on 2010/05/17 6:20 UTC
Read the original article Hit count: 238

A little side project I'm working on is a digital life assistant, much like project JARVIS. What I'm trying to do is speak to my mac, have my words translated to text and then have the text interpreted by my program.

Currently, my app is very simple, consisting of a single window containing a single wrapped NSTextView.

Using MacSpeech Dictate, When I say the custom command "Jeeves", MacSpeech ensures that my app is frontmost, highlights any text in the TextField and clears it, then presses the Return key to trigger the textDidEndEditing method of NSTextField. This is done via Applescript. MacSpeech then switches to dictation mode and the next sentence I say will appear in the NSTextField.

What I can't figure out is how to signify that I have finished saying a command to my program. I could simply say another keyword like "execute" or something similar that would send an AppleScript return keystroke to my app (thereby triggering the textDidEndEditing event) but this is cumbersome. Is there a notification that happens when text is pasted into a NSTextField? Would a timer work that would fire after maybe three seconds once my program becomes frontmost (three seconds should be sufficient for me to say a command)?

Thanks,

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about applescript