1

I know that I can use

SendMessage(buttonHandle, BN_CLICK, 0, 0);

to get my program (program 1) to click a button on another program (program 2), but I was wondering if there was a way of doing something else. The button I wish to click on program 2 is going to pop up a window.

QUESTION:: Is there any message I can send in the SendMessage() function to bring that window up directly or is there possibly some other function that I can use to do that?

3
  • 2
    The only way the window will pop up is if program 2 executes code to create it. It's likely that the only place this code exists is in the button handler. So no, there's no other message that could make it happen. Commented Apr 22, 2014 at 18:42
  • could I possibly get that code somehow and then send it to program 2 via program 1? Commented Apr 22, 2014 at 18:55
  • BN_CLICK is not a valid message that you can send to a button HWND. You are thinking of BM_CLICK instead. Commented Apr 23, 2014 at 18:13

1 Answer 1

1

Possible ways to automate another application include:

  • Faking input.
  • Sending messages to specific windows.
  • Using a system wide automation framework such as UI Automation.
  • Using an application specific application framework.

You are asking if it is possible to do the final of these options. That depends on the application. If the application publishes such an automation interface it is possible. Otherwise you are looking at one of the other options.

Sign up to request clarification or add additional context in comments.

5 Comments

regarding your second option, I know that I can use SendMessage() to send messages to a specific window... but the thing is I want to see if instead of sending sendmessage(buttonhandle, BN_CLICK, 0, 0), I could possibly send some other code thats something like function(open_window, ID... blahblah)... so that I bypass the button clicking all together
You require the application to expose such an interface. Does it?
I don't believe it does, no. You don't believe there is a way to insert the code into the other program to bring up that other window? (assuming we knew what that code was)
That would be super hacky. You'd also need to find a way to get the code to run in the main thread of the program. Which is tricky to do.
hah agreed. who knows... one day maybe I'll get to that level :P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.