LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hit any key

In many programs there is a possibility to get a keyboard signal to go
further in the program by:
1. Give a button the focus and give an OR
2. Get input with a message "Hit any key to ."
3. ..

My user will not click on a button but a simple way like above.

Is that possible? If yes how.

Paul
No private reply
0 Kudos
Message 1 of 4
(2,944 Views)
Hi Paul,
you're talking about keyboard faking, but there is an easier method. You can write the value to the button directly.
The attached example .vi (in LV 6.1) has three buttons - one is the obligatory stop, but the other two do the same function. The OK button works directly, bringing up the MessagePopup box. The other button is a cheat - it writes to the other button which is then caught by the program. (I could have used a timer here to do it, but it was easier to demonstrate with a front panel object)
Note - the button you're activating with this method must be set to switch when ... not latch when...

The other way (the fake keypress) requires the use of the property node for the button, and setting KeyFocus for that button. Then you c
all the appropriate third party fake keypress for the "Enter" key (or spacebar).

If you just want a pause, then I'd suggest creating your own popup panel. (I've attached an example that waits until you hit a key)

Hope that helps

S.
// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 2 of 4
(2,944 Views)
> In many programs there is a possibility to get a keyboard signal to go
> further in the program by:
> 1. Give a button the focus and give an OR
> 2. Get input with a message "Hit any key to ."
> 3. ..
>

You have pretty much described it already above. You have two options.

You can popup on any control, such as a button, and go to the advanced
pullright, then to Key Navigation... In this dialog you can put a
specific key, a hot key, that will toggle a button or give focus to a
numeric or string. This is appropriate for the old-fashioned, "Hit F1
to go here or hit F2 to go there." kind of interfaces.

The second option is to use either the events feature of LV6.1 to catch
any key event and respond to it in the diagram, such as progressing to

the next stage of the program, or if you are not using LV6.1, you can
look at downloading the keyboard VIs from the NI site. They have been
around for years but do not ship with the product. They have a VI to
register interest in keys, then you more or less call a GetChar type of
function to return the keys, if any, that the user has entered. If you
want these VIs go to zone.ni.com and search for LabVIEW keyboard.

Greg McKaskle
0 Kudos
Message 3 of 4
(2,944 Views)
Hi.

Thanks for the 'press any key sub, which is really helpful. However, I'm trying something slightly different.
This VI waits until keypressed.

But I have a rather large VI Running, and I want it to keep running until keypressed. So I want this VI to exit anyway, but with a boolean output "key pressed?", so I can attach my while loop to it. If boolean is false, then Rerun the keypress.vi and rerun my main program.
So I want to keep rerunning this "anykey" VI until keypressed.

Any ideas how to do this ?

Thanks,
Michiel.
0 Kudos
Message 4 of 4
(2,944 Views)