Showing results for 
Search instead for 
Did you mean: 

Can LabVIEW control another program /or emulate keys pressed on the keyboard?

Go to solution

Hello All!


I have a ultrasound machine (it's Windows XP based, so treat it as a normal PC), that saves an image everytime I press Ctrl+S. What I try (which i don't know if it's possible) is that for labview to simulate the following step:

 1. Key Press of Ctrl+S to save image 

2. LabVIEW access the folder which the image is saved, and rename the file to image1.img

3. Switch to the ULtrasound program and press Ctrl+S again

4. Labview access the folder and rename the file to image2.img

5.switch back...and on and on and on.


I think renaming the file is very much doable from my memory (haven't used LabVIEW in a long time), but I'm not sure if the Ctrl+S and switching between programs is doable with LabVIEW.


Thank you all very much for your support! Appreciate it! 

0 Kudos
Message 1 of 6
Accepted by topic author northPIG87

You can send keypresses using the Windows API. Search around as this has come up many times. Look for sendkey or similar. As for the renaming, use the Move function in the File I/O. As for activating the window, again, you would need to use the Windows API. You can get a bunch of utilities here.


EDIT: Another method is to use an automation utility like AutoIt. This has an ActiveX interface which can be called from LabVIEW. I've posted examples on using this, so search for it if you're interested. 

Message Edited by smercurio_fc on 06-24-2009 11:25 PM
Message 2 of 6

HI northPIG87,




I can't really relate to your doubt, but i suppose  your purpose will be solved by calling another exe(application) and detecting the keys from keyboard.


You can combine bopth the programs if you want.





"Appreciate  by giving kudos whoever deserves"

Message 3 of 6
Download All
0 Kudos
Message 4 of 6

hi shrekt,


Can you post the vi for lv 8.0 please?

0 Kudos
Message 5 of 6

I'm a tad confused.  don't really see how those VIs are helpful. The "Keystroke Detector" VI is just an event structure monitoring keypresses within LabVIEW itself. That doesn't do anything as far as sending Ctrl-S to another program. The "Run Program" VI just uses System Exec to launch an executable. That also doesn't answer any of the questions posed. And the library itself just contains a bunch of Windows API functions that have 2 "Set" functions (SetFileAttributes and SetVolumeLabel), while all the rest are "Get" functions, and none of them even deal with the keyboard.


Just curious: what are these VIs supposed to show?

Message 6 of 6