本帖最后由 pcl_test 于 2015-4-22 15:22 编辑
- Randomize
- Set ws = CreateObject("Wscript.Shell")
- ws.Run "notepad" '打开记事本
- do while ws.appactivate("无标题 - 记事本")=false '聚焦到当前记事本窗口
- WScript.Sleep 200
- loop
- ws.SendKeys "^ " '模拟Ctrl + Space
- WScript.Sleep 500
- str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
- Num = Int((len(str)-1) * Rnd + 1) '随机获取字符个数
- For i=0 to Num
- a=mid(str,Int(len(str) * Rnd + 1),1) '随机获取某个字符
- ws.sendkeys a
- WScript.Sleep 100 '数值越小打字速度越快
- Next
- ws.SendKeys " " '模拟Space
- WScript.Sleep 100
- save=0 '如想保存则写1
- If save=1 Then
- 'ws.sendkeys "^ "
- '解释上一行:关闭中文输入法。如果是中文,则必须去掉上一行的注释。
- ws.sendkeys "^s"
- WScript.Sleep 1000
- ws.sendkeys "c:\test.txt" '文件名(可写路径),必须是全英文
- WScript.Sleep 1000
- ws.sendkeys "{Enter}"
- End If
- ws.SendKeys "%{F4}" '模拟Alt + F4,关闭当前记事本窗口
- WScript.Sleep 500
- If save=0 Then
- ws.SendKeys "N"
- End If
- WScript.quit
复制代码
|