----Send function of AutoIt function learning

Source: Internet
Author: User

Send:

Function: Sends an analog keystroke operation to the activation window.

Syntax: Send (' key ' [, Flag])

Parameters:

Key: The key sequence to send.

Flag: [Optional parameter] Change the way the program handles "keys":
Flag = 0 (default), the key sequence contains special characters such as + and! will be treated as the SHIFT and ALT keys.
Flag = 1, the button will be sent as-is.

Attention

For more instructions/tips on using the Send function, see the Appendix. AutoIt can send all ASCII codes and extended ASCII characters (0-255), to send UNICODE encoded characters you must use the "ASC" option plus the character code you want to send (see {ASC} below).

The syntax for the "Send" command is similar to ScriptIt and the "SendKeys" command for Visual Basic. The character sequence is sent in the original language, except for the following characters:

'! '
tells AutoIt to send an ALT keystroke action, so the statement send ("This is text!a") means that the button "This is text" was sent sequentially and then pressed "Alt+a".

Note that some programs are quite picky about uppercase and lowercase characters and ALT keys, for example, "! A "may be considered to be different from"!a "; the first represents Alt+shift+a, while the second represents Alt+a. It's best to use lowercase if you are unsure!

' + '
tells AutoIt to send a SHIFT keystroke, so the statement send ("Hell+o") means that the button "HellO" is sent sequentially. Send ("!+a") means "alt+shift+a" is sent.

' ^ '
tells AutoIt to send a CONTROL keystroke action, so the statement send ("^!a") means the button "Ctrl+alt+a" is sent.

Note that some programs are quite picky about uppercase and lowercase characters and the CTRL key, for example, "^a" may be considered different from "^a"; the first represents Ctrl+shift+a, while the second represents CTRL + A. If you are unsure, use lowercase!

' # '
The pound sign will send a Windows logo key, so the statement send ("#r") will send Win+r, which will open the Run dialog box.

you can turn off the case toggle key (Caps LOCK, CAPS Lock) and resume after the operation is completed by setting Sendcapslockmode to close the Send function before it starts operation.
However, if the user presses the SHIFT key while the Send function is executing, the text that is sent may be lowercase characters.
One workaround is to use the statement send ("{shiftdown}{shiftup}") before each other Send operation.

If you want to send ASCII character A then refer to the example below (equivalent to alt+065, alt-Press 065 on the numeric keypad)
Send ("{ASC 065}")

(You must add a 0 before using the two-digit ASCII code, otherwise the No. 437 code page will be used).

If you want to send UNICODE characters, enter that character code, for example, the following example sends a Chinese characters
Send ("{ASC 2709}")

You can refer to the following example to send a key repeatedly:
Send ("{DEL 4}"), 4 times in a row press the DEL key
Send ("{S 30}"); sends 30 characters "S"
Send ("+{tab 4}"), 4 times in a row press Shift+tab

if you want to press and hold (hold down) a key (usually used in the game)
Send ("{A Down}"); Press and hold the key a
Send ("{A Up}"); release Button A

If you want to change the state of the CapsLock, NumLock, and ScrollLock keys, refer to the following example:
Send ("{NumLock on}"); open NumLock
Send ("{CapsLock off}"); Close CapsLock
Send ("{ScrollLock Toggle}"); Toggle the status of ScrollLock

If you want to use a variable to specify the number of times to send repeatedly, refer to the following example:
$n = 4
Send ("+{tab" & $n & "}")

If you want to use a variable to specify the ASCII character to be sent repeatedly (for example, A), refer to the following example:
$x = Chr
Send ("{" & $x & "4}")

Most laptops will have a special Fn key on their keyboard that cannot be simulated.

Note that if you set the value of the flag parameter to 1, the "key" parameter will be sent as is. You should use this setting if some text is copied from a variable and you want to send the text exactly as it is.

----Send function of AutoIt function learning

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.