VBS Senkey

什么是VBscrīpt呢? VBscrīpt的全称是:Microsoft Visual Basic scrīpt Editon.(微软公司可视化BASIC脚本版). VBS(VBscrīpt的进一步简写)是基于Visual Basic的脚本语言,其不编译成二进制文件, 而是直接由宿主(host)解释源代码并执行, 简单点说就是你写的程序不需要编译成.exe, 而是直接给用户发送.vbs的源程序, 用户就能执行了. SendKeys 方法 模拟键盘操作,将一个或多个按键指令发送到指定Windows窗口来控制应用程序运行, 其使用格式为:object.SendKeys(string) “object”:表示WshShell对象 “string”:表示要发送的按键指令字符串,需要放在英文双引号中。 ----------------------------------- 1.基本键   一般来说,要发送的按键指令都可以直接用该按键字符本身来表示,例如要发送字母“x”,使用“WshShell.SendKeys "x"”即可。当然,也可直接发送多个按键指令,只需要将按键字符按顺序排列在一起即可,例如,要发送按键“happy”,可以使用“  WshShell.SendKeys "happy" ”。 2.特殊功能键   对于需要与Shift、Ctrl、Alt三个控制键组合的按键,SendKeys使用特殊字符来表示:   Shift---------WshShell.SendKeys "+"   Ctrl---------WshShell.SendKeys "^"   Alt---------WshShell.SendKeys "%" (注意 这样使用时,不用大括号括起这些特殊字符。)   由于“+”、“^”这些字符用来表示特殊的控制按键了,如何表示这些按键呢? 只要用大括号括住这些字符即可。例如: 要发送加号“+”,可使用“WshShell.SendKeys "{+}"” 另外对于一些不会生成字符的控制功能按键,也同样需要使用大括号括起来按键的名称。 例如要发送回车键,需要用“ WshShell.SendKeys "{ENTER}" ”表示; 发送向下的方向键用“ Wshell.SendKeys "{DOWN}" ”表示。 Space---------WshShell.SendKeys " " Enter---------WshShell.SendKeys "{ENTER}" ←---------WshShell.SendKeys "{RIGHT}" ↑---------WshShell.SendKeys "{UP}" F1---------WshShell.SendKeys "{F1}" 按键 代码 BACKSPACE {BACKSPACE}, {BS}, 或 {BKSP} BREAK {BREAK} CAPS LOCK {CAPSLOCK} DEL or Delete {Delete} 或 {DEL} DOWN ARROW {DOWN} END {END} ENTER {ENTER}或 ~ ESC {ESC} HELP {HELP} HOME {HOME} INS or Insert {Insert} 或 {INS} LEFT ARROW {LEFT} NUM LOCK {NUMLOCK} PAGE DOWN {PGDN} PAGE UP {PGUP} PRINT SCREEN {PRTSC} RIGHT ARROW {RIGHT} SCROLL LOCK {SCROLLLOCK} TAB {TAB} UP ARROW {UP} F1 {F1} F2 {F2} F3 {F3} F4 {F4} F5 {F5} F6 {F6} F7 {F7} F8 {F8} F9 {F9} F10 {F10} Tips:如果需要发送多个重复的单字母按键,不必重复输入该字母,SendKeys允许使用简化格式进行描述,使用格式为“{按键 数字}”。例如要发送10个字母“x”,则输入“WshShell.SendKeys "{x 10}"”即可。 ----------------------------------- 按下F5刷新桌面 Dim WshShell,Path,i Set WshShell = Wscrīpt.CreateObject("Wscrīpt.Shell") WshShell.SendKeys "{F5}" ---------------------------------------------------- 电脑的自动重启 set WshShell = CreateObject("Wscrīpt.Shell") WshShell.SendKeys "^{ESC}u" WshShell.SendKeys "R" ---------------------------------------------------- 启动任务管理器 set WshShell = CreateObject("Wscrīpt.Shell") WshShell.SendKeys "^+{ESC}" ---------------------------------------------------- QQ消息连发 Dim WshShell Set WshShell= Wscrīpt.createObject("Wscrīpt.Shell") WshShell.AppActivate "bomb" for i=1 to 60 Wscrīpt.Sleep 800 WshShell.SendKeys "What do you say" WshShell.SendKeys i WshShell.SendKeys "%s" next ---------------------------------------------------- 自动到百度搜索歌曲:white flag Dim WshShell,Path,i Set WshShell = Wscrīpt.CreateObject("Wscrīpt.Shell") WshShell.Run("IEXPLORE.EXE") Wscrīpt.Sleep 2000 WshShell.AppActivate "about:blank-Microsoft Internet Explorer" WshShell.SendKeys "+{TAB}" WshShell.SendKeys "http://mp3.baidu.com" Wscrīpt.Sleep 800 WshShell.SendKeys "{ENTER}" Wscrīpt.Sleep 3000 WshShell.SendKeys "white flag" Wscrīpt.Sleep 800 WshShell.SendKeys "{ENTER}" ---------------------------------------------------- 自动关机 Dim WshShell Set WshShell=Wscrīpt.CreateObject("Wscrīpt.Shell") Wscrīpt.Sleep 2000 WshShell.Run "shutdown -r -t 120" wscrīpt.sleep 6000 WshShell.Run "shutdown -a" ---------------------------------------------------- 在记事本中输入Happy Birthday!并保存为birth.txt Dim WshShell Set WshShell=Wscrīpt.CreateObject("Wscrīpt.Shell") WshShell.Run "notepad" Wscrīpt.Sleep 1500 WshShell.AppActivate "无标题 - 记事本" WshShell.SendKeys "H" Wscrīpt.Sleep 500 WshShell.SendKeys "a" Wscrīpt.Sleep 500 WshShell.SendKeys "p" Wscrīpt.Sleep 500 WshShell.SendKeys "p" Wscrīpt.Sleep 500 WshShell.SendKeys "y" Wscrīpt.Sleep 500 WshShell.SendKeys " " Wscrīpt.Sleep 500 WshShell.SendKeys "B" Wscrīpt.Sleep 500 WshShell.SendKeys "i" Wscrīpt.Sleep 500 WshShell.SendKeys "r" Wscrīpt.Sleep 500 WshShell.SendKeys "t" Wscrīpt.Sleep 500 WshShell.SendKeys "h" Wscrīpt.Sleep 500 WshShell.SendKeys "d" Wscrīpt.Sleep 500 WshShell.SendKeys "a" Wscrīpt.Sleep 500 WshShell.SendKeys "y" Wscrīpt.Sleep 500 WshShell.SendKeys "!" Wscrīpt.Sleep 500 WshShell.SendKeys "%FS" Wscrīpt.Sleep 500 WshShell.SendKeys "b" Wscrīpt.Sleep 500 WshShell.SendKeys "i" Wscrīpt.Sleep 500 WshShell.SendKeys "r" Wscrīpt.Sleep 500 WshShell.SendKeys "t" Wscrīpt.Sleep 500 WshShell.SendKeys "h" Wscrīpt.Sleep 500 WshShell.SendKeys "%S" Wscrīpt.Sleep 500 WshShell.SendKeys "%FX" ---------------------------------------------------- 制作能自动定时存盘的记事本 '第一部分:定义变量和对象 Dim WshShell, AutoSaveTime, TXTFileName AutoSaveTime=300000 Set WshShell=Wscrīpt.CreateObject("Wscrīpt.Shell") TXTFileName=InputBox("请输入你要创建的文件名(不能用中文和纯数字):") '第二部分:打开并激活记事本 WshShell.Run "notepad" Wscrīpt.Sleep 200 WshShell.AppActivate "无标题 - 记事本" '第三部分:用输入的文件名存盘 WshShell.SendKeys "^s" Wscrīpt.Sleep 300 WshShell.SendKeys TXTFileName Wscrīpt.Sleep 300 WshShell.SendKeys "%s" Wscrīpt.Sleep AutoSaveTime '第四部分:自动定时存盘 While WshShell.AppActivate (TXTFileName)=True WshShell.SendKeys "^s" Wscrīpt.Sleep AutoSaveTime Wend Wscrīpt.Quit ---------------------------------------------------- 自动死机o(∩_∩)o... DIM WSHSHELL SET WSHSHELL=Wscrīpt.CreateOBJECT("Wscrīpt.SHELL") 'WSHSHELL.RUN " " 'Wscrīpt.SLEEP 1000 WSHSHELL.SENDKEYS "{ENTER}" 'Wscrīpt.SLEEP 1000 WSHSHELL.SENDKEYS "{ENTER}" 'Wscrīpt.SLEEP 1000 WSHSHELL.SENDKEYS "{ENTER}" 'Wscrīpt.SLEEP 1000 WSHSHELL.SENDKEYS "{ENTER}" 'Wscrīpt.SLEEP 1000 WSHSHELL.SENDKEYS "{ENTER}" 再来执行脚本,QTP执行成功.这就是描述性编程.当然值得注意的是,如果父对象用描述性编程表示了,那么后面的对象都要用描述性编程表示了.如: Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "mercury" 这边Dialog("text:=Login")用描述性编程表示了,那么WinEdit("attached text:=Agent Name:")就必须要描述性编程表示了.因为在对象库中,子对象是依靠父对象存在的.所以如果Dialog("text:=Login")这个父对象从对象库中删除了,那么后面的子对象也同时被删除了.反过来子对象删除就不影响父对象.所以子对象可以单独用描述性编程表示,而不需牵连其他对象. 此文来源于51testing博客,转载请注明出处为51testing博客 原始链接:http://blog.51testing.com/?26649/action_viewspace_itemid_2625.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android是一种基于Linux内核(不包含GNU组件)的自由及开放源代码的移动操作系统,主要应用于移动设备,如智能手机和平板电脑。该系统最初由安迪·鲁宾开发,后被Google公司收购并注资,随后与多家硬件制造商、软件开发商及电信营运商共同研发改良。 Android操作系统的特点包括: 开放源代码:Android系统采用开放源代码模式,允许开发者自由访问、修改和定制操作系统,这促进了技术的创新和发展,使得Android系统具有高度的灵活性和可定制性。 多任务处理:Android允许用户同时运行多个应用程序,并且可以轻松地在不同应用程序之间切换,提高了效率和便利性。 丰富的应用生态系统:Android系统拥有庞大的应用程序生态系统,用户可以从Google Play商店或其他第三方应用市场下载和安装各种各样的应用程序,满足各种需求。 可定制性:Android操作系统可以根据用户的个人喜好进行定制,用户可以更改主题、小部件和图标等,以使其界面更符合个人风格和偏好。 多种设备支持:Android操作系统可以运行在多种不同类型的设备上,包括手机、平板电脑、智能电视、汽车导航系统等。 此外,Android系统还有一些常见的问题,如应用崩溃、电池耗电过快、Wi-Fi连接问题、存储空间不足、更新问题等。针对这些问题,用户可以尝试一些基本的解决方法,如清除应用缓存和数据、降低屏幕亮度、关闭没有使用的连接和传感器、限制后台运行的应用、删除不需要的文件和应用等。 随着Android系统的不断发展,其功能和性能也在不断提升。例如,最新的Android版本引入了更多的安全性和隐私保护功能,以及更流畅的用户界面和更强大的性能。此外,Android系统也在不断探索新的应用场景,如智能家居、虚拟现实、人工智能等领域。 总之,Android系统是一种功能强大、灵活可定制、拥有丰富应用生态系统的移动操作系统,在全球范围内拥有广泛的用户基础。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值