17 August 2007

Send keypresses by Launchkey

If you need to send key to the any application, you can use a VBScript, like following example:

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
WScript.Sleep 100
WshShell.AppActivate "Calculator"
WScript.Sleep 100
WshShell.SendKeys "1{+}"
WScript.Sleep 500
WshShell.SendKeys "2"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 500
WshShell.SendKeys "*3"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 2500

But, if you want to use a batch script, use a LaunchKey. LaunchKey is a freeware command-line utility that runs an application and sends keypresses to it.

The syntax for using LaunchKey is:

Launchkey "KEYS TO SEND" "APPLICATION TO RUN" ["APPLICATION PARAMETERS"]

as in:

Launchkey "Here is some text." Notepad

"You can send all the normal key character keys as well as special keys like ALT, CTRL, F1-F12 etc. More information about how to send key presses is contained in the accompanying Helpfile."

Download LaunchKey.zip


Bookmark and Share ITStuff.ca

2 comments: