9

How to pause the script until a key is pressed in VBScript? I need something that would pause the flow of the program and wait until 'left_arrow' key is pressed.

1

1 Answer 1

21

You don't have a lot of choices. If you have a console script, and I'm assuming you do, you can read input from the user but it only registers when you press [ENTER]. So you could pause until the enter key is pressed. For example:

WScript.Echo "Press [ENTER] to continue..."

' Read dummy input. This call will not return until [ENTER] is pressed.
WScript.StdIn.ReadLine

WScript.Echo "Done."

There's also the old pause command from DOS days. However, shelling a new console window to run pause would cause a second window to appear. You'd need to press a key in that window to return to your script. Probably not what you want.

But apart from third-parties, VBScript has no methods to read keypresses at run-time.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.