In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use sendkeys in vbscript. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Its format is: object.SendKeys string
"object": represents a WshShell object
"string": indicates the keystroke instruction string to be sent, which needs to be enclosed in English double quotation marks.
1. Basic key
Generally speaking, the key instruction to be sent can be directly represented by the key character itself, for example, to send the letter "x", use "WshShell.SendKeys" x "". Of course, you can also send multiple keystroke instructions directly, simply by arranging the keystroke characters together in order. For example, to send the keystroke "happy", you can use "WshShell.SendKeys" happy ".
two。 Special function key
For keys that need to be combined with the three control keys Shift, Ctrl, and Alt, SendKeys uses special characters to indicate:
Shift-WshShell.SendKeys "+"
Ctrl-WshShell.SendKeys "^"
Alt-WshShell.SendKeys "%"
Since the characters "+" and "^" are used to represent special control keys, how do you represent these keys?
Just enclose the characters in curly braces. For example:
To send the plus sign "+", use "WshShell.SendKeys" {+} "
In addition, for some control function buttons that do not generate characters, you also need to use curly braces to enclose the name of the key. For example, to send an enter key, you need to use "WshShell.SendKeys" {ENTER} "", and the direction key sent downward is indicated by "WshShell.SendKeys" {DOWN} ".
Space-WshShell.SendKeys ""
Enter-WshShell.SendKeys "{ENTER}"
←-WshShell.SendKeys "{RIGHT}"
↑-WshShell.SendKeys "{UP}"
F1-WshShell.SendKeys "{F1}"
Tips: if you need to send multiple duplicate single-letter keys, you don't have to type the letter repeatedly. SendKeys allows you to describe it in a simplified format, using the format "{keystroke number}". For example, to send 10 letters "x", enter "WshShell.SendKeys" {x 10} "".
Example:
Press F5 to refresh the desktop
Dim WshShell,Path,i
Set WshShell = WScript.CreateObject ("WScript.Shell")
WshShell.SendKeys "{F5}"
Automatic restart of computer
Set WshShell = CreateObject ("WScript.Shell")
WshShell.SendKeys "^ {ESC} u"
WshShell.SendKeys "R"
Start the Task Manager
Set WshShell = CreateObject ("WScript.Shell")
WshShell.SendKeys "^ + {ESC}"
Send QQ messages in groups
Dim WshShell
Set WshShell= WScript.createObject ("WScript.Shell")
WshShell.AppActivate "bomb"
For iTunes 1 to 60
WScript.Sleep 800
WshShell.SendKeys "Number0"
WshShell.SendKeys i
WshShell.SendKeys 's'
Next
Automatically search for songs on Baidu: white flag
Dim WshShell,Path,i
Set WshShell = WScript.CreateObject ("WScript.Shell")
WshShell.Run ("IEXPLORE.EXE")
WScript.Sleep 2000
WshShell.AppActivate "about:blank-Microsoft Internet Explorer"
WshShell.SendKeys "+ {TAB}"
WshShell.SendKeys "http://mp3.baidu.com"
WScript.Sleep 800
WshShell.SendKeys "{ENTER}"
WScript.Sleep 3000
WshShell.SendKeys "white flag"
WScript.Sleep 800
WshShell.SendKeys "{ENTER}"
Enter Happy Birthday in notepad! And save as birth.txt
Dim WshShell
Set WshShell=WScript.CreateObject ("WScript.Shell")
WshShell.Run "notepad"
WScript.Sleep 1500
WshShell.AppActivate "No title-notepad"
WshShell.SendKeys "H"
WScript.Sleep 500
WshShell.SendKeys "a"
WScript.Sleep 500
WshShell.SendKeys "p"
WScript.Sleep 500
WshShell.SendKeys "p"
WScript.Sleep 500
WshShell.SendKeys "y"
WScript.Sleep 500
WshShell.SendKeys ""
WScript.Sleep 500
WshShell.SendKeys "B"
WScript.Sleep 500
WshShell.SendKeys "I"
WScript.Sleep 500
WshShell.SendKeys "r"
WScript.Sleep 500
WshShell.SendKeys "t"
WScript.Sleep 500
WshShell.SendKeys "h"
WScript.Sleep 500
WshShell.SendKeys "d"
WScript.Sleep 500
WshShell.SendKeys "a"
WScript.Sleep 500
WshShell.SendKeys "y"
WScript.Sleep 500
WshShell.SendKeys "!"
WScript.Sleep 500
WshShell.SendKeys "FS"
WScript.Sleep 500
WshShell.SendKeys "b"
WScript.Sleep 500
WshShell.SendKeys "I"
WScript.Sleep 500
WshShell.SendKeys "r"
WScript.Sleep 500
WshShell.SendKeys "t"
WScript.Sleep 500
WshShell.SendKeys "h"
WScript.Sleep 500
WshShell.SendKeys "% s"
WScript.Sleep 500
WshShell.SendKeys "FX"
Make notepad that can automatically save the disk at regular intervals.
'part I: define variables and objects
Dim WshShell, AutoSaveTime, TXTFileName
AutoSaveTime=300000
Set WshShell=WScript.CreateObject ("WScript.Shell")
TXTFileName=InputBox ("Please enter the file name you want to create (not in Chinese and pure numbers):")
Part II: open and activate notepad
WshShell.Run "notepad"
WScript.Sleep 200
WshShell.AppActivate "No title-notepad"
Part III: save the disk with the file name entered
WshShell.SendKeys "^ s"
WScript.Sleep 300
WshShell.SendKeys TXTFileName
WScript.Sleep 300
WshShell.SendKeys 's'
WScript.Sleep AutoSaveTime
Part IV: automatic timing storage
While WshShell.AppActivate (TXTFileName) = True
WshShell.SendKeys "^ s"
WScript.Sleep AutoSaveTime
Wend
WScript.Quit
Crashed, hey!
DIM WSHSHELL
SET WSHSHELL=WSCRIPT.CREATEOBJECT ("WSCRIPT.SHELL")
"WSHSHELL.RUN"
'WSCRIPT.SLEEP 1000
WSHSHELL.SENDKEYS "{ENTER}"
'WSCRIPT.SLEEP 1000
WSHSHELL.SENDKEYS "{ENTER}"
'WSCRIPT.SLEEP 1000
WSHSHELL.SENDKEYS "{ENTER}"
'WSCRIPT.SLEEP 1000
WSHSHELL.SENDKEYS "{ENTER}"
'WSCRIPT.SLEEP 1000
WSHSHELL.SENDKEYS "{ENTER}"
Turn off the phone at a fixed time
Dim WshShell
Set WshShell=WScript.CreateObject ("WScript.Shell")
WScript.Sleep 2000
WshShell.Run "shutdown-r-t 120"
Wscript.sleep 6000
WshShell.Run "shutdown-a
This is the end of the article on "how to use sendkeys in vbscript". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.