Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Sending mouse click to League of Legends without moving mouse cursor


  • Please log in to reply
2 replies to this topic
dilly
  • Members
  • 1 posts
  • Last active: Apr 17 2014 06:31 AM
  • Joined: 15 Apr 2014

I'm trying to use AutoHotKey to simulate WASD movement in League of Legends by sending mouse clicks without moving the mouse.  The Click function works fine in LoL, but won't work because it moves the mouse cursor.  I tried ControlClick, but I could not get it to register within League of Legends (it worked fine in other apps).

 

These other threads gave me hope that it could be done with PostMessage, even though ControlClick did not work:

 

http://www.autohotke...l-hwnd-clicker/

http://www.autohotke...to-game-window/

 

Unfortunately, PostMessage is just plain over my head.  I would give a million good wishes and the biggest smile this side of the Mississippi to anyone who could get a mouse click working in League of Legends without moving the mouse cursor.  Any ideas or suggestions?

 

EDIT:

 

I thought I'd add a little progress I made.  I used this script (taken from the second link above) to try to send a Right Click to the window.  (I really don't know what I'm doing here):

$\::PostClick(26,72, "League of Legends (TM) Client")

PostClick(X, Y, hwnd="A", Count=1, Delay=50)
{
	x := 100
	y := 100

	lParam := x | (y << 16)

	SendMessage, 0x084 , 0x00000000 , %lParam%, , 	%hwnd%	;NCHITTEST SEND
	SendMessage, 0x020 , 0x00040708 , 0x02040001, , %hwnd%	;SETCURSOR SEND
	PostMessage, 0x200 , 0x00000000 , %lParam%, , 	%hwnd%	;MOUSEMOVE POST
	Sleep,100
	PostMessage, 0x204 , 0x00000002 , %lParam%, , 	%hwnd%	;RBUTTONDOWN POST
	SendMessage, 0x084 , 0x00000000 , %lParam%, , 	%hwnd%	;NCHITTEST SEND
	SendMessage, 0x020 , 0x00040708 , 0x02050001, , %hwnd%	;SETCURSOR SEND
	PostMessage, 0x205 , 0x00000000 , %lParam%, , 	%hwnd%	;RBUTTONUP POST
}

This was the results in spy++:

