"Object": Represents the WshShell object
"String": Represents the key command string to be sent, which needs to be placed in double quotes in English.
1. Basic key
In general, the key commands to be sent can be represented directly by the key character itself, such as sending the letter "X" and using "Wshshell.sendkeys" X "". Of course, can also send multiple key commands directly, only to the key characters in order, for example, to send the key "Happy", you can use the "Wshshell.sendkeys" Happy "".
2. Special function keys
For keys that need to be combined with the shift, Ctrl, alt three control keys, SendKeys uses special characters to indicate:
How do you represent these keys because the characters "+" and "^" are used to represent special control buttons?
Just enclose these characters in curly braces. For example:
To send a plus "+", you can use the "Wshshell.sendkeys" {+} ""
In addition, for some control functions that do not generate characters, you also need to use the curly braces around the key to the name, such as to send enter, you need to use "Wshshell.sendkeys" {ENTER} "" ", send the downward arrow key with" Wshshell.sendkeys " {down} "" indicates.
Tips: If you need to send multiple, repetitive, single-letter keystrokes, you don't have to type the letter repeatedly, SendKeys allows you to use a simplified format for the description, using the format "{Key number}". For example, to send a 10 letter "x", enter "Wshshell.sendkeys" {x 10} "".
Instance:
----------------------------------------------------
Press F5 to refresh the desktop
Dim Wshshell,path,i
Set WshShell = WScript.CreateObject ("Wscript.Shell")
Wshshell.sendkeys "{F5}"
----------------------------------------------------
automatic restart of the computer
Set WshShell = CreateObject ("Wscript.Shell")
Wshshell.sendkeys "^+{esc}"
----------------------------------------------------
QQ Message Mass
Dim WshShell
Set wshshell= wscript.createobject ("Wscript.Shell")
Wshshell.appactivate "Bomb"
For I=1 to 60
Wscript.Sleep 800
Wshshell.sendkeys "Number0"
Wshshell.sendkeys I
Wshshell.sendkeys '%s '
Next
----------------------------------------------------
Automatic to Baidu Search song: 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, Autosavetime, Txtfilename
autosavetime=300000
Set wshshell=wscript.createobject ("Wscript.Shell")
Txtfilename=inputbox ("Please enter the name of the file you want to create (not in Chinese and plain numbers):"
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.