您现在的位置:首页 >> 软件开发 >> 内容

VBS脚本编写的机器手模拟程序

时间:2020-07-18 06:49:16 点击:

  核心提示:'程序说明:打开WORD,切换成英文输入法,切换成大写状态,输入英文字母,存盘,然后关闭WORD,接着把刚才存盘的文档移到C盘。'下面是源码:Set wshobj=WScript.CreateObje...

'程序说明:打开WORD,切换成英文输入法,切换成大写状态,输入英文字母,存盘,然后关闭WORD,接着把刚才存盘的文档移到C盘。


'下面是源码:


Set wshobj=WScript.CreateObject("WScript.Shell") 
app=wshobj.Run ("winword.exe")  '打开WORD
WScript.Sleep 1000 
wshobj.AppActivate app  '激活当前窗口
WScript.Sleep 1000 
wshobj.SendKeys "^ "  '切换成英文输入法
wshobj.SendKeys "{CAPSLOCK}" '切换成大写
wshobj.SendKeys "ABCDEFG"
WScript.Sleep 1000 
wshobj.SendKeys "{CAPSLOCK}" '切换成小写
WScript.Sleep 1000 
wshobj.SendKeys "^s" '另存为
WScript.Sleep 1000 
wshobj.SendKeys "d:\aaa.doc"  '输入存盘路径
WScript.Sleep 2000 
wshobj.SendKeys "{ENTER}"
WScript.Sleep 1000 


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'winword.exe'")
For Each objProcess in colProcessList
    objProcess.Terminate()
Next



wshobj.Run "C:\WINDOWS\system32\cmd.exe",1,False
WScript.Sleep 1000
wshobj.AppActivate "C:\WINDOWS\system32\cmd.exe"
wshobj.SendKeys "move d:\aaa.doc c:\"
WScript.Sleep 1000 
wshobj.SendKeys "{ENTER}"
WScript.Sleep 1000 
wshobj.SendKeys "EXIT"
WScript.Sleep 1000 
wshobj.SendKeys "{ENTER}"


Wscript.Quit

作者:站长 来源:原创
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
  • 陈工笔记(www.dui580.com) © 2021 版权所有 All Rights Reserved.
  • 站长:陈工 微信号:chengongbiji QQ:24498854
  • Powered by 陈工