华域联盟 vbs VBS sendkeys 模拟击键操作 问题解决

VBS sendkeys 模拟击键操作 问题解决

复制代码 代码如下:

' ======================================

' VBS 中 SendKeys 模拟键盘击键

' 2009-07-26

' 刘林

' ======================================

Dim WshShell

Set WshShell=WScript.CreateObject("WScript.Shell")

WshShell.Run "cmd"

' 让脚本等待1000毫秒,也就是1秒再执行下一条语句

WScript.Sleep 1000

' -- 发送字符时,输入法一定要在英文件状态下

' 发送分号

WshShell.SendKeys ";"

WScript.Sleep 1000

' 发送冒号

WshShell.SendKeys ":"

WScript.Sleep 1000

' 发送双引号 -- 利用chr把双引号转换出来

WshShell.SendKeys Chr(34)

WScript.Sleep 1000

' 发送带有双引号的字符串

WshShell.SendKeys Chr(34)&"this is a string"&Chr(34)

WScript.Sleep 1000

' -- 切记,这里是模拟的击键操作,所以不能发送中文

'WshShell.SendKeys Chr(34)&"这是一个字符串"&Chr(34)

WScript.Sleep 1000

' ================================================

' -- 如何模拟回车,上档键,Alt键喃?

' ================================================

' -- 如何模拟回车, -- {enter}这就代表是发送回车

WshShell.SendKeys "this is a enter!{enter}"

WScript.Sleep 1000

' -- 如何模拟上档键Shift, -- +这就代表是发送shift

WshShell.SendKeys "this is +a" ' 结果为 this is A

WScript.Sleep 1000

' -- 如何模拟Alt, -- %这就代表是发送Alt

WshShell.SendKeys "this is %{TAB}" ' 结果为 切换窗口

WScript.Sleep 1000

' ===========================================================

' -- 那么如何发送%, + ^ 喃

WshShell.SendKeys "this is {+}{^}{%}" ' 结果为 切换窗口

WScript.Sleep 1000

' -- 这里你可能已经明白了,发送送特殊字符时,请放到 {} 中

' ===========================================================

' ======================================

' 更多信息请看VBS帮助文档 2009-07-26

' ======================================


您可能感兴趣的文章:

本文由 华域联盟 原创撰写:华域联盟 » VBS sendkeys 模拟击键操作 问题解决

转载请保留出处和原文链接:https://www.cnhackhy.com/15717.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部