我有一个 VBScript 可以取消订阅所有 Steam 创意工坊对象
Code:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "Steam Community :: [GER] Aaron :: Abonnierte Objekte - Opera"
WshShell.AppActivate "Steam Community :: [GER] Aaron :: Abonnierte Objekte - Opera"
WshShell.AppActivate "Steam Community :: [GER] Aaron :: Abonnierte Objekte - Opera"
WshShell.SendKeys "^{2}"
WScript.Sleep 5000
WshShell.SendKeys "jQuery ("[id^='UnsubscribeItemBtn']").children().trigger('click'); setTimeout(function(){location.reload();},500);"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 5000
WshShell.SendKeys "jQuery ("[id^='UnsubscribeItemBtn']").children().trigger('click'); setTimeout(function(){location.reload();},500);"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 5000
WshShell.SendKeys "jQuery ("[id^='UnsubscribeItemBtn']").children().trigger('click'); setTimeout(function(){location.reload();},500);"
WshShell.SendKeys "{ENTER}"
在第 7 行(符号 29)中,它必须发送一个“,但脚本认为它必须在那里结束 SendKey-Command...
我怎样才能防止这种情况发生?
这里的问题有两个方面:
字符串未正确转义为@Scott https://stackoverflow.com/users/736893/scott has 指出(修订版1) https://stackoverflow.com/revisions/41623814/1, but 他们的最新编辑 https://stackoverflow.com/revisions/41623814/2这不是解决这两个问题的方法""
and Chr(34)
是等价的,就我个人而言,我坚持通过加倍引号来转义。
-
第 7 行符号 1 处的过程或参数无效(代码:800a0005)
很可能是由SendKeys()
when AppActivate()
未设置到正确的窗口。
注意运行脚本时 VBSEdit 中发生的情况,SendKeys()
注入脚本导致运行时错误。
检查这一点的方法是从返回一个布尔值AppActivate()
在继续执行脚本之前确保其成功。
Option Explicit
Dim WshShell: Set WshShell = WScript.CreateObject("WScript.Shell")
Dim IsWindowActive: IsWindowActive = WshShell.AppActivate("Steam Community :: [GER] Aaron :: Abonnierte Objekte - Opera")
If IsWindowActive Then
WshShell.SendKeys "^{2}"
WScript.Sleep 5000
WshShell.SendKeys "jQuery (""[id^='UnsubscribeItemBtn']"").children().trigger('click'); setTimeout(function(){location.reload();},500);"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 5000
WshShell.SendKeys "jQuery (""[id^='UnsubscribeItemBtn']"").children().trigger('click'); setTimeout(function(){location.reload();},500);"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 5000
WshShell.SendKeys "jQuery (""[id^='UnsubscribeItemBtn']"").children().trigger('click'); setTimeout(function(){location.reload();},500);"
WshShell.SendKeys "{ENTER}"
Else
WScript.Echo "Activating Window Failed"
End If
Output (因为我没有那个特定的窗口):
Activating Window Failed
为什么AppActivate()
return False
?
至于找出原因AppActivate()
回报False
我建议回顾一下
A: WshShell.AppActivate 似乎不能在简单的 vbs 脚本中工作 https://stackoverflow.com/a/23184667/692942.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)