Blinking keyboard LED via VBS to get attention

When a script is waiting for input, a standard message box is sometimes too easy to miss. A simple workaround is to combine an on-screen pop-up with a blinking keyboard LED, so the user gets both a visible desktop notification and a hardware-based signal.

In this example, VBScript uses WScript.Shell to toggle the Scroll Lock key and display a timed pop-up. The result is a lightweight notification method that can be useful in administrative scripts, legacy workflows, or interactive tools that pause until the user provides information.

Why this approach works

The script relies on the SendKeys method, which sends keystrokes to the active window as if they had been typed on the keyboard. The Scroll Lock key can be sent as {SCROLLLOCK}, and repeated toggling causes the keyboard LED to switch between on and off states on supported hardware.jsdoc.inflectra+1

At the same time, the script uses the Popup method to display a small dialog box. This method can show a message for a defined number of seconds and returns -1 if the timeout expires before the user clicks a button.

The script

Set WshShell = WScript.CreateObject("WScript.Shell")

Do
    WshShell.SendKeys "{SCROLLLOCK}"
    Result = WshShell.PopUp("Stop blinking", 1, "Mail", 0)
    If Result <> -1 Then Exit Do
Loop

Code walkthrough

The first line creates the WScript.Shell object. This object provides the methods needed for both simulated keystrokes and pop-up windows.

Set WshShell = WScript.CreateObject("WScript.Shell")

The Do ... Loop block keeps the script running until the user interacts with the pop-up. Each loop iteration sends the Scroll Lock key once, which toggles the state of the key and therefore the LED on keyboards that support it.

WshShell.SendKeys "{SCROLLLOCK}"

Next, the script opens a pop-up window for one second. The text is Stop blinking, the title bar shows Mail, and the last parameter controls the button and icon style of the dialog.

Result = WshShell.PopUp("Stop blinking", 1, "Mail", 0)

If the user does not respond within the timeout, Popup returns -1, and the loop continues. If the user clicks a button before the timeout expires, the return value changes to the corresponding button code, and the script exits the loop.

If Result <> -1 Then Exit Do

Practical use cases

This technique is useful when a script must pause and wait for user input, confirmation, or some other manual action. It can also help in situations where a small notification might otherwise go unnoticed, especially on busy desktops or in support and admin scenarios.

Typical examples include:

  • Prompting a user to enter missing information into a script.
  • Asking for confirmation before continuing a task.
  • Highlighting that an interactive step is waiting.
  • Adding a visible reminder in simple internal tools or legacy automation.

Important limitations

SendKeys sends input to the active window, so its behavior depends on which application currently has the focus. That means this method is practical for small, controlled scenarios, but it is less reliable for complex or unattended automation.​

Hardware behavior can also vary. Some keyboards, notebooks, virtual machines, and remote sessions may not expose the Scroll Lock LED in the expected way, so the visual effect is not guaranteed on every system even though the key is still sent.

Professional closing

Using a blinking Scroll Lock LED is a creative way to draw attention to a VBScript prompt without building a larger user interface. It combines a timed pop-up with a hardware signal and works well as a lightweight notification method for small interactive scripts, provided the environment supports Scroll Lock LED feedback.

Schreibe einen Kommentar