batch file - How to write passed variables using sendkeys -
brief explanation: trying use sendkeys type 2 variables/keys output of batch file.
i keep getting syntax or out of subscript errors.
two variables passed batch script, via:
cscript //nologo sendkeys.vbs !config! !arguments! rem yes, both variables defined, , delayed expansion in enabled.
my attempts put them in sendkeys doesn't seem work. i'm not familiar vbs...
vbscript:
set wshshell = wscript.createobject("wscript.shell") wshshell.run "notepad.exe", 9 ' start notepad in order test failure. wscript.sleep 500 ' give notepad time load wshshell.sendkeys & wshshell.arguments(0) ' write passed !config! variable wshshell.sendkeys "{tab}" ' tab key wshshell.sendkeys & wshshell.arguments(1) ' write passed !arguments! variable wshshell.sendkeys "{enter}" ' enter key
the .arguments belong wscript object, not shell. &
concatenation operator, makes no sense between method name , first/only argument. use
set wshshell = wscript.createobject("wscript.shell") wshshell.run "notepad.exe", 9 ' start notepad in order test failure. wscript.sleep 500 ' give notepad time load wshshell.sendkeys wscript.arguments(0) ' write passed !config! variable wshshell.sendkeys "{tab}" ' tab key wshshell.sendkeys wscript.arguments(1) ' write passed !arguments! variable wshshell.sendkeys "{enter}" ' enter key
or - better - think way solve real world problem without sendkeys.
Comments
Post a Comment