This is the mail archive of the cygwin-xfree@cygwin.com mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: numlock




Could this code be added into the XFree build?

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/



_________________________________________________________________
Find a cheaper internet access deal - choose one to suit you. http://www.msn.co.uk/internetaccess



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]