Page 1 of 1

Simulate Keypress

Posted: Sun Aug 25, 2013 1:01 pm
by shaky
hey, I've been trying to work out this problem, if someone could help me would be much appreciated

I came across this
on rawKeyDown theKeyNumber
put theKeyNumber
pass rawKeyDown
end rawKeyDown
(which gives me the key number for the designated key)

so I tried the script below hoping it would work but I guess im doing it wrong.
on mouseUp
rawKeyDown 65289 ( but just gives error (button "Button": execution error at line 2 (Handler: can't find handler) near "rawKeyDown", char 1)
end mouseUp

but what Im trying to do is when I click the button in my program it launches a exe file, then I need to simulate a key press so it will do a few tasks like a macro.
some of the keys I need to work are alt, (65513) and tab (65289) for example.
and if possible to have the code press alt & tab at same time.
im trying to work through the livecode lessons and university at the moment but any help with this would help a lot.

Thanks

Re: Simulate Keypress

Posted: Sun Aug 25, 2013 1:08 pm
by Mark
Hi,

Is that exe file a LiveCode standalone? If not, what is it?

You might write a VBScript and use the SendKeys method to emulate a keydown.

Kind regards,

Mark

Re: Simulate Keypress

Posted: Sun Aug 25, 2013 1:22 pm
by shaky
its actually Microsoft publisher, I need it to load the program which I can get to do, then I need it to sendkeys like I did in the past on visual basic to auto complete a few tasks.
kinda hoped to be able to do it in livecode.

Re: Simulate Keypress

Posted: Sun Aug 25, 2013 3:25 pm
by Mark
Hi,

Yes, you can do that with VBScript. LiveCode can execute your VBScript with the do command.

Kind regards,

Mark

Re: Simulate Keypress

Posted: Sun Aug 25, 2013 5:09 pm
by shaky
thx for the reply mark, I will need to read up on it.
do you mean I need to save the vbscript to a file and execute it from inside livecode, or is there a way to insert vbscript directly into livecode.
sorry total noob here but trying my best to learn livecode ;)

Re: Simulate Keypress

Posted: Sun Aug 25, 2013 5:14 pm
by Mark
Hi,

Look up the "do" command in the dictionary. You can use it to execute VBScript directly. Only in special cases, if you create new objects or routines, you need to create a separate file.

Kind regards,

Mark