Nicely written script, with the modularity and comment-references. Your sprinting implementation doesn't work, though. For MP Bioware just imported the horse 'giddyup' function from SP, so you can't just hold down Shift to keep sprinting. If you jump or run into anything, including other players in the lag-dance, even momentarily, your sprinting ends and you have to hit Shift again.
Below is an outline of an effective sprinting implementation. There's a key to toggle autosprinting, which enables and disables sending Shift every 100 milliseconds, so even the frequent collisions of the lag dance won't knock you back into walking. Pressing Shift also disables the timer-loop, giving you a single Shift-press. In addition, while you are standing still the timer-loop stops, and restarts as soon as you begin moving. Basically, if you turn on the toggle, you never have to hit Shift again.
; Sprint Toggle
PgUp::
sprintToggle := !sprintToggle
if (sprintToggle) && (GetKeyState("w", "P") || GetKeyState("a", "P") || GetKeyState("s", "P") || GetKeyState("d", "P")) {
SetTimer KeepSprinting, 100
}
else
SetTimer, KeepSprinting, Off
return
; Sprint when moving if toggled
~w::
~a::
~s::
~d::
~Space::
if (sprintToggle) {
SetTimer KeepSprinting, 100
}
return
; Stop sprinting when not moving
~w UP::
~a UP::
~s UP::
~d UP::
if !GetKeyState("w", "P") && !GetKeyState("a", "P") && !GetKeyState("s", "P") && !GetKeyState("d", "P")
SetTimer, KeepSprinting, Off
return
#UseHook ; Prevent the following hotkey from calling itself
; Sprint once
~Shift::
SetTimer, KeepSprinting, Off
return
#UseHook Off
KeepSprinting:
IfWinActive, ahk_class Dragon Age: Inquisition
{
Send {Shift Down}
Sleep 10
Send {Shift Up}
}
return
Some other miscellaneous pointers ...
SetTitleMatchMode, 2 Can be problematic, especially for a script that others might use. If a user has a document (notepad, spreadsheet, etc.) open that is similarly titled, you're going to run into problems. SetTitleMatchMode, 3 is a better idea, as well as using the ahk_class title. (#IfWinActive ahk_class Dragon Age: Inquisition).
It would be good to add functionality to your RMB scripting that releases the button if the user alt-tabs, or switches to another application another way. This relieves the user from having to remember to toggle the RMB off before switching applications. Even better would be to re-enable the RMB conditionally when switching back to DA:I. Here's a scriptlet that does that:
Loop {
WinWaitActive, ahk_class Dragon Age: Inquisition
if rmb {
Click down right
SoundPlay, %A_WinDir%\Media\Windows Hardware Insert.wav
}
WinWaitNotActive, ahk_class Dragon Age: Inquisition
if rmb {
Click up right
SoundPlay, %A_WinDir%\Media\Windows Hardware Remove.wav
}
}
Lastly, the problem of Shift carrying over to the overlay is a bit of a challenge. The overlay seems to be completely immune to Autohotkey -- while it's active as well as calling it and dismissing it. You can have a hotkey that adds a wildcard to F1, then match onscreen colors to determine if Shift+F1 was presed or just F1 (the overlay has distinct colors to match). Something like this ...
; On opening Origin overlay, stop sprinting, and on
; closing the overlay, resume sprinting if toggled on
#UseHook
~*F1::
PixelGetColor, pcolor1, 869, 26
PixelGetColor, pcolor2, 865, 26
if (pcolor1 = 0xECECEC && pcolor2 = 0x3B3B3B && sprintToggle) {
SetTimer KeepSprinting, OFF
Keywait, F1, down
if sprintToggle {
SetTimer KeepSprinting, 100
}
}
return
#UseHook Off
This doesn't quite work, though. I'm still working on it (obviously the PixelGetColor coordinates will vary by monitor size). Hmm, I suppose putting the color-check into the KeepSprinting subroutine (which runs every 100 milliseconds if toggled on) could prevent sending Shift while the overlay is active.