vbs模拟Java Robot操做键盘

在Windows环境下,使用vbs也能够实现相似Java的robot操做键盘的功能,并且无需编译。某些特殊状况下,使用vbs会是一个很好的选择。code

如下程序的功能为打开系统的计算器程序,经过键盘输入1+2*3并得出计算结果ip

set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run "calc"
Wscript.Sleep 100
         WshShell.AppActivate "Calculator"
         Wscript.Sleep 100
WshShell.SendKeys "1{+}"
         Wscript.Sleep 500
         WshShell.SendKeys "2"

WshShell.SendKeys "~"
         Wscript.Sleep 500
         WshShell.SendKeys "*3"
Wscript.Sleep 500
WshShell.SendKeys "~"
Wscript.Sleep 2500
相关文章
相关标签/搜索