VBS SendKeys Simulation Keystroke operation Problem Resolution _vbs

Source: Internet
Author: User
Tags chr
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
' ======================================

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.