LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Maximizing/switching to other running applications + sending keys to them via LV

Hello everyone,
 
I want to change some settings in another running application via Labview. It does not support Active X or anything, basically i want to change some system parameters and I think the best way to do this will be to use Send Keys method and use Labview to simulate the keyboard and send keys to enter the parameters. The problem is; once labview VI, that does all this, is running, i want to maximize/switch to the other application (for which i need to change parameters) before simulating the keyboard, so only that application gets the keys i send from labview. I know I can also do this by sending Alt+tab... but that is, as you know, very inefficient if other applications besides the one I am concerned with, are open. I did some research and found that i can use FindWindow method in the user32.dll library to get a handle to the concerned application, given its caption string. I tried using it but it is not working for me, If possible can anyone give me an example of doing this? ....i will be starting the concerned application via Exec Command method (cmd prompt) within labview, it also does not support macros.
 
Also, is there a way to simulate Arrow Keys with the send keys method?, if so then what are the hex values for that...
 
Please help as soon as you can,
 
Thank you all,
 
- Muttee
0 Kudos
Message 1 of 11
(6,078 Views)
Muttee,
 
Send Key method is not a reliable method.  It send the key to the active window, no matter which window is active.
If user switch the window or an error message popup, send key method will fail.
 
If the application you try to control is not a LabVIEW application, there might be a better way.
If it is a LabVIEW application, you probably stuck with send key method unless you got the source code.
 
If you have to use send key method, there are a few VIs on my website can do this.
 
Instead of using "Exec Command method",  use my External Application library to launch the other application.
It will be ready (active) for send key method.
Or use SetActiveWindow.vi to make the other application ready for send key method.
 
George Zou
 
George Zou
0 Kudos
Message 2 of 11
(6,065 Views)

thanks zou, It is a non-labview application, basically the software for our photon counter system. I have tried many methods other than the SendKeys method but that application does not support them, How can I try to open the application via External library?....It does not come with a DLL, OCX or any active-x supported libraries...

Thanks again

0 Kudos
Message 3 of 11
(6,062 Views)
A robust method should send key stroke or click to a specific window, not any window which happen to be active.
 
To do that, you have to analyz the application window, figure out which child window (button, string, etc) you want
the send key stroke to.
 
How many keys do you want to send?
 
 
George Zou
 

Message Edited by zou on 08-31-2007 12:11 PM

George Zou
0 Kudos
Message 4 of 11
(6,053 Views)
I need to send a series of keys to change ~4-5 parameters in its settings, i can do that with keyboard using ~40 keys (most of them are TABs)....
0 Kudos
Message 5 of 11
(6,048 Views)
Also, I have Labview 8.0 so the Active Window vi on your website is not working on my system...
0 Kudos
Message 6 of 11
(6,032 Views)
Also, I have Labview 8.0 so the Active Window vi on your website is not working on my system...
0 Kudos
Message 7 of 11
(6,033 Views)

Muttee wrote:
Also, I have Labview 8.0 so the Active Window vi on your website is not working on my system...

It's availalbe in LV8.0 & 8.2 now. But I hope you don't need it.

Instead,try the Analyze Window library. It can enumerate all window objects on your window, and list in a tree control.

You can select the object you want to send text to, and send a test string to it, or send a click to a button. You don't need to bring your application window to the front or acitivate it. Send String.vi and Send Click.vi send only to the object you specify, not any window happen to be active.

Another top level vi in the library demonstrates how to send string and click to the standard Window's Open File Dialog window.

Message Edited by zou on 09-06-2007 07:04 PM

George Zou
Download All
Message 8 of 11
(5,997 Views)

wow thanks Zou,

Yes, i actually do not need it anymore, I am finished with a project and it was a success. This looks like a useful VI though, but does the user have to select the window to send keys every time or can I specify once the name of the applications to send keys to?...

Anyways thanks a lot once again,

- Muttee

0 Kudos
Message 9 of 11
(5,978 Views)
The Analyze Window VI only for collect information, such as the class name, and the parent / child relation.  These information doesn't change.  Object handles will change everytime.
 
The other top level vi is what you normally use.
 
George Zou
 
George Zou
0 Kudos
Message 10 of 11
(5,963 Views)