LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I set the focus on an external application ?

Solved!
Go to solution

Hi,

 

I'm activating an external .exe application through Labile.

When the application is activated a GUI is opened and I can automatically use this application properties.

The problem is, each time the user presses the screen, outside the GUI window, I lose the focus on this application and can't use its features any more.

 

1) How can I return the focus to this application window and keep on working with it after such a case ?

Otherwise, is it possible to disable the keyboard and/or mouse for a specific time (when the GUI is on) so the user won't accidentally press some buttons ?

 

2) How can I resize an application window to a specific size I choose ?

 

Thanks in advance!

0 Kudos
Message 1 of 7
(1,910 Views)

When you say "How can I return the focus to this application window" to which window are you referring? Earlier you said "When the application is activated a GUI is opened and I can automatically use this application properties" so it seems that when you say "application you're referring to this "external" application. But, it (1) it seems that you're referring to your LabVIEW VI's window. 

 

Also in (2) "How can I resize an application window to a specific size I choose ?", again, which application are you referring to?

0 Kudos
Message 2 of 7
(1,892 Views)

Hi,

 

In both cases I meant for the external application.

To better explain, lets say I activate an EXCEL application (for example), but each time the user presses a button on my LABVIEW GUI or just clicks the screen outside the Excel I lose the focus on the Excel application.

My thought was to set the focus on the external application every time I need to address it and also resize it so it won't disturb my Labview GUI which is running at the same time.

 

0 Kudos
Message 3 of 7
(1,876 Views)
Highlighted

You would need to resort to operating system calls. If you're on Windows you can use the lvwutil32 library which contains many functions on window control. You can find the utilities here. If your version of LabVIEW is 8.5 or greater you will need to get them from here.

 

If you're not on Windows, then you would need to see what API is available for the operating system you're using. 

0 Kudos
Message 4 of 7
(1,863 Views)

Thanks,

 

This helps.

I found the specific vi of the Resize function.

 

Regarding the focus: I still didn't find a specific vi that returns the focus to a selected window. It looks like I can use the Show window vi to return the focus but it only works after the Hide window vi was called before, which is not so convenient...

Do you know any specific vi for the focus function or is this the best solution I can use ?

0 Kudos
Message 5 of 7
(1,841 Views)
Use the "Move Window to Top" VI.
0 Kudos
Message 6 of 7
(1,833 Views)
Solution
Accepted by Mentos

OK, I missed it.

I now have it all.

 

Thanks!

0 Kudos
Message 7 of 7
(1,818 Views)