ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I use labview to control other programs

Is there a way to use LabView:
  1. to launch another application,
  2. leave it running in the background,
  3. continue to execute LabView code,
  4. send commands to the application launched in step 1
  5. repeat steps 3 and 4, 3 times and then close the application and finish executing code.
I know the answer to this is yes because I am currently doing this using active X but my problem is that in order for this to work I have to follow the following steps:
  1. use active X cotrol to launch batch file that executes first script with the application,
  2. execute LabView tests,
  3. using active X, send next command,
  4. repeat steps 2 and 3, close and finish.
The problem is that in order for active X to work the application that I want to send commands to has to be the active window and the commands are sent by emmulating keyboard presses.  This would have been an acceptable method if I could disable the keyboard and mouse, but I cannot send commands from LabView to the application with the keyboard disabled. Therefore this is not a good solution for me because this software is used on the manufacturing floor and operators may be doing other things on the station and may interfere with the data transfer by either typing keys that change the command or they may change the window focus to another application.

The application I'm controlling is a standard in, standard out dos executable created by another third party customer.

Is there a more direct method of sending string data from LabView to this type of application without having to depend on window focus and keyboard emmulation?

Thanks for any and all help.
Mitch
0 Kudos
Message 1 of 9
(7,838 Views)
Hey Mitch,

Let me see if I understand your application -- you have an executable that runs and requires user input including mouse clicks and keyboard characters via a GUI, and you are currently trying to automate this program by programmatically giving focus to the window and simulating keyboard strokes?

Does this program also have a command line interface that allows you to control it via the command line?

You can use System Exec.vi to launch an executable or batch file, but you only have the option of waiting for it to complete or running it in the background, however you can specify command line arguments.

When you say you want to disable the keyboard, do you simply mean unplugging the keyboard or actually disabling the driver, and if the latter, what method are you using to disable the driver?  I am not familiar with whether disabling the keyboard driver prevents you from programmatically registering keyboard commands
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 2 of 9
(7,794 Views)
Hi Doug,

The LabView software does the following:

  1. Using activeX, launch 3rd party application (virtual dos, launched using a batch file),
  2. Using activeX, make 3rd party application active (window focus),
  3. Using activeX, send commands to 3rd party application,
  4. Process log file created by 3rd party application,
  5. LabView software executes some test algorithms,
  6. repeat steps 2 - 5 until all test requirements are met,
  7. close 3rd party application and display results.
There is no input received from the operator.  Here's the problem: in order for activeX to work the 3rd party application that I want to send commands to has to be the active window and the commands are sent by emmulating keyboard presses.  The reasoning behind disabling the keyboard is to minimize operator interference.  The method I'm using to disable the keyboard (which also disables the mouse) is by calling the user32.dll and using the function BlockInput.

I've thought about using the System Exec.vi but can I:
  1. launch an application,
  2. send some commands,
  3. have other LabView functions execute
  4. send more commands to the application launched in step 1,
  5. repeat steps 3 and 4
I know I can do steps 1 - 3 but I'm not sure how to do step 4 (if I can).

Thanks for your help.
Mitch

0 Kudos
Message 3 of 9
(7,765 Views)
I'm not sure I have an answer but it sure doesn't sound like you are really using ActiveX right now. Typically, an ActiveX application is controlledwith properties and methods and started with the Automation Open and not a batch file. And controlling real ActiveX applications like word or excel do not need to emulate keyboard presses and they never need to be the active window. If it is ActiveX that you are using, is it properties and methods of the actual application or something else like maybe the Windows API? What is the name of the third-party application? Maybe someone here has experience with it.
0 Kudos
Message 4 of 9
(7,760 Views)
Your right, the ActiveX control I'm using is IWshRuntimeLibrary.IWshShell2, Library Type: IAS Helper COM Component 1.0 TypeLebraty Version 1.0 and Object: IasHelper (IAS>IasHelper.1).  I use the Automation Open and then I launch the 3rd party application using a method.  I'm using methods of this application to send commands to the 3rd party application as well.  Unfortunately the 3rd party application is a custom application developed by my customer.

Attached is a small vi that launches dos using this ActiveX application.

I guess the real question I have now is, can I use System Exec.vi to send commands to an application that is already running in the background?

Mitch
0 Kudos
Message 5 of 9
(7,750 Views)
Mitch,

System Exec cannot be used with an open command window or process that I'm aware of.  It sounds like you are looking for functionality similar to pipes in Linux, but I don't know that there is an easy way to achieve something similar with Windows.
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 6 of 9
(7,700 Views)
hey mitch and doug,

I am trying to do the same thing...access matlab command line through labview.  I know a lot of people would suggest to use MathScript or something, but it will not work in my application.  also, with using activex, it seems like mathworks screwed up the registry for matlab..is there a solution for this?

thanks,

erique
0 Kudos
Message 7 of 9
(7,609 Views)
erique,

Could you give additional information on what you are trying to do, and what version of Matlab and LabVIEW you are using?  Is the MATLAB Script Node not working for you?
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 8 of 9
(7,580 Views)
hey Doug,

I found a way to make it work already.  I cannot use the script node because there's a third party software that we use in conjunction with matlab.  I just used activex to execute commands in matlab, and also to get and pass variables. 

Thanks,

Erique
0 Kudos
Message 9 of 9
(7,535 Views)