Copy codeThe Code is as follows: '==============================================
'Sendkeys in VBS simulate keyboard keys
'2013-26
'Liu Lin
'==============================================
Dim WshShell
Set WshShell = WScript. CreateObject ("WScript. Shell ")
WshShell. Run "cmd"
'Wait the script for 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 status
'Send a semicolon
WshShell. SendKeys ";"
WScript. Sleep 1000
'Send colons
WshShell. SendKeys ":"
WScript. Sleep 1000
'Send double quotation marks -- 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 key operation, so it cannot send Chinese characters.
'Wshshell. SendKeys Chr (34) & "this is a string" & Chr (34)
WScript. Sleep 1000
'================================================ ==========
'-- How do I simulate the carriage return, the top key, and the Alt key?
'================================================ ==========
'-- How to simulate carriage return, -- {enter} indicates that the carriage return is sent.
WshShell. SendKeys "this is a enter! {Enter }"
WScript. Sleep 1000
'-- How to simulate Shift, -- + indicates sending shift
WshShell. SendKeys "this is + a" 'returns this is
WScript. Sleep 1000
'-- How to simulate Alt, -- % indicates sending Alt
WshShell. SendKeys "this is % {TAB}" 'returns a window for switching.
WScript. Sleep 1000
'================================================ ================================
'-- How to send %, + ^
WshShell. SendKeys "this is {+} {^} {%}" 'results in a switching window
WScript. Sleep 1000
'-- Here you may already understand. Put it in {} when sending special characters
'================================================ ================================
'==============================================
'For more information, see VBS help documentation
'==============================================