Getting a Handle for a Button Whose Parent Doesn't Have a Title?

ransomedbyfire

Board Regular
Joined
Mar 9, 2011
Messages
121
I am trying to use SendMessage to click a button. I have the text from the button; but when I try to use the title of the window it appears to be in as the parent hwnd, it doesn't find the button. I just ran a piece of code provided by Microsoft that is supposed to simulate Spy++; and it says that the parent window of this button has no title. So, how should I go about clicking it via SendMessage?

Thank you!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Re: Getting a Handle for a Button Whoe Parent Doesn't Have a Title?

I am trying to use SendMessage to click a button. I have the text from the button; but when I try to use the title of the window it appears to be in as the parent hwnd, it doesn't find the button. I just ran a piece of code provided by Microsoft that is supposed to simulate Spy++; and it says that the parent window of this button has no title. So, how should I go about clicking it via SendMessage?

Thank you!

Where is this button ? Is it a button embeeded in a worksheet ? Plz , provide more details.
 
Upvote 0
Sorry!

The button is on another application that I have launched with Shell and send keyboard commands to. I can get the handle for the initial window, and even for other buttons and one of the child windows. But I am having trouble sending input to a Finish button that is on the final screen that comes up after the export. I was hoping that, by finding the handle to the button, I could better detect when the export is done; but I am considering just having my macro wait a few minutes and sending WK_CLOSE to this window instead.
 
Upvote 0
Sorry!

The button is on another application that I have launched with Shell and send keyboard commands to. I can get the handle for the initial window, and even for other buttons and one of the child windows. But I am having trouble sending input to a Finish button that is on the final screen that comes up after the export. I was hoping that, by finding the handle to the button, I could better detect when the export is done; but I am considering just having my macro wait a few minutes and sending WK_CLOSE to this window instead.

Using a Spy like program you can determine if the target button has a hwnd in which case the best approach is to use the SendMessage API passing to it the hwnd. If no hwnd then you could watch for the existance of the final screen (where the button is located) and send the WM_CLOSE to it.
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,219
Members
452,895
Latest member
BILLING GUY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top