[C#] "Pressing" a Button

gooby pls
Decennium
Joined
Mar 22, 2008
Messages
830
Reaction score
174
OK, here is my question/problem/doubt...

Lets say I have an app that has two buttons.
button01 = Start
button02 = Exit

Is it possible to program an application that calls the button01 or 02, without actually pressing the button(clicking)?
If it is, anyone mind showing me an example?

Regards,
Alan
 
Yes, debug/disassemble, find the wndproc handling the click, find the function it calls on a click to that button ID (you can get the ID with something like the spy tool that comes with visual studio), and if you call that code yourself, it will behave as if the button was clicked unless more logic is implemented to test for a click (this is rare). You can also simulate the message yourself with http://msdn.microsoft.com/en-us/library/ms633571(v=vs.85).aspx.

There may be tools to get a list of wndprocs for a process's HWNDs (maybe Process Explorer? That spy tool may do it too). You can do this manually with http://msdn.microsoft.com/en-us/library/ms633584(v=vs.85).aspx by passing the HWND of the control.

You can use EnumWindows to enumerate windows and drill down into children to find child controls etc with EnumChildWindows. I'm not sure the code for C# for any of this but if the application is written in C#, you can probably just decompile the CIL.

And the wndprocs for a C# application will probably exist in .NET CLR code that invokes CIL code, in that case I'm not sure what you'd want to do. You can probably just simulate a mouseclick.
 
Last edited:
Thanks!
BTW: My computer got fucked up, and I am reinstalling windows now...
I didn't have any time to come online on MSN, so I'll contact you ass soon as I can.
 
if you want a lame hack that's easier than all that, just make a quick app that clicks an area on the screen and teach it where both buttons are :P
 
if you want a lame hack that's easier than all that, just make a quick app that clicks an area on the screen and teach it where both buttons are :P
Do you think I am stupid?
I am making attempting to create a small application capable of opening and clicking on a launcher's buttons... The launcher is in Chinese and people are too lazy and stupid to follow the directions I gave them, so I decided to make a "loader"...
 
Hah. I've made tens of thousands of dollars with that solution that you think i'm calling you stupid for suggesting :P

I don't think you're stupid - was just suggesting a simple solution if it was a simple problem :)
 
Back