Hi there,

I have a problem which I can't solve since I am a bit rusty in programming (due to NAVY TIME :mad: ).

I have a program which displays a messagebox with two buttons on it. I use a timer function in my own program which waits until this messagebox comes up on the target. Then it is supposed to click on one of the buttons. I already have the handle of the button, but how do I simulate a press on this button?

Please help me.

Posted on 2001-12-15 09:08:56 by YaWNS
well, i can't personally help ya, but...

[9:02am] <YaWNS> Can someone tell me, how I can click a button by commands? I mean, I get a messagebox wit two buttons on it using findwindow, then I find the button I need, but how do I simulate the click on that button? Is there a style with SendMessage?
[9:05am] <YaWNS> Noone?
[9:06am] Quits: YaWNS (xxxxxx@xxxxxx.foo.net) ($null)
[9:16am] <Nerz> yawn: WM_COMMAND
[9:17am] <_death> he quit
[9:18am] <Nerz> still I said it
[9:18am] <Nerz> hehe
Posted on 2001-12-15 09:52:32 by nev
yeah but what if you don't know the exact
button-handle? sooner i had a little dumb vb
bruteforce prog that was able to get though a
password list and send password for password
to the current (focused) dialog (you could define
buttons like enter or tab or whatever)...
you can definitively do this with a playback-hook
or even better with a mouse hook that retrives
the current class/handle so you can send
WM_COMMAND msg's but these ways seem to be
very dirty and circular (assuming i'll choose the 2nd
way i'll definitively not use a dll hook (uh i hate it!)
so i will try to set up a journal record to do this, but
these hooks are very slow i think), are there other
ways to do it?

btw: und? wars toll in der marine? :)
Posted on 2001-12-15 13:13:24 by mob

[9:16am] <Nerz> yawn: WM_COMMAND

And you should send that message to the parent window of the button. Of course, if you don't actually own the parent window you would need to do an EnumWindows() first to find it.
Posted on 2001-12-15 16:21:41 by sluggy
hey YaWNS,

sluggy is right, you gotta send a WM_COMMAND message to the parent window of the message box. you should choose wParam and lParam, like if you would check in your application if a button was pressed. get it? ;)

Posted on 2001-12-16 03:29:58 by NOP-erator
you could send a message directly to the button, those messages:

Invoke SendMessage, hWndOfTheBUTTON, WM_LBUTTONDOWN, 0, 0
Invoke SendMessage, hWndOfTheBUTTON, WM_LBUTTONUP, 0, 0

Posted on 2001-12-16 07:04:15 by NEMO

I finally found out my problem. Your Reply, NEMO, gave the important thing. I just forgot about one fact on the target programm and now everything works fine.

Thanks to all who tried to help. Stay tuned as there will be new probs from my side :D

Greets YaWNS
Posted on 2001-12-16 09:43:06 by YaWNS