I want to click on a button in another application from my C# application ,
and I don't have the source code for the application that contains the button
let us say as an example ...can I use windows calculator from my application by clicking its buttons Programmatically
I am using c# and .NET
I think I must use windows api to do this
does anybody have any idea????
We can "manually" execute Calculator and type "2+2=" into it. Then when we execute our sample application it can just click the "=" button and we can see the result. Look for "Contol ID" near the botom of the first (General) tab. It will probably have the value "00000079".
Creating a C# Button To create a Button control, you simply drag and drop a Button control from Toolbox to Form in Visual Studio. After you drag and drop a Button to a Form, the Button looks like Figure 1. Once a Button is on the Form, you can move it around and resize it.
Yes, it's not too complicated. You can use FindWindowEx to get the window handle, then iterate through the windows elements and use sendmessage or postmessage to send the WM_Click message.
Here's a codeproject project that does exactly what you want.
Code project
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With