LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Keyboard button count

Hi there,

I want to use Labview to achieve a count that can be obtained in the non-focus window when a button on the keyboard is pressed.

When I put Acquire Input Data.vi under timeout, I can achieve the function I want, but the count is not accurate. Pressing the button once will sometimes miss the number of times, sometimes it will increase several times.
When I put Acquire Input Data.vi under Key Down, the count is stable but I can't count in the non-focus window.

Have any way to solve this question?

Download All
0 Kudos
Message 1 of 3
(2,935 Views)

Hi Jason,

 

some general recommendations:

check.png

- Why do you convert the array from KeyboardAcquire to a cluster of 9 elements and only check the first element? Why don't you check ALL array elements? (And why do you have to convert to a cluster???)

- Why do you need a boolean labelled "KB_Q" to update a numeric labelled "KB_Q"? Why are there to frontpanel elements with the very same label? And why do you need an additional event?

 

Those InputDevice functions should be used in a polling mode, which will always lead to inaccuracies. To catch all key events you should use event structures in all your VIs. (You can then use user events to "send" events to other VIs to handle all keystrokes in one background VI…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(2,903 Views)

Hi Gerd,

Thanks for your quick reply, I am currently testing a character first, I need to use a lot of characters on the keyboard.
I want to see the light on when I press the button and confirm that it is correctly summed every time I press it. I am a newcomer to Labview. I saw that your method is really simple and straightforward. But after I tried it, this method still can't count correctly. I have to control the time delay, but everyone's button speed is different, not an insurance method.
Using the event structure can only be used on VIs, but my forcus windows are apps from other vendors (such as video players), I have tried to switch to other apps and it is not possible to count in the background.

Is there a good suggestion to get the way the keyboard is pressed and counted in the background?

 

Best regards,

 

Jason

0 Kudos
Message 3 of 3
(2,887 Views)