03-01-2012 12:37 AM
Hi I am trying to use this program in the lab, to capture each pressed key. Could someone help me take a look and the to improve it?
Please just try typing the phrase: Anniversary is Commemoration and Celebration
It is giving me a lot of space between letters
shift and any character is giving me that character twice
Fast typing is omitting some characters...
Thanks for any help.
03-01-2012 02:32 PM
hi agyna,
I think a much better way to implement this will be with an event structure. If you drop an event structure and add an event about <THIS VI> and make it a key down event, you will be able to capture every key press. This will be much better than timing and using the keyboard input VIs that you have now. This example shows the basics of what I am talking about.
http://zone.ni.com/devzone/cda/epd/p/id/3924
Ryan
03-02-2012 09:45 AM
I tried this, it works fine. But the problem is that this works only if I am typing in this front panel. Once I open word and start typing in word or wordpad, it doesn't work. I think it is focused on the front panel only.
Could you help improve this such that I can type my text in a word page and the get the characteres captured?
We will be using another program to enter the text, we cannot use the front panel to enter the text.
Thank you.
03-02-2012 01:23 PM
Hi,
Event structures won't register the key strokes when other programs are in focus. I made a fun little example of how to log key strokes using the keyboard VIs. I did a producer/consumer so that you don't miss keystrokes and I only enqueue when a new key is pressed or released. I think it works pretty well. Take a look at it and play around to see how it works. The next step is to convert the enum array to strings so that you can actually log the keystrokes, but that lookup table was a bit more complicated to make so I will leave that up to you if this is what you want to use. I have attached a version saved in LabVIEW 8.0 for those who can't open it in 2011.
Let me know if that helps!
03-02-2012 01:47 PM
I quickly modified the above code so that it converts the enum to a string and shows the text.
03-03-2012 10:56 AM
Can you please post this as attachment? So I can open it easily. I cannot drag this from the forum page to the block diagram.
Thanks.
03-03-2012 02:46 PM
Also the CPU usage is very high, making the system slow. Any Idea how to reduce it?
03-04-2012 09:35 AM
The CPU usage is very high because the top loop does not have any timing, it is running as fast as it can to make sure it does not miss any keystrokes. You can add a Wait in the top loop to release the processor, even if you wire a constant of 0 to the wait, it will at least release the processor between loops. I am not on the computer that has that program on it, but I would recommend saving the image to your computer and then dragging it to your block diagram. A lot of browsers don't let you drag snippets directly into LabVIEW.
Regards,