Page 1 of 1

Is there a way to send keyboard keys to other windows?

Posted: Tue Sep 27, 2011 10:12 am
by keithglong
Hello,

This might be a dumb question, but is there a way in LiveCode to simulate sending keyboard keys to non-LiveCode applications/windows? For example, if I am running Firefox and want to send a CTRL-T in order to open a new tab, is there a way that I can simulate the CTRL and T being pressed and then send it to a particular instance of a Firefox Window accordingly?

Thanks,

- Boo

Re: Is there a way to send keyboard keys to other windows?

Posted: Tue Sep 27, 2011 7:36 pm
by sturgis
For a test run to see how it could be done, make a simple stack with a button and a field.
(disclaimer- I don't know vbscript very well, so anything more complex than this would require research)
In the field put the following:
Dim Wsh
Set Wsh = CreateObject("Wscript.Shell")
Wsh.AppActivate "Firefox" -- activate firefox so that it has focus
Wsh.SendKeys "^t" -- send the keys. the ^ stands for control in this case. % is alt, + is shift.
For the button script, put:

Code: Select all

on mouseUp
   do field 1 as "vbscript"
end mouseUp
Assuming firefox is already open, clicking the button should pop a new tab up. On this same note, its very possible that firefox has vbscript hooks so it might be possible to talk to it in a more direct way. But as I said, I don't know as much about vbscript as I would like.