SendKeys reference Documentation _vbs

Source: Internet
Author: User
Tags documentation
SendKeys reference Documentation


has been using the FOXIPGW program to automatically login to the gateway, today made an automatic call FOXIPGW program, you do not have to "determine" each time, the code is as follows.
Set s= wscript.createobject ("Wscript.Shell")
App_window = S.run ("D:\Soft\FoxIPGW.EXE")
Wscript.Sleep 200
S.appactivate App_window
S.sendkeys "{ESC}"
S.sendkeys "{ESC}"

The following is a description of the use of SendKeys from MSDN.
--------------------------------------------------------------------------------


The SendKeys method sends one or more keystrokes to the active window (as if it were a keystroke on the keyboard).
Object. SendKeys (String)
Parameters
Object
WshShell object.
String
A string value that represents the keystroke (one or more) to be sent.
Description
Use the SendKeys method to send keystrokes to an application without an Automation interface. Most keyboard characters can be represented by one keystroke. Some keyboard characters are combined (for example, Ctrl+shift+home) by multiple keystrokes. To send a single keyboard character, send the character itself as a string parameter. For example, to send the letter x, send the string parameter "x".

Note To send a space, send the string "".
You can use SendKeys to send multiple keystrokes at the same time. To do this, you can create a composite string parameter that represents a series of keystrokes by arranging each keystroke in order. For example, to send keystrokes A, B, and C, you need to send the string parameter "abc". The SendKeys method uses some characters as modifiers to the character (rather than using its own meaning). This special set of characters can include parentheses, brackets, curly braces, and:

Plus "+",
Insert Mark "^",
Percent semicolon "%",
and "non" symbol "~".
Enclose these characters in curly braces "{}" to send them. For example, to send a plus sign, use the string argument "{+}". The brackets "[]" used in SendKeys have no special meaning, but they must be enclosed in curly braces to accommodate applications that are really given special meaning (for example, for Dynamic Data exchange (DDE)).

To send the left bracket character, send the string parameter ' {[] '; To send the right bracket character, send the string parameter ' {]} '.
To send a left curly brace character, send the string argument ' {{} '; to send the closing curly brace character, send the string parameter ' {}} '.
Some keystrokes do not generate characters (such as ENTER and TAB). Some keystrokes represent actions (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 key {down}
End {END}
Enter {Enter} or ~
ESC {ESC}
Help {Help}
Home {Home}
INS or insert {Insert} or {INS}
Left key {Ieft}
NUM LOCK {NumLock}
PAGE Down {PGDN}
PAGE up {PgUp}
PRINT Screen {PRTSC}
Rightwards Key {Right}
SCROLL LOCK {ScrollLock}
tab {TAB}
Up key {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 that are combined by regular keystrokes and SHIFT, CTRL, or ALT, create a composite string parameter that represents the combination of the keystrokes. You can do this by adding one or more of the following special characters before a regular keystroke:

Key special characters
SHIFT +
CTRL ^
ALT%

Note These special characters are not enclosed in curly braces when used in this way.
To specify that a combination of SHIFT, CTRL, and ALT be pressed when more than one key is pressed, create a composite string parameter, enclosing the key combination in parentheses. For example, the combination key to send specifies:

If you press the SHIFT key while pressing E and C, the string argument "+ (EC)" is sent.
If you press E only by pressing C (instead of pressing SHIFT), the string parameter "+ec" is sent.
You can use the SendKeys method to send a keystroke that repeats a key within one line. To do this, you create a composite string parameter to specify the keystrokes you want to repeat, and then specify the number of repetitions thereafter. You can do this by using a composite string parameter in the form of {keystroke number}. For example, if you want to send 10 times "x", you need to send the string argument "{x 10}". Make sure there is a space between the keystrokes and the numbers.

Note You can send only keystrokes that repeatedly press one key. For example, you can send "X" 10 times, but you cannot send "ctrl+x" 10 times.
Note the PRINT screen key {PRTSC} cannot be sent to the application.
Example
The following example shows how to use a. wsf file for two jobs written in different scripting languages (VBScript and Jscript). Each job runs a Windows calculator and sends it to keystrokes to perform a simple calculation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.