07-26-2012 03:03 PM
Hello,
My VI utilizes a couple third party exe files to control a couple pieces of equipment. I'm using SystemExec.vi to open the programs. However, I only want 1 instance of the program open, as opening it again can cause problems.
Looking through other forum posts, I've noticed that I can use tasklist.exe to check if the programs are running. The last piece of the puzzle is to bring the exe program to the front if it's already open.
In short, if the user clicks a button, the program will either open a single instance, or bring that instance to the front. Does anyone know how I can bring an exe program to the front?
Thanks.
Solved! Go to Solution.
07-26-2012 03:17 PM - edited 07-26-2012 03:24 PM
Like This? If so just right click the icon in the top right of the front panel and set VI properties. Then set window appearance. Dont know if this is the right fix though.
07-26-2012 03:19 PM
Sorry, I should have stated I'm using Labview 2009. Could you please save the VI in a version I can open?
Thanks
07-26-2012 03:24 PM
Sorry here you go
07-26-2012 03:56 PM
I found this page. This does not directly help you do what you want, but it is suggesting to use user32.dll to bring your select window to front.
https://decibel.ni.com/content/docs/DOC-15791
07-26-2012 03:59 PM
ok, i'm confused now. All you did was make a VI with a Dialog appearance, which has nothing to do with excecutables. Pherhaps I wasn't clear with my question so here is an example.
Let's say you make a VI that opens the calculator on windows, by wiring "Calc.exe" to the SystemExec.vi. This action is done when you click a button on the front panel. Now, if the button is pressed a second time, I DO NOT want to open a second calculator. Instead, I want to bring the already opened calculator to the front of the desktop. I've figured out how to see if the calculator is currently open, but have no clue how to control what is frontmost on the windows desktop.
Thanks again for the assistance and sorry if my original post was a little confusing.
07-26-2012 04:11 PM
TailofGon,
While this looks interesting, I'm not sure if my program has this ActiveX controls so I will have to look into it. I'll let you know if it works.
07-26-2012 04:49 PM
You do not need to use ActiveX. What you need is Hwnd to pass to the Call Library Function. There should be a way to get Hwnd of your select Window. 🙂
07-26-2012 05:08 PM - edited 07-26-2012 05:11 PM
@pjr1121 wrote:
ok, i'm confused now. All you did was make a VI with a Dialog appearance, which has nothing to do with excecutables. Pherhaps I wasn't clear with my question so here is an example.
Let's say you make a VI that opens the calculator on windows, by wiring "Calc.exe" to the SystemExec.vi. This action is done when you click a button on the front panel. Now, if the button is pressed a second time, I DO NOT want to open a second calculator. Instead, I want to bring the already opened calculator to the front of the desktop. I've figured out how to see if the calculator is currently open, but have no clue how to control what is frontmost on the windows desktop.
Thanks again for the assistance and sorry if my original post was a little confusing.
Thats Okay, I understand what you want to do now. I will look into it.Can you post the portion that the button is dealing with?
07-27-2012 07:17 AM
So figuring out how to get the hWnd of my program was the last piece. Following the example found here http://forums.ni.com/t5/LabVIEW/Is-there-a-way-to-call-an-exe-non-LabVIEW-such-as-Notepad-in-a/m-p/9... I am using the FindWindow function to get the hWnd of my program, then using the Call Library function to bring it to the foreground.
Thanks alot for the help everyone.