WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Problem Detecting Key Toggle

Keywords:   numlock   keytoggleget

Question:

Iconized WIL Interpreter window doesn't seem to detect NUMLOCK state changes.

My WIL batch file looks like this:

;-------------------------------------
While KeyToggleGet(@NUMLOCK) == @OFF
WinTitle(``, `Thinks NUMLOCK OFF`)
Delay(1)
EndWhile
Message(``, `Detected NUMLOCK ON`)
;-------------------------------------
Steps to Repeat Problem:
  1. From the keyboard, set NUMLOCK off.
  2. Execute the WIL batch file. The WIL Interpreter becomes iconized. WIL Interpreter title becomes "Thinks NUMLOCK OFF".
  3. From the keyboard, set NUMLOCK on. Unexpectedly, the state change is not detected and nothing happens.
Additional Notes:

As soon as the WIL Interpreter goes from an ICON to a NORMAL window, the NUMLOCK state change is detected.

Is there a work-around, possibly involving a Windows API call?

Answer:

WinBatch can only "see" the numlock change if Windows tells it. Windows will only inform WinBatch that it has changed if WinBatch is either the active window or may soon become it (as in moving the mouse over the window).

In 32 bit Windows, each application can have its own view of the status of the toggles, so you can only really see and set your own view. Consequently, WinBatch cannot necessarily detect the Key Toggle for a specific application, or read that view for the KeyToggleSet.

On DOS based systems, like 16-bit Windows, this function will return the keys state for ALL applications.


Article ID:   W13094
Filename:   KeyToggleGet and Problem Detecting Key Toggle.txt
File Created: 1999:04:15:16:51:42
Last Updated: 1999:04:15:16:51:42