Disabling hotkey when certain programs are the active window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
THX1138
Posts: 63
Joined: 25 Jul 2017, 00:36

Disabling hotkey when certain programs are the active window

02 Nov 2018, 17:28

I have this code which I use to relocate my mouse cursor to the centre of the screen any time it goes missing.

Code: Select all

MButton & WheelDown::
CoordMode, Mouse, Screen
SysGet, PriMon, Monitor, %MonitorPrimary%
MX := (PriMonLeft + PriMonRight)//2
MY := (PriMonTop + PriMonBottom)//2
MouseMove, MX, MY
return

MButton::Send {MButton}
My problem is that it interferes with control and function of programs AutoDesk Fusion 360 (window title: Autodesk Fusion 360 (Startup License)) and Google Sketchup (window title: SketchUp Make 2017). Thus I want to disable this code any time either of those programs is the active window. My first attempt to do this was tested for Windows Notepad but it doesn't work.

Code: Select all

#IfWinActive, ahk_class Notepad

#IfWinActive
MButton & WheelDown::
CoordMode, Mouse, Screen
SysGet, PriMon, Monitor, %MonitorPrimary%
MX := (PriMonLeft + PriMonRight)//2
MY := (PriMonTop + PriMonBottom)//2
MouseMove, MX, MY
return

MButton::Send {MButton}
I copied this solution directly from https://www.autohotkey.com/docs/Hotkeys.htm#Context but the mouse-cursor-relocation code remains functional when Notepad is the active window, so it doesn't seem that this approach is going to work for me.
vsub
Posts: 541
Joined: 29 Sep 2015, 03:39

Re: Disabling hotkey when certain programs are the active window

03 Nov 2018, 10:46

GroupAdd,Programs,Autodesk Fusion 360 (Startup License)
GroupAdd,Programs,SketchUp Make 2017
Return

#IfWinNotActive,ahk_group Programs
MButton & WheelDown::
CoordMode, Mouse, Screen
SysGet, PriMon, Monitor, %MonitorPrimary%
MX := (PriMonLeft + PriMonRight)//2
MY := (PriMonTop + PriMonBottom)//2
MouseMove, MX, MY
return

MButton::Send {MButton}

#If

Any code below #If is applied to that #If condition until another #If is reached
THX1138
Posts: 63
Joined: 25 Jul 2017, 00:36

Re: Disabling hotkey when certain programs are the active window

05 Nov 2018, 16:42

Thanks but it doesn't seem to work. If I add "Notepad" to the list of programs and try it in Notepad, middle click + scroll still moves the cursor to the centre of the screen.

Code: Select all

GroupAdd,Programs,Autodesk Fusion 360 (Startup License)
GroupAdd,Programs,SketchUp Make 2017
GroupAdd,Programs,Notepad
Return

#IfWinNotActive,ahk_group Programs
MButton & WheelDown::
CoordMode, Mouse, Screen
SysGet, PriMon, Monitor, %MonitorPrimary%
MX := (PriMonLeft + PriMonRight)//2
MY := (PriMonTop + PriMonBottom)//2
MouseMove, MX, MY
return

MButton::Send {MButton}

#If

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, mikeyww and 324 guests