Help refining a LMB remap

Ask gaming related questions (AHK v1.1 and older)
Hyphen
Posts: 53
Joined: 24 Jul 2016, 17:57

Help refining a LMB remap

23 May 2017, 09:03

Here's my code block:

Code: Select all

		LButton::
			CoordMode, Mouse, Screen
			MouseGetPos, posX, posY
				if ((posX >= 1658) && (posY >= 818)) || ((posX >= 549) && (posX <= 1212) && (posY >= 975)) { ; Minimap and information bar
					SendInput {Shift down}{LButton down}
					_release := "{LButton up}{Shift up}"
				} else {
					SendInput {LButton down}
					_release := "{LButton up}"
				}
		Return
		LButton up::SendInput %_release%
I'll explain for anyone who cares or needs context. In League of Legends, I have my LMB bound to the attack-move command. By default, moving elements on the League UI is LMB. Therefore, I've had to rebind (in the game settings) the default LMB action to Shift+LMB. This code here makes it so that when I hover the minimap or item bar, the LMB sends Shift+LMB instead (effectively fixing the problem and allowing me to just LMB on the minimap and item bar rather than Shift+LMB).

So far, this is working fine. However, the very first time I hover these areas and press the LMB, it sends LMB instead of Shift+LMB. Why is that? Additionally, if I spam the LMB key over the minimap, sometimes it will send a LMB instead of Shift+LMB. It happens very rarely, but I can't afford it to happen at all. Are there any ways to fix these?
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Help refining a LMB remap

23 May 2017, 15:52

It's very hard to tell, I see no obvious errors in your code.

I would suggest adding some logging to the script using the OutputDebug command.

You can get debug info from an AHK editor such as Scite, but instead I would recommend downloading DebugView from SysInternals (It's a Microsoft site, totally safe) which will allow you to see the debug messages in a separate window.

To avoid seeing loads of spam from other apps, use the following filter in debugview (CTRL+L to set filter)

DBGVIEWCLEAR;AHK|*

Then prefix all your debug messages with "AHK|" like so:

OutputDebug % "AHK| The value of a is: " a

It can also be handy to put this line at the start of the script to clear the log each time you run it:
OutputDebug DBGVIEWCLEAR

So use this to log the coords it gets from the mouse, and the decision it makes - you may find that it gets bad coords or you goofed or something.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: ReyAHK and 90 guests