How can I set the NumLock status to ON in a C++ program?
Is there any System Call to do it?
Thanks.
Printable View
How can I set the NumLock status to ON in a C++ program?
Is there any System Call to do it?
Thanks.
This could help in VC
http://www.codeguru.com/misc/control...ock_keys.shtml
I also remember doing this using Assembly language in C via some keyboard interrrupt. Don't remember which interrupt is for keyboard.
Cheers
V
In standard C++, there is no function call to get the status of the numlock. You have to rely on what your operating system provides, and each operating system will use different methods.Quote:
Originally posted by sarambur
How can I set the NumLock status to ON in a C++ program?
Is there any System Call to do it?
Thanks.
Regards,
Paul McKenzie
Yeaa.. In C++ there is no function that allows you to set/get the status of NUMLOCK/CAPSLOCK key.
So whatever the OS is , in C++ you can set/get the status of these keys using BIOS calls.
You will have to find a function under Int 9 (Keyboard BIOS interrupt) which allows you to set/get values of these keys.
Cheers
V
finally I have used this piece of code.Code:int ReqdNumLockState = 0x0001;
if( (GetKeyState( VK_NUMLOCK ) & 0x0001) != ReqdNumLockState )
{
//Ponemos el NumLock a ON, para que se pueda escribir con el numpad directamente.
keybd_event( VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0 );
keybd_event( VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
}
I havent tested it yet, and I will post if it works or not in about 5 minutes (for anyone who wants to know, of course).
You also need to post what Windows OS this worked on. This forum is not a Windows-only forum.
Regards,
Paul McKenzie