<00001> 000C0492 S WM_GETICON nType:ICON_BIG
<00002> 000C0492 R WM_GETICON hicon:00000000
<00003> 000C0492 S WM_GETICON nType:ICON_SMALL
<00004> 000C0492 R WM_GETICON hicon:00000000
<00005> 000C0492 S WM_GETICON nType:ICON_SMALL2
<00006> 000C0492 R WM_GETICON hicon:00000000
<00007> 000C0492 S WM_WINDOWPOSCHANGING lpwp:000FEC44
<00008> 000C0492 R WM_WINDOWPOSCHANGING
<00009> 000C0492 S WM_WINDOWPOSCHANGED lpwp:000FEC44
<00010> 000C0492 R WM_WINDOWPOSCHANGED
<00011> 000C0492 S WM_ACTIVATEAPP fActive:True dwThreadID:000014F0
<00012> 000C0492 R WM_ACTIVATEAPP
<00013> 000C0492 S WM_NCACTIVATE fActive:True
<00014> 000C0492 R WM_NCACTIVATE
<00015> 000C0492 S WM_ACTIVATE fActive:WA_ACTIVE fMinimized:False hwndPrevious:(null)
<00016> 000C0492 S WM_IME_SETCONTEXT fSet:1 iShow:C000000F
<00017> 000C0492 R WM_IME_SETCONTEXT
<00018> 000C0492 S WM_SETFOCUS hwndLoseFocus:(null)
<00019> 000C0492 R WM_SETFOCUS
<00020> 000C0492 R WM_ACTIVATE
<00021> 000C0492 S WM_NCHITTEST xPos:1097 yPos:329
<00022> 000C0492 R WM_NCHITTEST nHittest:HTCLIENT
<00023> 000C0492 S WM_NCHITTEST xPos:1097 yPos:329
<00024> 000C0492 R WM_NCHITTEST nHittest:HTCLIENT
<00025> 000C0492 S WM_SETCURSOR hwnd:000C0492 nHittest:HTCLIENT wMouseMsg:WM_MOUSEMOVE
<00026> 000C0492 R WM_SETCURSOR fHaltProcessing:False
<00027> 000C0492 P WM_MOUSEMOVE fwKeys:0000 xPos:769 yPos:177
<00028> 000C0492 S WM_NCHITTEST xPos:100 yPos:100
<00029> 000C0492 R WM_NCHITTEST nHittest:HTNOWHERE
<00030> 000C0492 S WM_SETCURSOR hwnd:00040708 nHittest:HTCLIENT wMouseMsg:WM_RBUTTONDOWN
<00031> 000C0492 R WM_SETCURSOR fHaltProcessing:False
<00032> 000C0492 P WM_MOUSEMOVE fwKeys:0000 xPos:100 yPos:100
<00033> 000C0492 S WM_NCHITTEST xPos:100 yPos:100
<00034> 000C0492 R WM_NCHITTEST nHittest:HTNOWHERE
<00035> 000C0492 P WM_RBUTTONDOWN fwKeys:MK_RBUTTON xPos:100 yPos:100
<00036> 000C0492 S WM_SETCURSOR hwnd:00040708 nHittest:HTCLIENT wMouseMsg:WM_RBUTTONUP
<00037> 000C0492 R WM_SETCURSOR fHaltProcessing:False
<00038> 000C0492 P WM_RBUTTONUP fwKeys:0000 xPos:100 yPos:100
<00039> 000C0492 S WM_CONTEXTMENU hwnd:000C0492 xPos:428 yPos:252
<00040> 000C0492 R WM_CONTEXTMENU
<00041> 000C0492 S WM_NCHITTEST xPos:1097 yPos:329
<00042> 000C0492 R WM_NCHITTEST nHittest:HTCLIENT
<00043> 000C0492 S WM_NCHITTEST xPos:1097 yPos:329
<00044> 000C0492 R WM_NCHITTEST nHittest:HTCLIENT
<00045> 000C0492 S WM_SETCURSOR hwnd:000C0492 nHittest:HTCLIENT wMouseMsg:WM_LBUTTONDOWN
<00046> 000C0492 R WM_SETCURSOR fHaltProcessing:False
<00047> 000C0492 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:769 yPos:177
<00048> 000C0492 S WM_NCHITTEST xPos:1097 yPos:329
<00049> 000C0492 R WM_NCHITTEST nHittest:HTCLIENT
<00050> 000C0492 S WM_NCHITTEST xPos:1097 yPos:329
<00051> 000C0492 R WM_NCHITTEST nHittest:HTCLIENT
<00052> 000C0492 S WM_SETCURSOR hwnd:000C0492 nHittest:HTCLIENT wMouseMsg:WM_LBUTTONUP
<00053> 000C0492 R WM_SETCURSOR fHaltProcessing:False
<00054> 000C0492 P WM_LBUTTONUP fwKeys:0000 xPos:769 yPos:177
<00055> 000C0492 S WM_NCHITTEST xPos:1097 yPos:329
<00056> 000C0492 R WM_NCHITTEST nHittest:HTCLIENT
<00057> 000C0492 S WM_NCHITTEST xPos:1097 yPos:329
<00058> 000C0492 R WM_NCHITTEST nHittest:HTCLIENT
<00059> 000C0492 S WM_SETCURSOR hwnd:000C0492 nHittest:HTCLIENT wMouseMsg:WM_MOUSEMOVE
<00060> 000C0492 R WM_SETCURSOR fHaltProcessing:False
<00061> 000C0492 P WM_MOUSEMOVE fwKeys:0000 xPos:769 yPos:177
<00062> 000C0492 P WM_SYSKEYDOWN nVirtKey:VK_MENU cRepeat:1 ScanCode:38 fExtended:0 fAltDown:1 fRepeat:0 fUp:0
<00063> 000C0492 S WM_CANCELMODE
<00064> 000C0492 R WM_CANCELMODE
<00065> 000C0492 S WM_NCHITTEST xPos:1097 yPos:329
<00066> 000C0492 R WM_NCHITTEST nHittest:HTCLIENT
<00067> 000C0492 S WM_NCHITTEST xPos:1097 yPos:329
<00068> 000C0492 R WM_NCHITTEST nHittest:HTCLIENT
<00069> 000C0492 S WM_SETCURSOR hwnd:000C0492 nHittest:HTCLIENT wMouseMsg:WM_MOUSEMOVE
<00070> 000C0492 R WM_SETCURSOR fHaltProcessing:False
<00071> 000C0492 P WM_MOUSEMOVE fwKeys:0000 xPos:769 yPos:177
<00072> 000C0492 P WM_KEYUP nVirtKey:VK_MENU cRepeat:1 ScanCode:38 fExtended:0 fAltDown:0 fRepeat:1 fUp:1
<00073> 000C0492 S WM_NCACTIVATE fActive:False
<00074> 000C0492 R WM_NCACTIVATE fDeactivateOK:True
<00075> 000C0492 S WM_ACTIVATE fActive:WA_INACTIVE fMinimized:False hwndPrevious:(null)
<00076> 000C0492 R WM_ACTIVATE
<00077> 000C0492 S WM_ACTIVATEAPP fActive:False dwThreadID:00000FC4
<00078> 000C0492 R WM_ACTIVATEAPP
<00079> 000C0492 S WM_KILLFOCUS hwndGetFocus:(null)
<00080> 000C0492 R WM_KILLFOCUS
<00081> 000C0492 S WM_IME_SETCONTEXT fSet:0 iShow:C000000F
<00082> 000C0492 R WM_IME_SETCONTEXT

The Left Click in the above is a real left click.  The Right Click is simulated by AutoHotKey with the script above.  The interesting thing I noticed is that the hittest for the real click returns HTCLIENT, while the hittest for my non-working code returns HTNOWHERE.  Any ideas how to fix this?



RHCP
  • Members
  • 1228 posts
  • Last active: Apr 08 2017 06:17 PM
  • Joined: 29 May 2006

Have you read the MSDN documentation to ensure each message is being sent with the correct wParam and lParam values?  

SendMessage, 0x020 , 0x00040708 , 0x02040001, , %hwnd%	;SETCURSOR SEND

I can't be bothered checking them for you,  but I can tell you that this one is incorrect.

 

 

 

wParam

A handle to the window that contains the cursor.

lParam

The low-order word of lParam specifies the hit-test code.

The high-order word of lParam specifies the identifier of the mouse message.

Link http://msdn.microsof...2(v=vs.85).aspx

 

I've noticed (in starcraft) every mouse button up press is followed by a WM_MouseMove as well (not sent before, unless the mouse is actually moved) - but I don't know if that is the same for all games.



orliesaurus
  • Members
  • 1 posts
  • Last active: Sep 15 2014 04:06 PM
  • Joined: 29 Apr 2014

Hi, did you manage to get this to work? Any updates?

I'm looking to do something similar so I was wondering if you could share some quick-wins before I get down and do it "from scratch"