PDA

View Full Version : sending keystrokes with NR



kaeton
November 6th, 2007, 05:35 PM
I was wondering if anybody knows if I can send a keystroke to the same machine running NR, using only NR and not girder.

On a side note, does anybody else have problems logging in to the forum.

I can never login. I have to have a new password sent to my email in order to login. Kind of a pain.

Any advice?

Thanks,

Kaeton

tmorten
November 7th, 2007, 12:41 PM
I'm not sure about the forum problems... seems to be working from this end. Do you have cookies disabled?

For keystrokes, Girder is really the way to go. NetRemote isn't set up to do that kind of thing.

Best,
Tim

harleydude
November 7th, 2007, 02:15 PM
True that NR can't send keys to another application. However I found the follow code snippet that might help.


require("luacom")
function SendKeys()
WshShell = luacom.CreateObject("WScript.Shell");
WshShell:Run("calc");
NetRemote.Sleep(100);
WshShell:AppActivate("Calculator");
NetRemote.Sleep(100);
WshShell:SendKeys("1{+}");
NetRemote.Sleep(100);
WshShell:SendKeys("2");
NetRemote.Sleep(100);
WshShell:SendKeys("~");
NetRemote.Sleep(100);
WshShell:SendKeys("*3");
NetRemote.Sleep(100);
WshShell:SendKeys("~");
WshShell = nil;
collectgarbage();
end

Put the above in your .lua file, add a button to the screen and assign a Execute Lua action with SendKeys() as the lua to execute. Was able to make it work here.