LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

key down event in background

Is there a way to make the key down event in the wait event structure run in the background when labview is not the focus? Also what is the difference between the "key down? event" and the "key down event"? I couldn't find a good answer in the LabVIEW help.

Message 1 of 5
(4,233 Views)

An event that ends in a question mark means it is a filter event.  If you wire a true to the discard terminal on the right side of the event, you can discard that the keydown ever happened.  That way you can detect a key was pressed, but not have it passed through to the control that might normally capture it.

 

I doubt you could have LabVIEW capture a key down when it is not in focus.  What ever application or window was in focus would be the one to get the key down event.  That is a principle of Windows and has nothing to do with LabVIEW.

Message 2 of 5
(4,214 Views)

@momenslythe wrote:

Also what is the difference between the "key down? event" and the "key down event"? I couldn't find a good answer in the LabVIEW help.


'Key Down' event is notify event and 'Key Down?' is a filter event.

You can discard or modify any filter after it occurs.

For more info, check it here

 

Well it explained a great depth in the LabVIEW help.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 3 of 5
(4,195 Views)

To expand a bit on RF's answer, while you can't use the event structure to register for key down events in other windows, there are some potential options:

 

  1. You could use the input VIs to poll the keyboard (and you can have a loop which will use a user event to send each new key to an event structure). The main problem with this (and it's a big one) is that it is unreliable. You would have to poll quickly enough (probably at ~20-50 Hz) to have a decent chance of being sure that you're not missing keys and even then it's not guaranteed. The other problem is that you don't know which window was actually in focus.
  2. You could try getting the window messages from the other window. I have no real experience with Windows messaging, but my understanding is that this will probably require you to write a custom hook in C to get it, but it's possible that this is also possible with the standard Win32 API functions. Even if it is, this is probably not something you want to get into to, but you could try looking it up.

___________________
Try to take over the world!
0 Kudos
Message 4 of 5
(4,190 Views)

@tst wrote:

To expand a bit on RF's answer, while you can't use the event structure to register for key down events in other windows, there are some potential options:

 

  1. You could use the input VIs to poll the keyboard (and you can have a loop which will use a user event to send each new key to an event structure). The main problem with this (and it's a big one) is that it is unreliable. You would have to poll quickly enough (probably at ~20-50 Hz) to have a decent chance of being sure that you're not missing keys and even then it's not guaranteed. The other problem is that you don't know which window was actually in focus.
  2. You could try getting the window messages from the other window. I have no real experience with Windows messaging, but my understanding is that this will probably require you to write a custom hook in C to get it, but it's possible that this is also possible with the standard Win32 API functions. Even if it is, this is probably not something you want to get into to, but you could try looking it up.

Actually this Windows Messaging already exists in LabVIEW:

 

http://zone.ni.com/devzone/cda/epd/p/id/4394

 

However there is a few issues.  It only partially works in Windows 64-bit, and you have to know the handle to the application that you want to intercept key downs for.  I did a quick test and I was able to detect the KEYDOWN event in another VI that was running for for some reason got an error when I tried to get keydown on notepad.  This method would eliminate polling if you can get it to work, and because of this you shouldn't miss any key presses.

0 Kudos
Message 5 of 5
(4,162 Views)