LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to make vi always active or by pressing a key?

When my VI is running I can change tabs by pressing the F2 key.
However this will only work if the VI is active (title bar is blue), if another windows progam is used at that moment, the VI title bar is gray and the VI doen't switch to the next page (tab-contol) when the F2 key is pressed. Only when I leftklick the mouse on the running VI (the tiltle bar gets blue again) I can use my F2 key again.
How can I make the tab-control always listen to the F2 key?
0 Kudos
Message 1 of 18
(3,784 Views)
Hi khs,
one way is to make sure that your vi is always on top and the other is to hook the F2 key in the entire system.

Hope it helps.
Mike
0 Kudos
Message 2 of 18
(3,780 Views)
Mike, thanks for your reaction!
I already made the VI always on top, and it is indeed always on top, but not alway active!
What do you mean by "hook the F2 key in the entire system"?
How can I do that?
khs
0 Kudos
Message 3 of 18
(3,774 Views)
You can use the Input Device Control VIs to monitor the keyboard. An example can be found here.

The "entire system hook" that Mike is referring to is using the Windows API to create a hook. This requires knowledge of the Windows API, and since it's a global hook, it can sometimes cause problem with other applications, especially when you use a single key like F2. See MSDN: About Hooks.
0 Kudos
Message 4 of 18
(3,751 Views)
Hi smercurio,
Thanks for your reaction, I used the input device control VI, which used in the example you showed and it works great!
The solution is even more simple than the event structure I used to trigger key activity!
Thanks again!
 
Kees (Netherlands)
0 Kudos
Message 5 of 18
(3,724 Views)

Unfortunatly it still doesn't work the way I want to. Smiley Sad

I used the Input Device Control VI’s to monitor the keyboard (thanks to smercurio), and this works fine for a normal key-board. But I have a tablet PC with only a few buttons witch I can program to a specific key-fuction. When building an application and running it on my tablet PC the VI doesn’t listen (most of the time) to a press on the button… When I hook up a normal keyboard it works fine again..

When I use the event structure the VI listens to the button every time I press it (the way it should be). The only problem now is still the fact that this will only work if the VI is active (blue title bar). When I use an other windows application the event structure doesn’t work any more (with the input device control VI it did!).

Who does have a solution to this problem?

0 Kudos
Message 6 of 18
(3,694 Views)
Let's see if I uinderstood correctly. 
 
You trigger events based on keyboard activity, such as pressing a PF-key, such as F2. Although this works fine opn a regular keyboard, the Tablet PC does not have these keys available.  Is this correct?  And the target PC where this application will be running is a Tablet PC.
 
Are there any available keys on the Tablet PC that you could use?  Could you create buttons on the VI that you could call F2 and trigger the same evet when either the F2 button is pressed on a regular keyboard or the F2 button is clicked (or Tab-selected + Enter) on the Tablet PC?
 
R
0 Kudos
Message 7 of 18
(3,687 Views)

Hello JoeLabView, thanks for your reaction!

You understood it correctly. The tablet PC doesn’t have a normal keyboard, but there are 3 buttons witch I can program to any standard key function (or combinations). Button nr. 1 I gave the F2 function (but I could be any function). The event structure works fine with this button, but only when the VI is active (and mostly it ins’t active although it always topmost…) If I could find a way to make the VI active, for instance by pressing the same button, I think my problem would be solved.

khs.

0 Kudos
Message 8 of 18
(3,673 Views)

I'm not sure I understand what you mean by " find a way to make the VI active".

Do you mean to activate the vi?  ie make it run

or to make it the active window? ie. already running but in the background or minimized..

R

0 Kudos
Message 9 of 18
(3,664 Views)

When the VI opens it starts running and is active (title bar is blue). When I open an other (windows) application, the VI is not longer active anymore (but stil running and topmost) the title becomes gray. At this point the event structure doesn't work anymore. I have to make the VI active again by pointing it with the mouse (which I don't want to).

0 Kudos
Message 10 of 18
(3,655 Views)