C # sendkeys usage

Source: Internet
Author: User

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

Syntax: sendkeys. Send (string keys); sendkeys. sendwait (string keys );

Note:

(1) 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.

(2)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. In other applicationsProgramSquare brackets have special significance. When Dynamic Data Exchange (DDE) occurs, it may be of great significance. To specify braces, use {} and {}}.

(3)To specify the characters that are not displayed when you press the button, such as enter or tab, and the buttons that indicate actions rather than characters, use the followingCode:

Buttons 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 {F1}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}

(4)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:

buttons 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: 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.

(5) Use sendkeys. Send ("") to input Chinese characters ");

 

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.