Remap +MButton to ^MButton and vice versa

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Chrysalis
Posts: 11
Joined: 09 Feb 2021, 19:04

Remap +MButton to ^MButton and vice versa

29 Mar 2023, 18:39

Hi,
I'm trying to do what the title says. So something that can be conceptually described as:

Code: Select all

+MButton::
Send, ^MButton
return

^MButton::
Send, +MButton
return
The above code obviously doesn't work. I had to do it like this to obtain desired effect:

Code: Select all

MButton & LShift::
SendEvent, {Blind}{LShift Up}{LCtrl Down}{MButton Down}
return

MButton & LShift Up::
Send, {Blind}{LCtrl Up}{LShift Up}{MButton Up}
return

MButton & LCtrl::
SendEvent, {Blind}{LCtrl Up}{LShift Down}{MButton Down}
return

MButton & LCtrl Up::
Send, {Blind}{LShift Up}{LCtrl Up}{MButton Up}
return

~MButton::
Send, {MButton Down}
return

*MButton Up::
Send, {Blind}{MButton Up}{LShift Up}{LCtrl Up}
return

~*LShift Up::
SendEvent, {Blind}{MButton Up}{LShift Up}{LCtrl Up}
return

~*LCtrl Up::
SendEvent, {Blind}{MButton Up}{LShift Up}{LCtrl Up}
return
It works. But it "stutters". Why is that not ok? This code is for dealing with an application for 3d editing that doesn't let you change key binds for "camera pan" and "camera zoom". Pan is done by Ctrl+MMB (+ mouse drag) and zoom is done by Shift+MMB (+ mouse drag). And I want them to be the other way because I'm used to such configuration from working with other 3d apps.
And by "stuttering" I mean: when I press Shift+MMB and drag the mouse it zooms for ~0.5 s and then starts panning (analogically for Ctrl+MMB). It's annoying. And I don't know how to fix it despite knowing that this code is clunky. Can anyone help me improve this code?
User avatar
mikeyww
Posts: 27260
Joined: 09 Sep 2014, 18:38

Re: Remap +MButton to ^MButton and vice versa

29 Mar 2023, 20:34

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v1.1.33

+MButton::
Send ^{MButton}
SoundBeep 1500
Return

^MButton::
Send +{MButton}
SoundBeep 1000
Return
Explained: Key names
User avatar
Chrysalis
Posts: 11
Joined: 09 Feb 2021, 19:04

Re: Remap +MButton to ^MButton and vice versa

30 Mar 2023, 16:38

Hi mikeyww
Thank's for the welcome. But I have a question: did you just correct my blooper of not including curly brackets around the key name or are you posting an actual answer? If the second is true then it unfortunately doesn't work :(
User avatar
mikeyww
Posts: 27260
Joined: 09 Sep 2014, 18:38

Re: Remap +MButton to ^MButton and vice versa

30 Mar 2023, 19:56

I guess I was a bit hasty. You could try something like this as a first step.

Code: Select all

#Requires AutoHotkey v1.1.33

+MButton::
Send {Ctrl down}{MButton down}
SoundBeep 1500
Return

+MButton Up::
SoundBeep 2000
KeyWait Shift
Send {MButton up}{Ctrl up}
SoundBeep 1000
Return
User avatar
Chrysalis
Posts: 11
Joined: 09 Feb 2021, 19:04

Re: Remap +MButton to ^MButton and vice versa

19 May 2024, 16:09

Ugh... Sorry for so late reply - I forgot to subscribe to the topic to get notifications and back then I actually managed to force myself to ignore the annoyance.

From what you wrote I made this script:

Code: Select all

+MButton::
Send {Ctrl down}{MButton down}
Return

+MButton Up::
KeyWait Shift
Send {MButton up}{Ctrl up}
Return

^MButton::
Send {Shift down}{MButton down}
Return

^MButton Up::
KeyWait Ctrl
Send {MButton up}{Shift up}
Return
And it works flawlessly. Thanks a lot! :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: gssf, peter_ahk and 174 guests