C # simulate keyboard input

Source: Internet
Author: User

SendKeys is the main class used. Send () to the active application by sending the click action behavior.

Example: SendKeys. Send ("123 ");

It will simulate the keyboard Hitting 1, 2, 3 ,;

Each key is represented by one or more characters. To specify a single keyboard character, use the character itself. For example, to represent the letter A, pass the string "A" to the method. To indicate multiple characters, append each additional character to the end of the character before it. To indicate letters A, B, and C, specify the parameter as "ABC ".

Plus sign (+), inserted symbol (^), percent sign (%), wave number (~) And parentheses () have special meanings for SendKeys. To specify a character in these characters, place it in braces. For example, to specify a plus sign, use "{+ }". To specify braces, use "{{}" and "{}}". Brackets ([]) have no special meaning for SendKeys, but must be placed in braces. In other applications, brackets have special meanings, which may play an important role in the occurrence of Dynamic Data Exchange (DDE.

 

Below isSendKeys.
Key code
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREA {BREAK}
Caps lock {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
Down ArrowKey {DOWN}
END {END}
ENTER {ENTER} Or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS, INSERT {INSERT}, or {INS}
LEFT arrow {LEFT}
Num lock {NUMLOCK}
Page down {PGDN}
Page up {PGUP}
Print screen {PRTSC} (reserved for future use)
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}
Numeric keypad plus sign {ADD}
Keyboard minus {SUBTRACT}
Numeric keypad multiplication number {MULTIPLY}
Keypad division {DIVIDE}

To specify keys that can be used with any combination of SHIFT, CTRL, and ALT keys, add one or more codes before these key codes:

Key code
SHIFT +
CTRL ^
ALT %

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.