12-05-2011 12:54 AM
Hi,
in attached file, I am trying to get up to 10 characters from the key board. Meaning that each time a key is pressed, I get it, up to a max of 10; and start again.
Now the issue I am facing is that it is working ony when, after starting my vi (RUN), I click the mouse on the running Front Panel.
Once the mouse is clicked some where else, or I am typing somewhere else, it is not recording the key.
what I want is to open a wordpad page, type some special characters, and so, while typing in my wordpad, my running vi, should be recording those keys.
Any help?
12-05-2011 01:38 AM
Without looking at the code, I'm guessing you're using the Key Down event to get the click. This only works when you have focus, as you saw.
What you can do is use the keyboard VIs (search the palettes), which work without focus as well. Just be aware that you will need to recognize all the changes yourself (you can use a shift register to hold the old value of which buttons which pressed), because the VI just returns which keys are currently pressed.
12-05-2011 03:51 PM
Hi,
I would look into using the Initialize Keybaord.vi, Aquire Input Data.vi, and Close Input Device.vi. These should allow you to monitor the keyboard as you are trying to. You could possibly do this with an event structure but I would use a producer/consumer loop. There are examples of using the keyboard vi's and producer/consumer loops in LabVIEW. Just use the search feature in the labVIEW example finder. If you are unable to locate a good example just let me know.
Regards,
Greg H.
12-10-2011 03:01 PM
So I tried this, but I do I get the pressed key to a file so that I can read what was pressed. It is just disappearing...
Thanks for any help.
12-10-2011 07:45 PM
Wire the output to a shift register and compare it with the previous value. If it is not equal, build it in to an array or convert it in to string depending on what you want to do with it.
12-12-2011 02:00 AM
Not really sure that I understand what you mean. could explain a bit more?
12-12-2011 02:09 AM
The real problem is that the character appear only when the key is pressed. When I release the key, the character disapears immediately, so I cannot record it... or send to a file...
12-12-2011 08:07 AM
Try this.
I am not proud of the code but it does the job. Also using a build array inside a loop is not very efficeint. You need to initialise the array outside the loop and replace the subset. You can do that....
12-12-2011 08:16 AM
It should be pointed out that the code can be simplified (and that you don't need the for loop anyway):
Note that this example uses a trick of the AND array elements primitive, where it returns T for an empty array.
12-12-2011 08:25 AM
Hi,
While this method of using a build array will work, I would suggest using a producer/consumer loop as well. Examples of this can be found in the LabVIEW example finder. Using this setup will make sure that no keystrokes are missed.
Regards,
Greg H.