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

How to realize sendkeys simulated keystroke by VBS

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to achieve VBS sendkeys simulation keystroke operation, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The code is as follows:

'= =

'SendKeys simulates keyboard keystrokes in VBS

'2009-07-26

'= =

Dim WshShell

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

WshShell.Run "cmd"

'Let the script wait 1000 milliseconds, that is, 1 second before executing the next statement

WScript.Sleep 1000

When sending characters, the input method must be in the English file state

'send semicolon

WshShell.SendKeys ";"

WScript.Sleep 1000

'send a colon

WshShell.SendKeys ":"

WScript.Sleep 1000

'send double quotes-use chr to convert double quotation marks

WshShell.SendKeys Chr (34)

WScript.Sleep 1000

'send a string with double quotation marks

WshShell.SendKeys Chr (34) & "this is a string" & Chr (34)

WScript.Sleep 1000

Remember, this is a simulated keystroke operation, so it cannot be sent in Chinese

'WshShell.SendKeys Chr (34) & "this is a string" & Chr (34)

WScript.Sleep 1000

'=

'--how to simulate enter, upper key, Alt key?

'=

'--how to simulate enter,-- {enter} this means that it is sent to enter.

WshShell.SendKeys "this is an enter! {enter}"

WScript.Sleep 1000

'--how to simulate the upfile key Shift,-+ this means sending shift

WshShell.SendKeys "this is + a" result is this is A

WScript.Sleep 1000

'--how to simulate Alt,--% this means sending Alt

WshShell.SendKeys "this is% {TAB}" 'result is a toggle window

WScript.Sleep 1000

'=

'--so how to send%, + ^ murmur

WshShell.SendKeys "this is {+} {^} {%}" 'result is a toggle window

WScript.Sleep 1000

You may already understand here, when sending special characters, please put them in {}

'=

'= =

For more information, see the VBS help documentation 2009-07-26

'= =

The above is all the content of the article "how to achieve sendkeys simulated keystroke operation by VBS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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