手机
当前位置:查字典教程网 >脚本专栏 >vbs >VBS sendkeys 模拟击键操作 问题解决
VBS sendkeys 模拟击键操作 问题解决
摘要:复制代码代码如下:'======================================'VBS中SendKeys模拟键盘击键'20...

复制代码 代码如下:

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

' 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 模拟击键操作 问题解决】相关文章:

VBS教程:函数-CreateObject 函数

VBS读取注册表的两种方法

vbs SendKey 用法 Sendkey 键盘对应的码表

VBS操作Excel常见方法

vbs 注册表操作类代码

VBS中SendKeys的基本应用

VBS教程:VBScript 基础-VBScript 数据类型

VBS 偏移量解密工具[算法解密]

VBS的字符串及日期操作相关函数

vbs字符串操作小考题

精品推荐
分类导航