LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to bring exe to front

Solved!
Go to solution

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.

0 Kudos
Message 1 of 10
(5,736 Views)

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.

0 Kudos
Message 2 of 10
(5,733 Views)

Sorry, I should have stated I'm using Labview 2009.  Could you please save the VI in a version I can open?

 

Thanks

0 Kudos
Message 3 of 10
(5,731 Views)

Sorry here you go

0 Kudos
Message 4 of 10
(5,729 Views)

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

TailOfGon
Certified LabVIEW Architect 2013
0 Kudos
Message 5 of 10
(5,715 Views)

 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.

 

 

0 Kudos
Message 6 of 10
(5,714 Views)

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.

0 Kudos
Message 7 of 10
(5,711 Views)
Solution
Accepted by topic author pjr1121

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. 🙂

TailOfGon
Certified LabVIEW Architect 2013
0 Kudos
Message 8 of 10
(5,705 Views)

@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?

0 Kudos
Message 9 of 10
(5,700 Views)

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.

Message 10 of 10
(5,676 Views)