From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Switch until release" control by keyboard..need urgent help...

Hi,
i have a problem of configuring "switch until release" action using keyboard....
or is it there no this function at all...
it seems like all i can do is press to ON and press again to OFF
anyone can help...
need Urgent help....
thank you in advance..
0 Kudos
Message 1 of 13
(3,528 Views)

Select the control -> Properties -> Key Navigation -> Toggle -> Select the key.  It will switch immediatly on the key press.

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 2 of 13
(3,520 Views)
i tried it many times but it doesnt seems to work....the control i want is the same as the mouse click "switch until release" but using keyboard i can ON it but when i release the keyboard key it still ONs and i have to click it again to OFF it...
i need it to switch OFF imeediately after i release the keyboard key...
any other solution?
0 Kudos
Message 3 of 13
(3,516 Views)
The "Switch Until Released" is for the mouse only.  You cannot do that with a keyboard key.  The first key press will turn the boolean on and the next key press will turn it off.  You can't have a switch that will remain on for the duration of the key press, and then off when the key is released.  Well I suppose you could code this function, but it is quite complex.  You would have to call Windows native DLL functions to access the keyboard, and create code to turn the boolean on when the key is pressed.  Then you would have to create a loop that checks the key status continuously, and turn the boolean off when the key is released.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 13
(3,513 Views)
Works fine in 8.20.  My guess is that you are not updating the state of the control.  Do you have 8.20 installed?
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 5 of 13
(3,511 Views)
As in my previous post, "It will switch immediatly on the key press"  thus it will not switch on the release of the key.  It will change immediatly.
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 6 of 13
(3,505 Views)
Maybe I am misunderstanding the question.  I am under the impression that cheeaun wants the boolean to remain on as long as the key is pressed, and that he wants the boolean to go off when the key is released, like a momentary switch.  I have 8.2 and I have tried your vi.  When I hold the key down, the key repeat takes effect and the boolean toggles repeatedly very fast.  This is not the same as the mouse action where the boolean stays on as long as the mouse key is held down, and turns off when the mouse key is let go.  This is called "switch until released".  What you are implementing is "switch when pressed".

Message Edited by tbob on 10-16-2006 10:24 AM

- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 13
(3,504 Views)

tbob,

You are correct that is what they want and correct that it will switch immediatly.  I was restating for cheeaun that it will not work that way using this implementation.  Agree, the mouse will behave different from the keyboard.

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 8 of 13
(3,496 Views)

I'm using LV7.1 unfortunately....

Never thought it would be so complex for such a simple feature...

you see...i have to create a button for my remote control vehicle...it's very difficult to control a, let's say, steering if you have to press it twice...

Any example code on the how to do it, anyone??

 

0 Kudos
Message 9 of 13
(3,495 Views)

Sometimes you have to ask twice but this should do it!  In LV 7.1 for you.  It works on the F5 key or the button on the screen.

Message Edited by mfitzsimons on 10-16-2006 11:54 AM

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
Message 10 of 13
(3,493 Views)