Copy Code code as follows:
' ======================================
' VBS SendKeys analog keyboard keystroke
' 2009-07-26
' Liu
' ======================================
Dim WshShell
Set wshshell=wscript.createobject ("Wscript.Shell")
Wshshell.run "cmd"
' Let the script wait 1000 milliseconds, that is, 1 seconds to execute the next statement.
Wscript.Sleep 1000
'--When sending characters, the input method must be in the English file state
' Send a semicolon
Wshshell.sendkeys ";"
Wscript.Sleep 1000
' Send a colon
Wshshell.sendkeys ":"
Wscript.Sleep 1000
' Send double quotes--use CHR to convert double quotes
Wshshell.sendkeys Chr (34)
Wscript.Sleep 1000
' Send a string with double quotes
Wshshell.sendkeys Chr & "This is a string" &CHR (34)
Wscript.Sleep 1000
'--remember, here is the simulated keystroke operation, so you can't send Chinese
' Wshshell.sendkeys Chr & "This is a string" &CHR (34)
Wscript.Sleep 1000
' ================================================
'--how to simulate a carriage return, on-file key, Alt key Nan?
' ================================================
'--how to simulate carriage return,--{Enter} This means send carriage return
Wshshell.sendkeys ' This is a enter! {Enter} '
Wscript.Sleep 1000
'--how to simulate upper-shift shift,--+ this means send shift
Wshshell.sendkeys ' This is +a ' results to this is a
Wscript.Sleep 1000
'--how to simulate alt,--% which means to send Alt
Wshshell.sendkeys ' This is%{tab} ' result is a toggle window
Wscript.Sleep 1000
' ===========================================================
'--then how to send%, + ^ nam
Wshshell.sendkeys ' This is {+}{^}{%} ' result is a toggle window
Wscript.Sleep 1000
'--you may have understood here, when sending special characters, please drop them in {}
' ===========================================================
' ======================================
' For more information see the VBS help document 2009-07-26
' ======================================