当我尝试使用SendKeys发送“(”或“)”字符时,我收到以下错误。在我的vbscript中。
Invalid procedure call or argument
我的剧本:
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 100
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Documents and Settings\Administrator\Desktop\readme.txt", 1)
Wshshell.SendKeys "!@#$%^&*()"
Do Until objFile.AtEndOfStream
strCharacters = objFile.Read(1)
WshShell.SendKeys strCharacters
Loop
当我尝试在循环之前发送它们时它不发送“(”和“)”但是没有显示任何错误并继续直到它遇到另一个“(”字符并且因错误而停止。
答案 0 :(得分:3)
括号被视为特殊字符,需要用括号括起来。有关详细信息,请参阅此link。
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 100
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Documents and Settings\Administrator\Desktop\readme.txt", 1)
Wshshell.SendKeys "!@#$%^&*{(}{)}"
Do Until objFile.AtEndOfStream
strCharacters = objFile.Read(1)
WshShell.SendKeys strCharacters
Loop