SendKeys and sendkeys

Source: Internet
Author: User

SendKeys and sendkeys

Usage:

Using System. Windows. Forms; // Add namespace reference

{

SendKeys. SendWait ("{DOWN }");

Ppt.ppt _ sendkey ("+ {F5}"); // full screen represents a combination of SHIFT + F5: the plus sign directly represents the shift key

Ppt.ppt _ sendkey ("{ESC}"); // cancel full screen

}

SendKeys statement

Send one or more key messages to the activity window, just as you input them on the keyboard.

Syntax

SendKeys string [, wait]

The syntax of the SendKeys statement has the following naming parameters:

Partial description
String is required. String expression that specifies the key message to be sent.
Optional. Specifies the BooleandefBooleanDataType@veendf98.chm value for the wait mode. If it is False (default), the control returns to the process immediately after the key is sent. If the value is True, the key message must be processed before the control returns to the process.


Description

Each key is represented by one or more characters. To specify a single keyboard character, you must press the character key. For example, to represent the letter A, you can use "A" as the string. To indicate multiple characters, you must add another character directly after the character. For example, to indicate a, B, and C, "ABC" can be used as A string.

For SendKeys, the plus sign (+), the insert character (^), the percent sign (%), and the upper line (~) And parentheses () have special significance. To specify any of the preceding characters, place them in braces. For example, to specify a positive number, it can be represented by {+. Square brackets ([]) do not have special significance for SendKeys, but must be placed in braces. Square brackets are of special significance in other applications. When Dynamic Data Exchange (DDE) occurs, it may be of great significance. To specify braces, use {} and {}}.

Use the following code to specify characters that are not displayed when you press the key, such as ENTER or TAB, and keys that represent actions rather than characters:

Key code
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
Caps lock {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
Down arrow {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 specify keys that combine with the SHIFT, CTRL, and ALT keys, you can place one or more codes in front of these key codes. The codes are listed as follows:

Key code
SHIFT +
CTRL ^
ALT %


To show that you should press any combination of SHIFT, CTRL, and ALT at the same time when pressing other keys, please put the code of those keys in brackets. For example, to demonstrate how to press the SHIFT key while pressing E and C, use "+ (EC )". "+ EC" is used to indicate that the SHIFT key is pressed at the same time while the C key is pressed instead of the SHIFT key ".

To specify duplicate keys, use the {key number} format. A space must be placed between the key and number. For example, {LEFT 42} Means 42 times to press the left arrow key; {h 10} means 10 times to press the H key.

Note that you cannot use SendKeys to send a key message to an application that is not designed to run in Microsoft Windows. Sendkeys cannot send the print screen button {PRTSC} to any application either.

 

Related Article

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.