Intercepting mouse cicks Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Danniique
Posts: 6
Joined: 11 Feb 2018, 02:11

Intercepting mouse cicks

11 Feb 2018, 05:09

Hi there :)

I appreciate any help given on helping me figure this one out as I'm rather stumped.

I'm having difficulties getting a script to intercept a mouse click so that I can choose to either accept, deny or modify it based on the location of the cursor on the screen (if it is over the minimap in League of Legends).

I have tried remapping the mouse button to null and using the Hotkey On/Off command to toggle its activation state depending on the cursor location but for some reason I cannot seem to get it to work. I feel quite certain that this is what I need to do but I feel like perhaps my lack of understanding the structure of script programming properly is what is preventing me from getting it working - I'm not a programmer and just read the help files, google for insight or trial and error to sometimes get things working. It's beginning to frustrate me a little.

I wouldsend through my latest attempt using the Hotkey function, but unfortunately, after countless iterations, various strategies and around 12 hours (yes, I swear, it's quite embarrassing) it turns out I don't have a save using that particular strategy. I will try and work one up when I have the time. In the meantime, I'm posting this up on the forums to see if I can get a head start.

The basic gist of what I have/will have (rough draft with truncations for simplicity):
#Ifwinactive LoL.exe
Hotkey, RButton, RButtonHotkey, Off ;- Initializes the RButton Hotkey and sets it to off

SetTimer, LeagueCheck, 1000

;- -- MAIN LOOP --

LeagueCheck:
while WinActive("LoL.exe") { ;- periodically checks if LoL.exe is the active window before proceeding

;~ OFFMAP STUFF

Loop {
MouseGetPos, Xpos, Ypos
OnMap := ((Xpos > MapX) AND (Ypos > MapY))
} Until OnMap ;~ loops mouse position check until it is over the map, ie. OnMap = True

Hotkey, RButton, On

;~ ONMAP STUFF

Loop {
MouseGetPos, Xpos, Ypos
...
} Until (Xpos < MapX) OR (Ypos < MapY) ;~ loops until cursor is off the map, then turns the Hotkey Off and sets OnMap = False

Hotkey, Rbutton, Off
OnMap := !OnMap
}
return

RButtonHotkey: ;- the Hotkey label/function
RButton::
return
Sorry about the lack of code formatting, I know it's dreadful to try and read like this. I CAN'T EVEN GET BBS INDENTATION CODES TO WORK!! no wonder I have so much trouble programming.

Anyways, any help would be great thank you.

Danniique
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Intercepting mouse cicks  Topic is solved

11 Feb 2018, 07:44

The first thing that can be a big factor is whether you're running the game fullscreen or (fullscreen) windowed. If it's fullscreen, the game cursor location likely doesn't match your MouseGetPos output, if it's windowed, it may.

Secondly, I'd advise against the loop doing the checking and setting the hotkey on/off. Instead, use something like:

Code: Select all

#If Winactive("LoL.exe") && CursorInMinimap()
RButton::return

CursorInMinimap(){
	MapX:=50 ;set correct values 
	MapY:=50
	MouseGetPos, Xpos, Ypos
	Return ((Xpos < MapX) AND (Ypos < MapY))
}
Danniique
Posts: 6
Joined: 11 Feb 2018, 02:11

Re: Intercepting mouse cicks

13 Feb 2018, 06:43

Thanks for the advice Nex I'll give these a look when I get a chance. I've actually temporarily uninstalled League while I have other more important things that I need to focus on.

I honestly don't lack impulse control. That's just a rumour.
Danniique
Posts: 6
Joined: 11 Feb 2018, 02:11

Re: Intercepting mouse cicks

20 May 2018, 01:08

Nextron wrote:The first thing that can be a big factor is whether you're running the game fullscreen or (fullscreen) windowed. If it's fullscreen, the game cursor location likely doesn't match your MouseGetPos output, if it's windowed, it may.

Secondly, I'd advise against the loop doing the checking and setting the hotkey on/off. Instead, use something like:

Code: Select all

#If Winactive("LoL.exe") && CursorInMinimap()
RButton::return

CursorInMinimap(){
	MapX:=50 ;set correct values 
	MapY:=50
	MouseGetPos, Xpos, Ypos
	Return ((Xpos < MapX) AND (Ypos < MapY))
}
You've really helped show ways of doing things I hadn't previously considered. I started out programming in BASIC on my Amiga500 back in the early 90's but I never progressed beyond it or picked it up again until recently with AHK. The whole concept of functions has thus, always been something foreign and which I've avoided where possible but this has worked amazingly thankyou!
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Intercepting mouse cicks

20 May 2018, 04:59

Good to hear! Thanks for the feedback. :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, Joey5 and 249 guests