Jump to content

Sending Mouse Click


Dae
 Share

Recommended Posts

I've been trying to send a mouse click to a game and in Winspector it's coming out differently than me actually clicking with my mouse.

What I'm attempting is to send a FAKE mouse click through a DLL call to the game window.

As you can see below, I've quoted the messages sent to the game window.

"program click" messages are fake clicks. Looks to be being sent, but a duplicate is being sent for some reason too.

"natural click" messages are normal clicks. Is sent twice too, but the duplicate is a little different.

WM_LBUTTONDOWN

Buttons pressed: MK_LBUTTON

Mouse coordinates: 32, 107

WM_LBUTTONDOWN

Buttons pressed: MK_LBUTTON

Mouse coordinates: 32, 107

WM_LBUTTONUP

wParam: 0x00000001

lParam: COORD

WM_LBUTTONUP

wParam: 0x00000001

lParam: COORD

WM_LBUTTONDOWN

Mouse coordinates: 32, 107

WM_LBUTTONDOWN

Buttons pressed: MK_LBUTTON

Mouse coordinates: 32, 107

WM_LBUTTONUP

wParam: 0x00000001

lParam: COORD

WM_LBUTTONUP

wParam: 0x00000000

lParam: COORD

The first DLL call is the left mouse button down, and the second is the left mouse button up.

The first WM_LBUTTONDOWN and the last WM_LBUTTONUP don't include 1 of the params. I can't figure out a way to change the duplicate of my message being sent. Any change I make is made in the duplicate. Is this some sort of preventative measure against fake mouse clicks?

DllCall($user32, "long", "PostMessage", "hwnd", $hWnd, "int", 0x00000201, "int", 0x00000001, "long", $COORD)
DllCall($user32, "long", "PostMessage", "hwnd", $hWnd, "int", 0x00000202, "int", 0x00000001, "long", $COORD)

I'm so very close. Any help would be great! Thanks in advance.

Edited by Dae
Link to comment
Share on other sites

Try 0 as the wParam of the 2nd PostMessage? You probably have already but that's all I can think of.

Yeah I tried that. It doubles up and the duplicate is the same. If only I could change the duplicate.

WM_LBUTTONDOWN

Buttons pressed: MK_LBUTTON

Mouse coordinates: 32, 107

WM_LBUTTONDOWN

Buttons pressed: MK_LBUTTON

Mouse coordinates: 32, 107

WM_LBUTTONUP

wParam: 0x00000000

lParam: COORD

WM_LBUTTONUP

wParam: 0x00000000

lParam: COORD

Link to comment
Share on other sites

It does it with the coordinates of the mouse. (where it is on the screen) You may want to use winwaitactive to have it work. I was trying to follow what you were attempting, and I don't understand why you were using dll call at first, then trying the mouseclick. With the thing being sent twice, it looked to me (I could be compleatly wrong here) like you were sending the same command twice???

Take a look at MouseCoordMode. That may give you some direction.

Link to comment
Share on other sites

It does it with the coordinates of the mouse. (where it is on the screen) You may want to use winwaitactive to have it work. I was trying to follow what you were attempting, and I don't understand why you were using dll call at first, then trying the mouseclick. With the thing being sent twice, it looked to me (I could be compleatly wrong here) like you were sending the same command twice???

Take a look at MouseCoordMode. That may give you some direction.

I am not sending the same command twice. The first call is the left mouse button down, the second call is the left mouse button up. I don't know why the call goes through twice, but it just does with this game, and it doesn't seem to have a problem with that - normal mouse clicks go through twice also.

I don't intend on making the window active for the mouse click.

What I am attempting is to send a fake mouse click to the game window that is inactive and hidden.

I'm aware what MouseClick() does. What I'm wondering is what the source does to send that mouse click with the MouseClick() function. A DLL call right? Probably in C#/C++/Java or something, but still, I'd like to know.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...