Sunday, July 3, 2011

Right click lock for Dungeon Siege III

This is an autohotkey script for people who don't like to hold the right mouse button down all the time to move the character. It basically enables right clicklock. The current duration to hold the right mouse key down to activate click lock is 350ms but can obviously be modified to something that is not 350. I've noted that sometimes the game can crash and the right click can remain locked (left click should clear it but may not always work), so use this script at your own caution and make sure you don't have any vital program running before you run this script.
; Right click lock (Rt mouse button will be kept held down with a long click -- short clicks allowed for short movements)

#IfWinActive, Dungeon Siege III
#MaxThreadsPerHotkey 3

; Force the keyboard hook to be used, which as a side-effect prevents the Send command from triggering hotkeys.
#UseHook

~Lbutton::HoldRMB = 0

~Rbutton::
TC := A_TickCount
KeyWait, RButton ;wait for right mouse button to be released
If HoldRMB || (A_TickCount-TC) < 350
{
HoldRMB = 0
Return
}
HoldRMB = 1
Loop {
Send {RButton down}
Sleep 40
if !HoldRMB
break
}
Send {RButton up}
HoldRMB = 0
return
To have this script execute automatically, you can create a batch file in the game directory
start c:\progra~1\AutoHotkey\AutoHotkey.exe /r "ds3.ahk"
start "Dungeon Siege III" "Dungeon Siege III.exe"
exit
and point the Dungeon Siege III play shortcut to it (instead of the executable)