04-26-2011 08:42 PM
Hi everybody,
I'm trying to make an automated program to control some hardware in my lab. I have imported the manufacturer's DLLs and everything works smoothly except at some points the DLL shoots out a dialog box that I'd like to immediately click yes on. Is there a way to automate this. I've tried using the Windows API to send a spacebar message to the labview window since yes is the default value but that doesn't work.
Thanks for your help,
Chris
04-27-2011 02:29 AM
Windows API will always work to simulate a click or button.
Start with, you have to know what is the Window name (well, every window has a name, you can use some software to get the names of the opened window, in your case the window is a dialog box). Now, use the Windows API to set the Window as Foreground by specifying it's name, simulating a click to the 'Yes' button is so tedious you have to specify the correct co-ordinates and also it will vary with different systems having different screens.
After settingt your dialog box as a Foreground you will have a key focus, so you can now simulate an Enter key to press the "Yes" button.
You can use winlister to get names of all the opened windows : http://www.nirsoft.net/utils/winlister.html
AshwiN,
04-27-2011 02:32 PM
Chris-
Are you controlling this hardware with LabVIEW and calling these DLLs from the VI?
Thanks,
Sean
04-27-2011 03:17 PM
Hi, I send you a nice set of tools for working with the windows APIs (User32.dll).
In the readme.doc you can find the VIs that:
1. Locate a window by its name and make it active. (User32.dll-SetWindowPos)
2. Set mouse in postion X,Y. (User32.dll-SetCursorPos)
3. Make the click action of the mouse (User32.dll-mouse_event)
You should refer to the Microsoft library to undertand the values that are sent as parameters to this functions. A google search with the keyword 'MSDN'+'function name' will do. As an example: http://msdn.microsoft.com/en-us/library/ms646260%28v=vs.85%29.aspx
Like AshwiN I suggest to use the keyboard (focus+enter) to avoid the troublesome positioning of the cursor.
Let us know if this solves your problem.