Simulating the keyboard in other applications

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
andrewferguson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 184
Joined: Wed Apr 10, 2013 5:09 pm

Simulating the keyboard in other applications

Post by andrewferguson »

Hi,
I am trying to find a way to send "virtual keystrokes" to the computer. I know that the "type" command sends keystrokes to LiveCode, but I need it to be sent to the whole computer.

For example:
My Application would be running in the background, receiving messages and then typing text into Microsoft Word. Unfortunatly I cannot just use the "write to file" command, as the keystrokes would need to be sent to other applications, Like Control Panel, or used in shortcuts Ctrl+S.

I don't mind using the command line via the "shell" command, as long as it worked with Windows, Mac OS X and Linux.

Any Ideas?
andrewferguson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 184
Joined: Wed Apr 10, 2013 5:09 pm

Re: Simulating the keyboard in other applications

Post by andrewferguson »

Ok,
After a bit of digging, I found a way to make this work in Mac OS X using AppleScript.

Make a variable and put this into the variable:
tell application "System Events"
keystroke "<name of key>"
end tell

Then:
do <variable name> as applescript

If anyone else has any other ideas on how to make this work for Windows or Linux, I would be glad to hear them.
Andrew
Post Reply