Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is SendKeys?

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "what is SendKeys". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what is SendKeys?"

SendKeys reference documentation

Has been using the foxipgw program to automatically log in to the gateway, today to do an automatic call to the foxipgw program, do not have to click "OK" every time, the code is as follows.

Set s = WScript.CreateObject ("WScript.Shell")

App_window = s.run ("D:\ Soft\ FoxIPGW.EXE")

WScript.Sleep 200

S.AppActivate app_window

S.SendKeys "{ESC}"

S.SendKeys "{ESC}"

Here are the instructions for using SendKeys, from msdn.

The SendKeys method sends one or more keystrokes to the active window (as if you were typing on a keyboard).

Object.SendKeys (string)

Parameters.

Object

WshShell object.

String

A string value that represents one or more keystrokes to be sent.

Description

Use the SendKeys method to send keystrokes to applications that do not have an automated interface. Most keyboard characters can be represented by a keystroke. Some keyboard characters are made up of multiple keystrokes (for example, CTRL+SHIFT+HOME). To send a single keyboard character, send the character itself as a string parameter. For example, to send the letter x, send the string parameter "x".

Note that if you want to send spaces, please send the string "".

Multiple keystrokes can be sent at the same time using SendKeys. To do this, you can arrange each keystroke in order to create a composite string parameter that represents a series of keystrokes. For example, to send keystrokes a, b, and c, you need to send the string parameter "abc". The SendKeys method uses certain characters as modifiers for characters (instead of using their own meaning). This special set of characters can include parentheses, square braces, curly braces, and:

Plus sign "+",

Insert the token "^",

Percent sign "%",

And the "non" symbol "~".

Enclose these characters in curly braces "{}" to send them. For example, to send a plus sign, use the string parameter "{+}". The square braces "[]" used in SendKeys do not have any special meaning, but they must be enclosed in curly braces to accommodate the application that does give it a special meaning (for example, for dynamic data exchange (DDE)).

To send the left square bracket character, send the string parameter "{[]"; to send the right square bracket character, send the string parameter "{]}".

To send the left brace character, send the string parameter "{{}"; to send the right brace character, send the string parameter "{}}".

Some keystrokes do not generate characters (such as ENTER and TAB). Some keystrokes represent operations (such as BACKSPACE and BREAK). To send these types of keystrokes, send the parameters listed in the following table:

Key parameter

Backspace key {BACKSPACE}, {BS} or {BKSP}

BREAK {BREAK}

CAPSLOCK {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}

NUMLOCK {NUMLOCK}

PAGE DOWN {PGDN}

PAGE UP {PGUP}

PRINT SCREEN {PRTSC}

Right Arrow {RIGHT}

SCROLLLOCK {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}

To send keyboard characters that are a combination of regular keystrokes and SHIFT, CTRL, or ALT, create a composite string parameter that represents the keystroke combination. You can do this by adding one or more of the following special characters before regular keystrokes:

Key special character

SHIFT +

CTRL ^

ALT%

Note that these special characters are not enclosed in curly braces when used in this way.

To specify that the combination of SHIFT, CTRL, and ALT is pressed when multiple other keys are pressed, create a composite string parameter, enclosing the key combination in parentheses. For example, the key combination to send specifies:

If you press SHIFT while pressing e and c, the string parameter "+ (ec)" is sent.

If you press c only (instead of SHIFT) when pressing e, the string parameter "+ ec" is sent.

You can use the SendKeys method to send a keystroke that repeats the key in a row. To do this, create a composite string parameter to specify the keystroke to repeat, followed by the number of repeats. You can do this using a compound string parameter in the form of {keystroke number}. For example, if you want to send "x" 10 times, you need to send the string parameter "{x 10}". Make sure there is a space between the keystroke and the number.

Note that you can only send keystrokes that press one key repeatedly. For example, you can send "x" 10 times, but not "Ctrl+x" 10 times.

Note that the PRINT SCREEN key {PRTSC} cannot be sent to the application.

Example

At this point, I believe you have a deeper understanding of "what is SendKeys", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report