Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I make a script that waits in a while loop for a specific keyboard combination before doing something? I want to run the script and then have it wait for ALT+CTRL+Q and then execute the rest of the script.

I've searched around but finding VBScript info is kinda hard. The ones I do find seem to be Internet Explorer related.

share|improve this question
is this a standalone script,part of a Office app? If standalone, you may be out of luck but look at the Read method for StdIn – uSlackr Jun 14 '12 at 22:08
@uSlackr Standalone I guess? I'm trying to control some windows operations with a script like opening a program, running some commands in the program then closing the program. – VEC Jun 14 '12 at 22:45
Look into AutoIt or AutoHotKey, you'll be able to find more for detecting keypresses than with VBScript. They also have built ins for automating windows and controls. – MaQleod Jun 15 '12 at 1:09
up vote 0 down vote accepted

This will wait for the ENTER key:

strMessage = "Press the ENTER key to continue."
Wscript.StdOut.Write strMessage

Do While Not WScript.StdIn.AtEndOfLine
   Input = WScript.StdIn.Read(1)
WScript.Echo "The script is complete."

You may be able to check what value Input is getting to see if your desired keypress has a value you can test for

share|improve this answer

You'll need to look into keyboard hooks. You may be somewhat limited in only having VBScript to play with.

Check out:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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