LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to show c++ executable window in a fixed place on front panel

Hi, I am calling some .exe code from LabView with System Exec.vi,  I want to control the popup windows from those .exe(s) to a certain location on my front panel.  Is this possible?
 
Bryan
Message 1 of 12
(3,206 Views)
Bryan,
You're going to have to use the Windows API calls to obtain a reference to the window that your program opens and then also use the Win API to set the position of this window. This can be done from within your c++ application or it can be done from LabVIEW using the call library function (CLF) nodes. CLFs are the means in LabVIEW to access dlls. But to keep things more modular, I would probably implement this functionality in your executable.
 
Unfortunately I don't know the Windows API too well, so I would check out Microsoft's web site.
 
Chris Cs
Message 2 of 12
(3,184 Views)
Thanks Chris, unfortunately my .exe codes are from a 3rd party which I cant access the source code. I have to do this in LabView...wonder if they are other tricks out there?
0 Kudos
Message 3 of 12
(3,175 Views)
Hi Bryan,

This link will get you to microsofts Windows API (formerly Win32) documentation page.

Here you can find most of the exported functions in the windows dll's that will allow you to do what you need and then some.  Be careful with what you poke around with, there is a lot of power in the api. 

You'll need a good grip on using CLFs (call library function node).  Check out the LV help section titled "Calling Shared Libraries" under Funcamentals -> Calling Code Written in Text Based Languages -> Concepts.

Hope this helps!


Message 4 of 12
(3,171 Views)
Thanks Petr, I will try both Chris's and your suggestions.
0 Kudos
Message 5 of 12
(3,164 Views)
Bryan,
You don't have to reinvent the wheel.  NI made VIs for this long long time ago: Windows API Function Utilities (32-bit) for LabVIEW.
You can download it from NI at:  http://zone.ni.com/devzone/cda/epd/p/id/4935
 
You can move any window, LabVIEW or 3rd party, to any position on the screen.
 
George Zou
 
George Zou
Message 6 of 12
(3,164 Views)
Hi George,
 
Thank you for your help. I have two issues automating a few windows executables.
 
1. I need to simulate mouse clicks on those executable windows by sending commands ( so need to know the key strokes) in Labview, and
 
2. I need to reserve a fixed window space in my front panel of my automation vi, so that the windows of those executables will only show up on the reserved space.
 
I guess I need to get more familiar with Windows API, but will appreciate any suggestions on general approch or specifics.
 
Thanks again,
Bryan
0 Kudos
Message 7 of 12
(3,155 Views)
>1. I need to simulate mouse clicks on those executable windows by sending commands ( so need to know the key strokes) in Labview
Simulate mouse click is not the best choice.
When a menu is selected by mouse click, the window will get a message, tells it which menu item is selected.
You should catch the message using Spy++, or WinSpy.  Then you just send this message to the window to simulate a menu selection.
Simulate mouse click should be you last choice.  Not mention you might have to simulate multiple clicks to make a single menu selection,
you could "click" at a wrong place if the window is move to other position or behind another window.
 
>2. I need to reserve a fixed window space in my front panel of my automation vi, so that the windows of those executables will only show
>up on the reserved space.
The easy way is to launch the application, and then use NI's utiltiy to move the window to your fixed space.
 
 
George Zou
 
George Zou
0 Kudos
Message 8 of 12
(3,149 Views)
George, thank you for your suggestions.  I downloaded WinSpy++, after starting it, I opened my appliction program which has a main window and a small window that is first activated. I placed the cross hair of WinSpy onto the small window, pressed "Capture" on the WinSpy.  Then I pressed an OK button on my application's small window, which made the small window disappeared.  Then I pressed Capture again on the WinSpy.  I was hopping to get the command message for pressing the OK button on my application's small window.  The WinSpy told me windows captured on the clipboard, but when I use Ctr-V to paist the clipboard on a notepad, nothing appears. Did i use WinSpy correctly to catch actions on a window?  Thanks.
Bryan
0 Kudos
Message 9 of 12
(3,145 Views)
I did find out the handle of the OK button to be 0045058E on my executable's window from WinSpy.  Then I send the following command
 
cmd /c cClickButton(0045058E)
 
using LabView's System Exec.vi (with string wired to the command line input).  However it didnt press the OK button as expected. Could someone see a problem in doing this?  
Thanks in advance!
 
 
0 Kudos
Message 10 of 12
(3,138 Views)