简单的VBScript无法可靠执行

时间:2018-06-29 15:38:50

标签: vbscript

自从我与VBS合作以来,这一直是一个热门的分钟,但是我从来没有遇到过像这样的简单问题。下面是脚本的当前状态,以浏览文件管理器中的特定文件,打开该文件,并替换其中的一个值(最后一位仍在起作用。)我的问题是脚本执行不一致。有时它仅打开文件资源管理器窗口,然后似乎什么也不做,但有时它可以完美运行。如果没有,我检查任务管理器以查看脚本是否仍在执行,应该执行该脚本,但是该脚本未在进程中显示。有任何想法吗?

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "explorer"
WScript.Sleep 700
WshShell.AppActivate "File Explorer"
WScript.Sleep 500
WshShell.SendKeys("{TAB}")
WScript.Sleep 100
WshShell.SendKeys("{TAB}")
WScript.Sleep 100
WshShell.SendKeys("{TAB}")
WScript.Sleep 100
WshShell.SendKeys("{TAB}")
WScript.Sleep 100
WshShell.SendKeys("{TAB}")
WScript.Sleep 100

WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{RIGHT}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("{DOWN}")
WScript.Sleep 100
WshShell.SendKeys("~")
WScript.Sleep 100
WshShell.SendKeys("{TAB}")
WScript.Sleep 100
WshShell.SendKeys("T")
WScript.Sleep 100
WshShell.SendKeys("E")
WScript.Sleep 100
WshShell.SendKeys("S")
WScript.Sleep 100
WshShell.SendKeys("S")
WScript.Sleep 100
WshShell.SendKeys("~")
WScript.Sleep 100
WshShell.SendKeys("T")
WScript.Sleep 100
WshShell.SendKeys("~")
WScript.Sleep 100
WshShell.SendKeys("^{H}")

0 个答案:

没有答案