i come from a background of fps games, where you don’t need to hold right-click in order to look around. i also found it quite awkward to turn with “a” and “d” — i quickly changed those to strafe left/right. i searched for a script to automatically hold down right-click for me, and found a few. but none of them were very good so i made my own using autohotkey (ahk)!
ahk is a pretty common program for creating macros. for those who are unfamiliar with it, after you download the program you should:
- delete the contents of “AutoHotkey.ahk”
- copy-paste my script in there; save
- reload the script in ahk
#SingleInstance force
#MaxThreadsBuffer On
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#InstallKeybdHook
#InstallMouseHook
#IfWinActive ahk_class ArenaNet_Dx_Window_Class ;hotkeys only work when GW2 is active
MouseLookKey = RButton
ToggleKey = q ;choose which key to toggle MouseLookKey depress
Hotkey, ~*%ToggleKey%, ToggleMouseLook
~o:: ;all these hotkeys call ToggleOff()
~y::
~g::
~h::
~i::
~k::
~f12::
~f11::
~p::
~b::
~n::
~m::
~c::
~WheelDown::
~WheelUp::ToggleOff()
!TAB:: ;when you alt-tab, toggle off first
ToggleOff()
Send {Alt Down}{Tab}
return
ToggleOff()
{
global
if(GetKeyState(MouseLookKey)) ;key is held down
{
send {%MouseLookKey% up}
}
}
ToggleMouseLook:
if(GetKeyState(MouseLookKey))
{
send {%MouseLookKey% up}
}
else
{
BlockInput, Mousemove
WinGetPos,,,WinWidth,WinHeight,ahk_class ArenaNet_Dx_Window_Class
MouseMove,WinWidth/2,WinHeight/2,1
BlockInput, MouseMoveOff
send {%MouseLookKey% down}
}
return
this is what the script does:
- when you press “q,” the right mouse button is held down, and the mouse is centered. if you press it again, the right mouse button is released. you can change ToggleKey something other than “q.”
- when you open a dialog (e.g. you press “i” to open your inventory), right-click is released (toggled off).
- when you alt-tab from gw2, right-click is released.
- the script’s hotkeys are only active when gw2 is the active window.
i do not use all the default keys, in particular i use:
- “c” for interact and “f” for aoe loot. i found it beneficial to have interact and loot on separate keys, because i want to release right click most of the times when i interact. however, when i loot i always want right click to still be held down.
- mouse wheel for zooming in and out (WheelDown and WheelUp). right click has to be released in order to zoom in or out.
some other custom keys i use in gw2, but are not affected by my script: “a” and “d” for strafing; “e” for free camera; and, “x” for lock autotarget (use to untarget).
this is my first ahk script. let me know what you think!