C # SendKeys Usage

Source: Internet
Author: User

Function: sends one or more key messages to the active window as if it were entered on the keyboard.

Syntax: Sendkeys.send (string keys); Sendkeys.sendwait (string keys);

Description

(1) Each key is represented by one or more characters. In order to specify a single keyboard character, you must press the key of the character itself. For example, to represent the letter A, you can use "a" as a string. To represent more than one character, you must precede the character with a second character. For example, to represent A, B, and C, you can use "ABC" as a string.

(2) for SendKeys, the plus (+), caret (^), percent sign (%), underscore (~), and parenthesis () have special meanings. To specify any one of these characters, place it in curly braces ({}). For example, to specify a positive sign, you can use {+}. square brackets ([]) do not have a special meaning for SendKeys, but they must be placed in curly braces. In other applications, square brackets have a special meaning, which can be significant in the event of Dynamic Data Exchange (DDE). To specify curly brace characters, use {{} and {}}.

(3) to specify characters that do not appear when you press a key, such as ENTER or TAB and those that represent an action other than a character, use the following code:

Keys 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}

(4) in order to specify the key combinations with the SHIFT, CTRL and ALT keys, you can place one or more code in front of these key codes, which are listed as follows:

key code
shift ctrl ^
alt %

Note: You cannot use SendKeys to send a key message to this Like an application, this application is not designed to run in Microsoft Windows. SendKeys also cannot send the print Screen key {PRTSC} to any application.

(5) Input Chinese characters with sendkeys.send ("kanji");

Reprinted from: http://www.cnblogs.com/sydeveloper/archive/2013/02/25/2932571.html

C # SendKeys Usage

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.