Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Access to Scroll Lock State

Jason,
This is a follow up question to regarding my interest in keyboard functions,...
I could not find the details in the CVI documentation
regarding EVENT_KEYPRESS in a panel, but I learned that
"eventData1" contains the key char, and eventData2
contains a pointer to both the char and the extended
ascii char! So I am able to get most of what I need.
Still remaining is the question of how to get the scroll-lock state and Numlock/CapsLock etc.
Are these variables that I can get at?
What does *callbackData point to? Is it a pointer to
a struct with keyboard data?

Thanks DraftsmanEE Dude
0 Kudos
Message 1 of 3
(3,015 Views)
Hello

You can use the GetKeyboardState(). Its one of the Win SDK functions. You can install the SDK's by starting up the CVI installer from the control panel (it doesnt install by default). The SDK help lists all the function parameters and the appropriate libraries and headers you would need. I found some sample code on how to use the function on from the MSDN (http://msdn.microsoft.com):


The following sample program turns the NUM LOCK light on if it is off. The SetNumLock function defined here simulates pressing the NUM LOCK key, using keybd_event() with a virtual key of VK_NUMLOCK. It takes a boolean value that indicates whether the light should be turned off (FALSE) or on (TRUE).

The same technique can be used for the CAPS LOCK key (VK_CAPI
TAL) and the SCROLL LOCK key (VK_SCROLL).

/* Compile options needed:
*/

#include

void SetNumLock( BOOL bState )
{
BYTE keyState[256];

GetKeyboardState((LPBYTE)&keyState);
if( (bState && !(keyState[VK_NUMLOCK] & 1)) ||
(!bState && (keyState[VK_NUMLOCK] & 1)) )
{
// Simulate a key press
keybd_event( VK_NUMLOCK,
0x45,
KEYEVENTF_EXTENDEDKEY | 0,
0 );

// Simulate a key release
keybd_event( VK_NUMLOCK,
0x45,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
0);
}
}

void main()
{
SetNumLock( TRUE );
}


Hope this helps
Bilal Durrani
NI
Message 2 of 3
(3,015 Views)
bilalD,
Yes this helps!
Thanks a bunch, sorry for the very late
thanks,... I took off some time for spine surgery!
Cheers!
0 Kudos
Message 3 of 3
(3,015 Views)