0
votes

Well, the project has moved along rather nicely and we have a pretty darn good product, but a wrench has been thrown into the gear works.

We have a C# 2012 application that interacts with another application (written in VB 6 of all things) and we can do a good bit with it so far, but we have a problem.

We need to select a button on a toolbar at the top of this particular application's window, but the button is not available through an API search. We have the main window's handle and can see all of its children, but I think the Toolbar is a User type control that we can't access through the API Calls. This application is very poorly designed and we had to do a LOT of work just to discover TWO User ID text boxes on the logon screen.

Anyway, my question is this: How would I set up a call to the main window and click a certain X, Y coordinate of that window's viewable area? I am using SendMessage to send mouse clicks to press a button control already, but if I can't get access to that button control, the idea was to send mouse clicks to a specific coordinate of the window.

Any ideas folks? Thanks!

1
Use Spy++ (part of the Windows SDK) to find out what window receives the messages in normal use (interactive with a real mouse). Or even better, find out what WM_COMMAND or WM_NOTIFY id the toolbar button sends to its owner, and just send that, bypassing the mouse-clicky type messages.Ben Voigt
Would I use those parameters (WM_COMMAND, WM_NOTIFY) in the Send Message method to return that information? My Win32 API knowledge is about 6 months old. :-DEric Olson
No, you'd use Spy++ to discover the message arguments sent from the toolbar button to the main window, and then you could use SendMessage(hWnd, WM_COMMAND, stuff learned from Spy++) to tell the app its toolbar was clicked.Ben Voigt
If you really want to literally click the screen then use the GetWindowRect() API to get the (x, y) location of the main window, then simply add an offset to that to click the button using the mouse_event() API. This assumes that the position of the button doesn't changed with respect to its own UI.Idle_Mind
Bit of history for you...Idle_Mind

1 Answers

0
votes

It looks like the solution will be to get the Window's rectangle and add the offset in order to use the mouse event API call.

Thank you to @Idle_Mind for the suggestion. It is at least working on our test environment. It will be next week before we can test the solution out in our client's environment.