That script does not work on any version of Windows.
You would need to remove the invalid line
Else MButton::MButton
. You can't "execute" a hotkey or remapping like you execute a command or function. They are more like directives or labels. The hotkey
MButton::
executes whenever the user presses MButton, and at that point what you want to do is have it perform a click (
MouseClick Middle
or
Send {MButton}
), not "remap" the button.
If I remove that line, the script works okay on my Windows 10 system.
If you want the script to override middle click only while the cursor is hovering over the taskbar buttons, you can write it like this:
ShouldActivateMButton() {
MouseGetPos, xpos, ypos, , ControlUnderMouse
return ControlUnderMouse = "MSTaskSwWClass1"
|| ControlUnderMouse = "ApplicationManager_DesktopShellWindow"
|| ControlUnderMouse = "Shell_TrayWnd1"
|| ControlUnderMouse = "MSTaskListWClass1"
}
#If ShouldActivateMButton()
MButton::
MouseClick, Right
Sleep, 200
Send, {Up}
Send, {Enter}
return
At minimum, you would need to check for
MSTaskListWClass1
on Windows 10. I'm not sure whether all of the others are correct or necessary.
Braces have no effect for hotkeys/labels, so I removed them.
The following also works for me; it might be more reliable (for English systems):
; Add #If etc here if needed.
MButton::
Send +{RButton}
WinWait ahk_class #32768,, 1 ; Menu
if !ErrorLevel
Send c ; Close
return