LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading the scroll lock key

How could I make LabVIEW read the status of the scroll lock key (on or off)?
0 Kudos
Message 1 of 8
(3,671 Views)
In an event structure select the "Key Down" event (<This VI>). The "VKey" enum will give you special keystrokes like home, end, page up, page down, scroll lock, ...

EDIT: To read the current status without events I think you'll have to use some windows dll...

Message Edited by dan_u on 03-14-2007 03:13 PM

0 Kudos
Message 2 of 8
(3,669 Views)

Dan

Nice tip.  I tried this because I was curious and it works with all other keys but the scroll lock key.  is this key special?

- James

Using LV 2012 on Windows 7 64 bit
0 Kudos
Message 3 of 8
(3,660 Views)
Dan
 
Solved my problem.  Found something interesting. I have a KVM switch on my development machine and with it installed the scroll lock key doesn't show up in the VKey but it does without the KVM.
- James

Using LV 2012 on Windows 7 64 bit
0 Kudos
Message 4 of 8
(3,655 Views)
James,

Did you try using the event structure? For me it works with the scroll lock key. I get "ScanCode" 70 and "VKey" ScrollLock if I hit this key.
Or are you using a windows dll (user32 or similar) to read back the key status?

Daniel

0 Kudos
Message 5 of 8
(3,656 Views)
As mentioned in my previous posts it's also possible to read the key states via system dll calls.
I created a VI that reads the ScrollLock key status in a loop using the user32.dll.
See attached VI (LV 7.1).

Daniel

EDIT: works for other keys as well

Message Edited by dan_u on 03-14-2007 05:18 PM

0 Kudos
Message 6 of 8
(3,647 Views)
Using an event structure will only tell you if you pressed the scroll lock key, it will not tell you the current state of the scroll lock LED on your keyboard. For that you need to call user32.dll. The function is: unsigned char GetKeyState(long nVirtKey). I use this to get the state of the caps lock key, for which I pass this function 20. I'm not sure what the value of scroll lock is.
 
I've attached my caps lock key VI so you can see how to do it.
 
Edit: beaten to the punch.

Message Edited by Marc A on 03-14-2007 11:25 AM

0 Kudos
Message 7 of 8
(3,643 Views)
Thanks guys, that KeyState.vi is exactly what I was looking for.
0 Kudos
Message 8 of 8
(3,628 Views)