vbscriptsendkeys实例代码大全
作者:雨爱艳6688 | 来源:互联网 | 2022-11-19 13:47
其使用格式为:object.SendKeys string “object”:表示WshShell对象 “
其使用格式为: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}"”表示,发送向下的方向键用“WshShell.SendKeys "{DOWN}"”表示。 Space---------WshShell.SendKeys " " Enter---------WshShell.SendKeys "{ENTER}" ←---------WshShell.SendKeys "{RIGHT}" ↑---------WshShell.SendKeys "{UP}" F1---------WshShell.SendKeys "{F1}" Tips:如果需要发送多个重复的单字母按键,不必重复输入该字母,SendKeys允许使用简化格式进行描述,使用格式为“{按键 数字}”。例如要发送10个字母“x”,则输入“WshShell.SendKeys "{x 10}"”即可。 实例: ---------------------------------------------------- 按下F5刷新桌面 Dim WshShell,Path,i Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.SendKeys "{F5}" ---------------------------------------------------- 电脑的自动重启 set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "^{ESC}u" WshShell.SendKeys "R" ---------------------------------------------------- 启动任务管理器 set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "^+{ESC}" ---------------------------------------------------- QQ消息群发 Dim WshShell Set WshShell= WScript.createObject("WScript.Shell") WshShell.AppActivate "bomb" for i=1 to 60 WScript.Sleep 800 WshShell.SendKeys "Number0" WshShell.SendKeys i WshShell.SendKeys "%s" next ---------------------------------------------------- 自动到百度搜索歌曲:white flag Dim WshShell,Path,i Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run("IEXPLORE.EXE") WScript.Sleep 2000 WshShell.AppActivate "about:blank-Microsoft Internet Explorer" WshShell.SendKeys "+{TAB}" WshShell.SendKeys "http://mp3.baidu.com" WScript.Sleep 800 WshShell.SendKeys "{ENTER}" WScript.Sleep 3000 WshShell.SendKeys "white flag" WScript.Sleep 800 WshShell.SendKeys "{ENTER}" ---------------------------------------------------- 在记事本中输入Happy Birthday!并保存为birth.txt Dim WshShell Set WshShell=WScript.CreateObject("WScript.Shell") WshShell.Run "notepad" WScript.Sleep 1500 WshShell.AppActivate "无标题 - 记事本" WshShell.SendKeys "H" WScript.Sleep 500 WshShell.SendKeys "a" WScript.Sleep 500 WshShell.SendKeys "p" WScript.Sleep 500 WshShell.SendKeys "p" WScript.Sleep 500 WshShell.SendKeys "y" WScript.Sleep 500 WshShell.SendKeys " " WScript.Sleep 500 WshShell.SendKeys "B" WScript.Sleep 500 WshShell.SendKeys "i" WScript.Sleep 500 WshShell.SendKeys "r" WScript.Sleep 500 WshShell.SendKeys "t" WScript.Sleep 500 WshShell.SendKeys "h" WScript.Sleep 500 WshShell.SendKeys "d" WScript.Sleep 500 WshShell.SendKeys "a" WScript.Sleep 500 WshShell.SendKeys "y" WScript.Sleep 500 WshShell.SendKeys "!" WScript.Sleep 500 WshShell.SendKeys "%FS" WScript.Sleep 500 WshShell.SendKeys "b" WScript.Sleep 500 WshShell.SendKeys "i" WScript.Sleep 500 WshShell.SendKeys "r" WScript.Sleep 500 WshShell.SendKeys "t" WScript.Sleep 500 WshShell.SendKeys "h" WScript.Sleep 500 WshShell.SendKeys "%S" WScript.Sleep 500 WshShell.SendKeys "%FX" ---------------------------------------------------- 制作能自动定时存盘的记事本 '第一部分:定义变量和对象 Dim WshShell, AutoSaveTime, TXTFileName AutoSaveTime=300000 Set WshShell=WScript.CreateObject("WScript.Shell") TXTFileName=InputBox("请输入你要创建的文件名(不能用中文和纯数字):") '第二部分:打开并激活记事本 WshShell.Run "notepad" WScript.Sleep 200 WshShell.AppActivate "无标题 - 记事本" '第三部分:用输入的文件名存盘 WshShell.SendKeys "^s" WScript.Sleep 300 WshShell.SendKeys TXTFileName WScript.Sleep 300 WshShell.SendKeys "%s" WScript.Sleep AutoSaveTime '第四部分:自动定时存盘 While WshShell.AppActivate (TXTFileName)=True WshShell.SendKeys "^s" WScript.Sleep AutoSaveTime Wend WScript.Quit ---------------------------------------------------- 死机的,嘿嘿! DIM WSHSHELL SET WSHSHELL=WSCRIPT.CREATEOBJECT("WSCRIPT.SHELL") 'WSHSHELL.RUN " " 'WSCRIPT.SLEEP 1000 WSHSHELL.SENDKEYS "{ENTER}" 'WSCRIPT.SLEEP 1000 WSHSHELL.SENDKEYS "{ENTER}" 'WSCRIPT.SLEEP 1000 WSHSHELL.SENDKEYS "{ENTER}" 'WSCRIPT.SLEEP 1000 WSHSHELL.SENDKEYS "{ENTER}" 'WSCRIPT.SLEEP 1000 WSHSHELL.SENDKEYS "{ENTER}" ---------------------------------------------------- 定时关机的 Dim WshShell Set WshShell=WScript.CreateObject("WScript.Shell") WScript.Sleep 2000 WshShell.Run "shutdown -r -t 120" wscript.sleep 6000 WshShell.Run "shutdown -a
推荐阅读
本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ...
[详细]
蜡笔小新 2023-12-14 15:56:00
Imtryingtofigureoutawaytogeneratetorrentfilesfromabucket,usingtheAWSSDKforGo.我正 ...
[详细]
蜡笔小新 2023-12-12 14:13:01
特需要使用集合的时候,无法找到VBScript中的Collection对象;到处找不到,那就自己写一个吧!注:1.需要VBScript5.0或更高版本,使用Class及 ...
[详细]
蜡笔小新 2023-08-08 14:07:29
Ihaveasimplequestion,butIvesearchedforthisandcouldntfindanyhelpfultopics..我有一个简单的问 ...
[详细]
蜡笔小新 2023-07-17 13:02:50
个人学习使用:谨慎参考1Client类importcom.thoughtworks.gauge.Step;importcom.thoughtworks.gauge.T ...
[详细]
蜡笔小新 2023-12-13 14:20:23
本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ...
[详细]
蜡笔小新 2023-12-13 14:17:11
本文介绍了在iOS开发中使用UITextField实现字符限制的方法,包括利用代理方法和使用BNTextField-Limit库的实现策略。通过这些方法,开发者可以方便地限制UITextField的字符个数和输入规则。 ...
[详细]
蜡笔小新 2023-12-12 09:50:30
本文介绍了绕过WAF的XSS检测机制的方法,包括确定payload结构、测试和混淆。同时提出了一种构建XSS payload的方法,该payload与安全机制使用的正则表达式不匹配。通过清理用户输入、转义输出、使用文档对象模型(DOM)接收器和源、实施适当的跨域资源共享(CORS)策略和其他安全策略,可以有效阻止XSS漏洞。但是,WAF或自定义过滤器仍然被广泛使用来增加安全性。本文的方法可以绕过这种安全机制,构建与正则表达式不匹配的XSS payload。 ...
[详细]
蜡笔小新 2023-12-11 19:42:30
Icreatecodelikethis我创建这样的代码aArray(-fx,-cr,-ie)Setiim1CreateObject(imacros)i ...
[详细]
蜡笔小新 2023-09-04 20:52:36
IamtryingtocallabatchfilefromVBS,butIkeepgettingthisobjectrequirederror:我试图从VBS调 ...
[详细]
蜡笔小新 2023-08-19 18:58:52
关于打印机的问题,在网上找了好久都找不到自动打印的代码!!!现在我把我找到的发布出来共享一下(这个是不会弹出打印提示的,直接打印的;但浏览器但设置一下)页面上写上:<objectidWebB ...
[详细]
蜡笔小新 2023-08-13 14:45:50
这期内容当中小编将会给大家带来有关vbscript中怎么调用Dir命令,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所 ...
[详细]
蜡笔小新 2023-07-23 11:38:18
IsitpossibletocallaVBScriptfunctionfromaJavaScriptcall,oralternatelycallJavaScriptfr ...
[详细]
蜡笔小新 2023-07-17 13:51:40
我现在写了这样的函数:FunctionopenConnection()SetcnnCreateObject(ADODB.Connection)cnn.Connec ...
[详细]
蜡笔小新 2023-07-15 17:54:13
请问有谁能帮忙将满足条件的邮件内容弄成一封就将所有的完成啊?我现在满足条件的一个就发送一封,有所有满足的就会发送很多。请帮帮忙!真心感谢!谢谢!!<%@LANGUAGEVBSCRIP ...
[详细]
蜡笔小新 2023-06-30 16:28:29