Faking keypresses on Mac OS X

Ben Rubinstein benr_mc at cogapp.com
Wed Feb 27 13:11:04 EST 2008

On 27/2/08 16:43, Stephen Barncard wrote:
> TYPE doesn't do what you want?
> this has been around since the begnning of xtalks.
>> Does anyone know of a way to send a keypress into the system from Rev 
>> - natively or with extensions?
>> Obviously transcript includes a mechanism to move the user's mouse 
>> cursor; but I'm not aware of a similar mechanism to in effect type a 
>> key for them (or, for that matter, to click a mouse button for them).  
>> Have I missed anything?
>> Assuming not, has anyone tried to do this, eg using an external, or 
>> using a helper app of some kind?
>> (Context: I'm using Rev to make a kiosk browser app; in some instances 
>> there'll be no keyboard, so I want my app to provide an on-screen 
>> keyboard instead.  There are plenty of third-party options for 
>> on-screen keyboards, but it would be much neater if I could build it 
>> in Rev so that it can be nicely integrated; but when the user clicks 
>> on "A", I need to send that keypress to the RevBrowser instance.)

I'd forgotten about type, thank you!

But sadly 'type' doesn't do what I need; it simulates typing for the Rev 
stack, but not for the system.  Evidently a browser instance is really a 
window layered on top of the stack (at least on Mac); 'type' has no effect if 
the focus is on a text field in the browser instance.   I don't think 'type' 
does anything you couldn't do in transcript, finding the selection in a field 
and inserting characters.

So, thank you for the suggestion; but I'm still looking.  Granted that 'type' 
exists, I'm more doubtful if there is anything else in Rev (though I'd still 
be delighted to be 'reminded' of something else that I'd 'forgotten'); does 
anybody know of ways to fake a keypress to the system?  Evidently it's 
possible at a Cocoa or similar level, as there are various programs that for 
example allow you to use an apple remote and selectively map buttons on the 
remote to keypresses.  But I don't even know how to do it at that level, and I 
was hoping to avoid writing my first external for about five years...


- Ben

More information about the Use-livecode mailing list