numlock

J S vervoom@hotmail.com
Tue Apr 20 13:07:00 GMT 2004


Thomas,

Thank-you very very much!!! This is an excellent solution and works like a 
treat!! Thanks so much.

JS.

>OK.  You asked for it.  Below is a short C program which will check the 
>state of the NumLock key and synthesize a keydown/keyup sequence of the 
>NumLock key if it's down.  Works on my box, which is Win2K, but I'm led to 
>believe from the documentation that it should work with any 32-bit 
>implementation of windows.
>
>To build it, copy-paste the following source into a file (e.g. 
>"numlockoff.c") then run gcc on it (e.g. "gcc -o numlockoff numlockoff.c"). 
>  Then add that to a convenient location on your client systems and add a 
>call to it in your X startup script.
>
>#include <stdio.h>
>#define _WIN32_WINNT 0x0500
>#include <windows.h>
>
>int main()
>{
>    INPUT pInput[2];
>
>    if (GetKeyState(VK_NUMLOCK) == 1)
>    {
>        pInput[0].type           = INPUT_KEYBOARD;
>        pInput[0].ki.wVk         = VK_NUMLOCK;
>        pInput[0].ki.wScan       = 0;
>        pInput[0].ki.dwFlags     = 0; /* Nill for keydown */
>        pInput[0].ki.time        = 0;
>        pInput[0].ki.dwExtraInfo = 0;
>
>        pInput[1].type           = INPUT_KEYBOARD;
>        pInput[1].ki.wVk         = VK_NUMLOCK;
>        pInput[1].ki.wScan       = 0;
>        pInput[1].ki.dwFlags     = KEYEVENTF_KEYUP;
>        pInput[1].ki.time        = 0;
>        pInput[1].ki.dwExtraInfo = 0;
>
>        if (SendInput(2, pInput, sizeof(INPUT)) == 0)
>        {
>            fprintf(stderr, "Error: SendInput failed.  NumLock was not 
>turned off.\n");
>        }
>    }
>}
>
>_________________________________________________________________
>FREE pop-up blocking with the new MSN Toolbar – get it now! 
>http://toolbar.msn.com/go/onm00200415ave/direct/01/
>

_________________________________________________________________
Use MSN Messenger to send music and pics to your friends 
http://www.msn.co.uk/messenger



More information about the Cygwin-xfree mailing list