C # simulate keyboard operations -- SendKey (), SendKeys ()

Source: Internet
Author: User

Today is an excellent offer! When simulating a keyboard operation, you can hear it. Hey, isn't it? /...
Go to the topic ..

The following two syntaxes are used to simulate keyboard input.
SendKeys. Send (string keys); // simulate Chinese character (text) Input
SendKeys. SendWait (string keys); // simulate key input

Let's take a look at the usage of the two syntaxes! Paste the code later to see if you can understand it /...

(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 percentage 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 the braces, use {}.
 

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

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) SHIFT, CTRL, ALT, and other key combinations, one or more codes can be placed in front of these key codes. These codes are listed as follows:

Buttons Code
Shift +
Ctrl ^
Alt %

 

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

/* ---------------- The following is the case code -----------------*/

    button1_Click(            SendKeys.SendWait(

 

 

 

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.