LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I detect the Enter key was pressed without using the keydown event?

Hi,

I am trying to detect when the Enter key was pressed on the keyboard without using the keydown event, nor using the keyfocus property.  Is there a way to read out the Char, VKey, or ScanCode (as in the event) of the pressed key without resorting to using the event?
Thanks in advance.

-Anh


0 Kudos
Message 1 of 9
(7,784 Views)
You know, I can never figure out why people sometimes want to do things the hard way. Smiley Surprised

OK, I guess if you're on Windows you can use SetWindowsHookEx to create a callback and see if you have a keyboard event. There.

Good luck!
0 Kudos
Message 2 of 9
(7,775 Views)

What exactly are you trying to do? Put this in context and I might be able to help find a solution.

What are the reasons you can't/don't want to use an event structure for this? Could you use a callback instead?

________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 3 of 9
(7,773 Views)
You can use the Acquire Input Data VI to get which keys are pressed.  But this returns what is pressed at the time the VI is called, so you would have to call it in a while loop looking for the enter key.
Message 4 of 9
(7,767 Views)
I am learning Labview (just got my copy last week) and trying to create a Labview hyperterminal.  Here is a stab at modifying the included vi, Advanced Serial Write and Read.vi, to do what I want.  It's kind of working but no cigar.  I'd already tried to use the event in another while loop, but I want to avoid having more than one while loop for this simple exercise.

0 Kudos
Message 5 of 9
(7,754 Views)
LVTerm is an old VI, but you can probably get some tips from it.
0 Kudos
Message 6 of 9
(7,746 Views)
I finally got the hyperterminal simulation program working.  Now, I only need to add in the session logging and sending commands through a text file; then I am done.
Thanks much for all your help.
0 Kudos
Message 7 of 9
(7,698 Views)
AnhT,

You want to send commands through a text file.
If I understand you correctly, you can read from a text file (use the Read from Text File.vi) and parse it and send it accordingly.

Please provide more information if I am not answering your question
Van L
NI Applications Engineer
0 Kudos
Message 8 of 9
(7,677 Views)

I have a similar need but with more restrictions.  I'm making our LabVIEW program cross-platform for Windows and MacOS.  We have a vi which has a small window and whenever the user hits 'Enter' we want the continue button to be toggled and 'Esc' should toggle the stop button.  However we want this to work when the window is not active.  That is, no matter what the active window is, these key bindings should work.  

 

Currently we use the inputDevices.llb but it doesn't work on MacOS (and also it behaves oddly when some special hardware is plugged up on windows giving us double reason to stop using it).  

 

Does anybody know a way to detect a keyboard button press without the window needing to be active and without using OS specific calls?

0 Kudos
Message 9 of 9
(7,074 Views)