The title says it all, I'm trying to fake mouse clicks in a window..
however it isn't as easy as I thought it would be.
I'm trying to use the follow function:

SendMessage(hTarget,WM_LBUTTONUP,0,0x005000C0)

It should send the WM_LBUTTONUP message to hTarget and the
mouse coordinates are 0x005000C0 which comes out as y:0050 x:00C0.
I found out the WM name and the LParam with Spy++ so they should be
right. And I got the window name with FindWindow successfully.

Although I am using C (well, technically C++ so I can use // comments ;) )
feel free to post in assembly as well since it was what I originally used
and I can understand it. I wouldn't mind C either tho.

I have thought that the problem COULD be the LParam, I've never really
done hex in C but it looks ok to me.

Anyways, Thanks in advance!
Posted on 2002-07-23 20:34:15 by matthew
I am not sure why SendMessage would not work, but I would not
think it would be very reliable in this case. Look up the API call
mouse_event. Its sole purpose is to synthesizes mouse motion
and button clicks.

:cool:
Posted on 2002-07-23 21:33:43 by Graebel
Try :




invoke FindWindow,0, addr WndText
mov hWnd,eax
mov ecx,BN_CLICKED
shl ecx,16
mov cx,ControlId
invoke SendMessage, hWnd, WM_COMMAND, ecx, 0


Regards
Posted on 2002-07-24 02:16:02 by Axial
Try:

SendMessage(hTarget,WM_LBUTTONDOWN,0,0x005000C0)
SendMessage(hTarget,WM_LBUTTONUP,0,0x005000C0)

Remember the action of clicking is a combination of the two!
To prove this try the following:

Hold the left mouse button down over a widgit that accepts clicks (i.e. a button), then move off the button and release.... Nothing will happen.

Click off the button, and while holding drag over the button then release.... Nothing will happen.

If your target is a button, then you can use the BN_CLICK as suggested above...

Mirno
Posted on 2002-07-24 04:47:23 by Mirno
(An actual question in the last paragraph)

Ah ok thanks.
I'll either use SendMessage with button down and up,
or mouse_event (which is renamed in win2k, forgot what
to though). The target is a flash 'game' (well, really it's
a humour thing.. i'll give you a hint - involves a LOT
of clicking). So it's got no conventional buttons.

I've run into new problems though, now FindWindow
doesn't seem to be working. I HAVE revised that part
of the code but that was after it stopped working,
and now it still doesn't.

So I began using FindWindowEx but it hasn't given
any promising results. Flash stuff runs in IEFrame
under a bunch of other windows and it finally
is a window with class MacromediaFlashActiveX (or something
like that). So findwindow won't work because it isn't top
level. I think in the end i'll just use windows hooking
and WM_MOUSEOVER or something.

Maybe i'll learn to make a drag and drop sort of target like
Spy++, anybody know what kind of functions that uses? I'll
probably take an API monitor to it, or a program that is like
it and much simpler.
Posted on 2002-07-24 05:23:20 by matthew
It most likely uses WindowFromPoint.
You'd still have to have the mouse pointer over it, though.
Posted on 2002-07-24 06:40:27 by goofee
you can try to look upon Winspy++ by James Brown
http://freespace.virgin.net/james.brown7/source/winspy_src.zip [84.5k]

it is in Win32API C so it is easy to convert to ASM :grin:

hope it helps,
TBD
Posted on 2002-07-24 06:48:08 by TBD
This is your mouse click - sound only.
Posted on 2002-07-24 08:40:28 by Roy Cline
Hi All,

I write a util for my tvcard for automatic capture. SendMessage does not send my commands (or i don't working) but PostMessage API nicely work, send all my commands remoted application.

I coded like this:



.data
bclass db 'TekramM205',0
...
.code
...
call FindWindow,offset bclass,0
mov [butaddr],eax
call PostMessageA,butaddr,WM_COMMAND,133,0 ; audio format



here 133 is menu id number.

have nice days
Posted on 2002-07-24 18:20:28 by CYDONIA