Getting and Clicking buttons on external exe  
Author Message
Zacky





PostPosted: .NET Base Class Library, Getting and Clicking buttons on external exe Top

hi all,

i want to create an application that will give me basic automation functionality.

this application should start an exe file, when i click on a button/menu or anything it should capture the clicks and check what items are found there, later on i want to simulate these commands again automatically.

basically i need to build 2 functions:

1) function that supply information on items found on screen (position, visibility, enable status, class name,....)

2)function that execute the same senario (with confirmation that the command really was executed) using mouse move or remote invocation (throwing the actual events to the application).

can anyone help me with this problem

Z.




.NET Development34  
 
 
Peter Ritchie





PostPosted: .NET Base Class Library, Getting and Clicking buttons on external exe Top

To do this properly you should be using the CBT (computer-based-training) hooks available in Windows. Managed applications cannot use those hooks because of the injection requirements. To do what you want you should create a native application.

 
 
nobugz





PostPosted: .NET Base Class Library, Getting and Clicking buttons on external exe Top

You'll need to P/Invoke the EnumWindows() and EnumChildWindows() API functions to find the external app's main window and child control windows. Once you got those, you can send messages with SendMessage() to operate the app. WM_LBUTTONDOWN followed by WM_LBUTTONUP will simulate a mouse click for example. Check www.pinvoke.net for the required P/Invoke declarations.


 
 
Adrian Hains





PostPosted: .NET Base Class Library, Getting and Clicking buttons on external exe Top

I haven't tried it out, but this sample code looks good for doing the clicking:
http://groups.google.com/group/comp.lang.basic.visual.misc/msg/aed550357f7e8e7e &hl=en&q=sendmessage+WM_LBUTTONDOWN++WM_LBUTTONUP+fire+event

And these are examples of launching a process and getting a handle to its windows and elements:
http://www.codeproject.com/vb/net/ByPassAutomation.asp
http://www.codeproject.com/csharp/wmp_pinvoke.asp

Rather than Spy++, I went with http://www.windows-spy.com/ to identify the classes used by the app I was attempting to automate some mouse clicks on. I haven't really used Spy++, but this other one looks better.