sendkeys - VBScript Send Key " -
i have vbscript unsubscribe steam workshop-objects
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}" and in line 7 (symbol 29) has send " script thinks has end sendkey-command there...
how can prevent that?
the issue here 2 fold;
the strings not correctly escaped @scott has pointed out (revision 1), their latest edit isn't way fix both
"",chr(34)equivalent , i'd stick escaping doubling quotes.invalid procedure or argument @ line 7 symbol 1 (code: 800a0005)
is caused
sendkeys()whenappactivate()isn't set correct window.notice happens in vbsedit while running script,
sendkeys()injects script causing runtime error.the way check return boolean
appactivate()before continuing script make sure successful.option explicit dim wshshell: set wshshell = wscript.createobject("wscript.shell") dim iswindowactive: iswindowactive = wshshell.appactivate("steam community :: [ger] aaron :: abonnierte objekte - opera") if iswindowactive 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 ifoutput (because don't have particular window):
activating window failedwhy
appactivate()returnfalse?as working out why
appactivate()returnsfalsei'd recommend reviewinga: wshshell.appactivate doesn't seem work in simple vbs script.

Comments
Post a Comment