can someone help me?

Set wshShell =wscript.CreateObject("WScript.Shell")
do
wscript.sleep 3000
wshshell.sendkeys "{/}"
wshshell.sendkeys "{s}"
wshshell.sendkeys "{e}"
wshshell.sendkeys "{n}"
wshshell.sendkeys "{d}"
wshshell.sendkeys "{ }"
wshshell.sendkeys "{t}"
wshshell.sendkeys "{r}"
wshshell.sendkeys "{a}"
wshshell.sendkeys "{d}"
wshshell.sendkeys "{!}"
wshshell.sendkeys "{e}"
wshshell.sendkeys "{s}"
wshshell.sendkeys "{ }"
wshshell.sendkeys "{i}"
wshshell.sendkeys "{m}"
wshshell.sendkeys "{a}"
wshshell.sendkeys "{f}"
wshshell.sendkeys "{k}"
loop

i want to press F5 to stop the loop and f4 to start it again?
adam hassadAsked:
Who is Participating?
 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
Not feasible (with reasonable effort). Sendkeys is simulating key presses, and using the keyboard interferes with it. The receivimg window has the focus, and so the VBS code will not see any key press.

Only if registering a hotkey in the OS you might be able to bind F4 and F5 to actions globally - but I've never seen VBS code doing that. It probably requires Win32 API calls.

On another note: It is always a bad idea to use Sendkeys. It is very unreliable, and requires to be run in an environment no user interaction is expected.
And you can send multiple keys with one call - much better to read, and (slightly) more reliable.

Lastly, please use reasonable question titles telling something about your issue. That improves the probability to get a reply in a larger scale.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.