LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview Simulate Keyboard Issue

Hi

 

I've been trying to use this keyboard simulation VI I found on these forums and I ran into some problems. I'm really new to LabVIEW and was just trying to test out what the software can do.

 

I was trying to figure out a way to open up a word file and just have the simulator type something the user wrote on a front panel control before the execution. I ran into two programming issues, one is if I type in some string or number into the control, how would I translate this to pressing the correct button on the keyboard if I'm using the keyboard simulator as a sub VI.

 

Second problem I had is in using this VI as a sub VI as I do not know how to, from another VI, press a button and execute on the simulator; right now when I pass in a true boolean constant to one of the keys and then to the execute button nothing happens. I tried a flat sequence but for some reason the program just stops at the one of the frames and never moves on to the next frame. 

 

Lastly, a problem I'm having that's not programming related is that when I use the keyboard simulation VI, I click Alt, then Tab, then Execute. After that the VI ends, but for some reason I lose control of all keyboard function (i.e. I open up firefox and I try to google something and my keyboard doesnt respond). This happend on another computer as well. This problem is solved when I go Alt Tab on my real keyboard but it's a nuisance and I don't know why this is happening

 

I would prefer to use this file in some way and not have to write my own keyboard.

 

Thanks very much

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

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646304(v=vs.85).aspx

 

For your third problem: in the event structure, "L Alt" shows that Left Alt gets a KEYEVENTF_KEYUP flag (value 2 means "key down", or "key pressed"). If you do not click Alt again (to set it false) before Executing, no "KEY UP" event gets sent. It's like holding down the Alt key forever - until you hit alt on your regular keyboard to send "down" and "up" again. Or send "all off".

 

I don't think you can type on this keyboard and have the pressed keys show up in Word or Notepad. If you are typing, the VI front panel is in front and will receive the presses. I can't find the example, but you can invoke Word from a System Exec.vi, then scripted pressed will show up. Somewhere on the forums is also an example of calling "SendInput" function from user32.dll.

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

Hey Red_CCF,

 

While Todd has covered the technical side of the difficulties you're encountering, I wanted to touch on the overall approach you're taking. It seems like you want to take a front panel input and translate it into an input in an MS Word document. Instead of trying to use the event structure, which is meant for if you want to type the individual letters, I would recommend changing it to a case structure and parsing your command string one letter at a time. You could also go straight to the source and access the MS Word document using ActiveX calls. However, the ActiveX approach will be a little more difficult. Hope this helps!

 

--Ryan S.

0 Kudos
Message 3 of 3
(3,733 Views)