SendKeys reference document
I have been using the foxipgw program to automatically log in to the gateway. Today I have made a program that automatically calls foxipgw, so I don’t need to click “OK” every time. The code is as follows.
set s= ("")
app_window = ("D:\Soft\")
200
app_window
"{ESC}"
"{ESC}"
Below are instructions for using SendKeys, from msdn.
--------------------------------------------------------------------------------
The SendKeys method sends one or more keystrokes to the active window (as if you were keystrokes on the keyboard).
(string)
parameter
object
WshShell object.
string
A string value that represents the keystroke(s) to be sent.
illustrate
Use the SendKeys method to send keystrokes to applications without an automated interface. Most keyboard characters can be represented by a single keystroke. Some keyboard characters are composed of multiple keystrokes (for example, CTRL+SHIFT+HOME). To send a single keyboard character, send the character itself as a string parameter. For example, to send the letter x, please send the string parameter "x".
Note: To send spaces, please send the string " ".
SendKeys can be used to send multiple keystrokes at the same time. To do this, each keystroke can be arranged in order to create a composite string parameter representing a series of keystrokes. For example, to send keystrokes a, b, and c, you need to send the string parameter "abc". The SendKeys method uses certain characters as modifiers for characters (without using their own meaning). This special set of characters can include parentheses, brackets, braces, and:
Plus sign “+”,
Insert mark "^",
percent sign "%",
and "non" symbols "~".
Enclose these characters in braces "{}" to send them. For example, to send a plus sign, use the string parameter "{+}". The brackets "[ ]" used in SendKeys have no special meaning, but they must be enclosed in braces to accommodate applications that really want to give them a special meaning (for example, for Dynamic Data Exchange (DDE)).
To send the left middle bracket character, please send the string parameter "{[]"; to send the right middle bracket character, please send the string parameter "{]}".
To send the left brace character, please send the string parameter "{{}"; to send the close brace character, please send the string parameter "{}}".
Some keystrokes do not generate characters (such as ENTER and TAB). Certain keystrokes represent operations (such as BACKSPACE and BREAK). To send these types of keystrokes, send the parameters listed in the following table:
Key Parameters
Backspace key {BACKSPACE}, {BS} or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
Down arrow key {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or 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}
To send keyboard characters composed of a regular keystroke and SHIFT, CTRL, or ALT, create a composite string parameter representing the keystroke combination. The above can be done by adding one or more of the following special characters before a regular keystroke:
Key Special Character
SHIFT +
CTRL ^
ALT %
Note: When using this, do not enclose these special characters in curly braces.
To specify that when multiple other keys are pressed, press the combination of SHIFT, CTRL, and ALT, create a composite string parameter and enclose the key combinations in brackets. For example, the key combination to be sent specifies:
If you press the SHIFT key while pressing e and c , the string parameter “+(ec)” is sent.
If you only press c (not SHIFT) when pressing e , the string parameter "+ec" is sent.
You can use the SendKeys method to send a keystroke that repeats the keys in a row. To do this, create a composite string parameter to specify the keystrokes to be repeated and after that number of repetitions. The above operation can be accomplished using the compound string parameters in the form of {keystroke number}. For example, if you want to send "x" 10 times, you need to send the string parameter "{x10}". Make sure there is a space between the keystroke and the number.
Note: You can only send keystrokes that press one key repeatedly. For example, "x" can be sent 10 times, but not 10 times, "Ctrl+x".
Note: The PRINT SCREEN key cannot be sent to the application {PRTSC}.
Example
The following example demonstrates how to use a .wsf file for two jobs written in different scripting languages (VBScript and Jscript). Each job runs the Windows calculator and sends it to a keystroke to perform simple calculations.
I have been using the foxipgw program to automatically log in to the gateway. Today I have made a program that automatically calls foxipgw, so I don’t need to click “OK” every time. The code is as follows.
set s= ("")
app_window = ("D:\Soft\")
200
app_window
"{ESC}"
"{ESC}"
Below are instructions for using SendKeys, from msdn.
--------------------------------------------------------------------------------
The SendKeys method sends one or more keystrokes to the active window (as if you were keystrokes on the keyboard).
(string)
parameter
object
WshShell object.
string
A string value that represents the keystroke(s) to be sent.
illustrate
Use the SendKeys method to send keystrokes to applications without an automated interface. Most keyboard characters can be represented by a single keystroke. Some keyboard characters are composed of multiple keystrokes (for example, CTRL+SHIFT+HOME). To send a single keyboard character, send the character itself as a string parameter. For example, to send the letter x, please send the string parameter "x".
Note: To send spaces, please send the string " ".
SendKeys can be used to send multiple keystrokes at the same time. To do this, each keystroke can be arranged in order to create a composite string parameter representing a series of keystrokes. For example, to send keystrokes a, b, and c, you need to send the string parameter "abc". The SendKeys method uses certain characters as modifiers for characters (without using their own meaning). This special set of characters can include parentheses, brackets, braces, and:
Plus sign “+”,
Insert mark "^",
percent sign "%",
and "non" symbols "~".
Enclose these characters in braces "{}" to send them. For example, to send a plus sign, use the string parameter "{+}". The brackets "[ ]" used in SendKeys have no special meaning, but they must be enclosed in braces to accommodate applications that really want to give them a special meaning (for example, for Dynamic Data Exchange (DDE)).
To send the left middle bracket character, please send the string parameter "{[]"; to send the right middle bracket character, please send the string parameter "{]}".
To send the left brace character, please send the string parameter "{{}"; to send the close brace character, please send the string parameter "{}}".
Some keystrokes do not generate characters (such as ENTER and TAB). Certain keystrokes represent operations (such as BACKSPACE and BREAK). To send these types of keystrokes, send the parameters listed in the following table:
Key Parameters
Backspace key {BACKSPACE}, {BS} or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
Down arrow key {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or 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}
To send keyboard characters composed of a regular keystroke and SHIFT, CTRL, or ALT, create a composite string parameter representing the keystroke combination. The above can be done by adding one or more of the following special characters before a regular keystroke:
Key Special Character
SHIFT +
CTRL ^
ALT %
Note: When using this, do not enclose these special characters in curly braces.
To specify that when multiple other keys are pressed, press the combination of SHIFT, CTRL, and ALT, create a composite string parameter and enclose the key combinations in brackets. For example, the key combination to be sent specifies:
If you press the SHIFT key while pressing e and c , the string parameter “+(ec)” is sent.
If you only press c (not SHIFT) when pressing e , the string parameter "+ec" is sent.
You can use the SendKeys method to send a keystroke that repeats the keys in a row. To do this, create a composite string parameter to specify the keystrokes to be repeated and after that number of repetitions. The above operation can be accomplished using the compound string parameters in the form of {keystroke number}. For example, if you want to send "x" 10 times, you need to send the string parameter "{x10}". Make sure there is a space between the keystroke and the number.
Note: You can only send keystrokes that press one key repeatedly. For example, "x" can be sent 10 times, but not 10 times, "Ctrl+x".
Note: The PRINT SCREEN key cannot be sent to the application {PRTSC}.
Example
The following example demonstrates how to use a .wsf file for two jobs written in different scripting languages (VBScript and Jscript). Each job runs the Windows calculator and sends it to a keystroke to perform simple calculations.