programming

How to press any key automatically using batch program by opening existing user running application

Pressing any key automatically using batch program by opening existing user running application are given below:

Suppose your application is running in windows OS. Your need is to open application and press Ctrl+F to find something automatically by batch program. Then you can follow the instructions are given below

1. Create a VB script file named like “program.vbs”. Write following code and save it

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "notepad"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "^s"

where “notepad” is Notepad application which is already running. “WshShell.SendKeys” is using to keypress dynamically.

2. Create a batch file named like “auto.bat” and write following code and save it

wscript "F:\Ict_Backup\Desktop\program.vbs"

3. Run the batch file. See what happens.

Find more key code for vb script:

Key Code
Break {BREAK}
Backspace {Backspace}, {BKSP} or {BS}
Delete {DELETE} or {DEL}
Down Arrow {DOWN}
End {END}
Enter {ENTER} or ~
Escape {ESC}
Help {HELP}
Home {HOME}
Insert {INSERT} or {INS}
Left Arrow {LEFT}
Num Lock {NUMLOCK}
Page Down {PGDN}
Page Up {PGUP}
Print Screen {PRTSC}
Right Arrow {RIGHT}
Scroll Lock {SCROLLLOCK}
Tab {TAB}
Up Arrow {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}
Alt {%}
Ctrl {^}
Shift Lock {+}

For example to specify CTRL and C, the code would be object.SendKeys “^C” and for SHIFT F5 object.SendKeys “+{F5}”. To specify multiple combination sets such as ALT A Z, you use parentheses, for example, object.SendKeys “%(AZ)”.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s