Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODIFIED AT: 10/11/22 >> gw4/gw4.ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will reload it (the dialog box that normally appears in this situation gets skipped)
- #SingleInstance Force
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- ; Runs the game and terminates the macro when the game window doesn't exist any longer and wasn't being restarted either (keep this at the bottom of the auto-execute section)
- RunWait, "C:\Program Files\Guild Wars 2\Gw2-64.exe"
- ManageApp()
- ; The code below only executes for the Guild Wars 2 window
- #Include, <functions>
- #Include, <hotkeys>
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 10/11/22 >> gw4/lib/functions.ahk:
- ; Terminates the macro if the game doesn't restart itself within 30 seconds. And also has recursive code, which restarts this method each time the game crashes and immediately restarts
- ManageApp()
- {
- WinWait, Guild Wars 2,, 30
- if (ErrorLevel == 1)
- ExitApp
- else
- {
- WinWaitClose
- ManageApp()
- }
- }
- ToggleChatState()
- {
- Hotkey, If, (WinActive("Guild Wars 2"))
- HotKey, v, Toggle
- global isChatActive := !isChatActive
- }
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- Send, {Click -15 0 0 Relative}
- Send, {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- shouldUsePostponableHotkeys := true
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- }
- shouldUsePostponableHotkeys := false
- }
- ; Left-click outside the chat area with an active chat input field and left-click inside an inactive chat input field both toggles the chat state of the macro as well
- OnLButton()
- {
- MouseGetPos, currentCursorX, currentCursorY
- if (isChatActive)
- {
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleChatState()
- }
- else if (currentCursorX < 482 and currentCursorY > 1370)
- ToggleChatState()
- }
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 10/11/22 >> gw4/lib/hotkeys.ahk:
- #If (WinActive("Guild Wars 2"))
- ; Prevents hotkey interference when the chat is being used
- ~Enter::ToggleChatState()
- ; Dodge Jump
- ~v::Send, {Space}
- F3::
- F4::LButtonAboutFace("F3")
- ; This fixes the bug where the character suddenly rotates in a random manner when the player goes on their mount while auto-run is active and the right mouse button is being pressed
- ~'::
- ; Toggled boolean variable that becomes true when mounting up
- isMountUpAction := !isMountUpAction
- ; This is for when the player actually mounts up and is physically pressing the right mouse button but not the left mouse button (aka the situation where the bug happens)
- if (isMountUpAction and GetKeyState("RButton", "P") and !GetKeyState("LButton", "P"))
- {
- shouldUsePostponableHotkeys := true
- Critical
- ; The best cursor placement to have when the mouse buttons are no longer pressed and the center of the screen also guarantees the code to work
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- halfWindowWidth := windowWidth / 2
- halfWindowHeight := windowHeight / 2
- ; This is also necessary to make the original bugfix work and a high sleep time helps the user with regaining camera control automatically
- Send, {RButton up}
- Sleep, 100
- ; Press both mouse buttons (prevents auto-run from being stopped accidentally later on and this also makes wiggling the camera possible)
- Send, {Click %halfWindowWidth% %halfWindowHeight% Down}{RButton down}
- ; Wiggling camera to make mouse movement work when the mouse gets controlled by the user and holding both mouse buttons for atleast 50 milliseconds longer
- WiggleCamera()
- Sleep, 50
- ; Executes code for physical mouse button state combinations (when both mouse buttons are physically pressed then it'll simply return without releasing them)
- if (!GetKeyState("LButton", "P") and GetKeyState("RButton", "P"))
- {
- ; Release left mouse button and use auto-run instead
- Send, {LButton up}
- Send, {r}
- }
- else if (!GetKeyState("LButton", "P") and !GetKeyState("RButton", "P"))
- ; Releases both mouse buttons
- Send, {LButton up}{RButton up}
- shouldUsePostponableHotkeys := false
- }
- return
- ; The hotkeys below can be made postponable but aren't by default so that they work faster whenever possible (set the shouldUsePostponableHotkeys boolean to false when you're done using it)
- #If (WinActive("Guild Wars 2") and !shouldUsePostponableHotkeys)
- ~LButton::OnLButton()
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- ; The hotkeys below can be made postponable by setting the shouldUsePostponableHotkeys boolean to true
- #If (WinActive("Guild Wars 2") and shouldUsePostponableHotkeys)
- 4::Send, {4}
- LButton::
- Send, {LButton}
- OnLButton()
- return
- RButton::Send, {RButton}
- w::Send, {w}
- a::Send, {a}
- s::Send, {s}
- d::Send, {d}
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 7/10/24 >> [DONE]GW2 BUG TEST RESULTS AND NEW PROPOSED FIX.txt:
- I held left-button pressed, auto-run enabled (no AHK script running ofc)
- and then pressed mount-key, screen-face direction stayed the same but mount ran to the right [no mousemove blocking necessary either! and no need for postponing via mousehook!]
- it would be better if "LMB down, LMB up, RMB down & RMB up" get postponed instead of blocked
- don't need mousehook for blocking e.g. if the user had something pressed beforehand and released while blocking, it'd get stuck
- /
- // IF THIS LOOKS UGLY THEN I CAN TRY TO TEMPORARILY HIDE THE CURSOR WHEN IT GETS MOVED PROGRAMMATICALLY (but first try w/ SendInput + "A_KeyDelay := -1" in case it reverts to SendEvent)
- mouse in gw2 is only used for manual-run, activating chat and clicking some icons, it does not matter when it's slightly slower than usual due to a LButton hotkey (nor due to a mousehook)
- so on LButton hotkey it can check if the mount-up icon is clicked > block LMB down, LMB up, RMB down & RMB up > send CURSOR move w/ pos argument being a bit to the right of the icon
- > send RMB down > send mount-up key > sleep > send RMB up > send CURSOR move w/ pos argument being where it originally was (on icon) > unblock the mouse buttons
- | >>> [unmounts automatically when in water, death, logged-out.. DETECT THE MOUNT-DOWN ICON PIXEL!!!]
- USE `#HotIf (WinActive(gw2))` TO REMEMBER WHEN THE CHAT IS MADE ACTIVE/INACTIVE //AND TO REMEMBER IF THE CHARACTER IS MOUNTED-UP, WHEN MOUNTED-UP THEN NATIVELY MOUNT-DOWN IN LMB & ' HOTKEY
- THE CHAT CAN USE THE MOUNT-UP KEY (') WHICH OFC JUST NEEDS TO BE TEXT, SO I ALSO NEED TO CHECK IF THE CHAT HAS BEEN MADE ACTIVE/INACTIVE VIA CLICK OR ENTER, OR MADE INACTIVE VIA ESCAPE
- ON MOUNT-UP KEY:
- don't need mousehook for blocking this will continue auto-run in the screen-faced direction (there is no way to use the character-faced direction)
- if only LMB is active / /
- then assume auto-run is on > block LMB down, LMB up, RMB down & RMB up > send LMB up > send RMB down > send mount-up key > sleep > send RMB up > send LMB down > unblock the mouse buttons
- /
- otherwise it will stop auto-run (if it was enabled). can't send LMB + RMB, and then auto-run w/o knowing that it was on
- don't need mousehook for blocking
- else if LMB nor RMB is active /
- block LMB down, LMB up, RMB down & RMB up > send CURSOR move w/ pos argument being x: A_ScreenWidth, y: 0 ̶A̶_̶S̶c̶r̶e̶e̶n̶H̶e̶i̶g̶h̶t̶ ̶/̶ ̶2 (seems like a safe zone w/o windows) > send RMB down
- > send mount-up key > sleep > send RMB up > send CURSOR move w/ pos argument being where it originally was > unblock the mouse buttons
- ELSE (if RMB is active, or in other words: if only RMB is active or both LMB and RMB is active)
- just send mount-up key (in theory it should be fine, this seems like all it rly needs)
- [I DON'T THINK THIS HAS THE ISSUE, ESPECIALLY WHEN THE 'ONLY-LMB-ACTIVE' SOLUTION WORKS, B/C IT USES RMB....]
- if only RMB is active (not sure if this has the issue but if it does, then use the following solution)
- then assume auto-run is on >
- [I DON'T THINK THIS HAS THE ISSUE, ESPECIALLY WHEN THE 'ONLY-LMB-ACTIVE' SOLUTION WORKS, B/C IT USES RMB....]
- if both LMB & RMB are active (not sure if this has the issue but if it does, then use the following solution)
- know that manual-run is on >
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 7/12/24 >> _______________AHKv2 Guild Wars 2 Auto-Fly (MOVED INTO MAIN FILE BUT NOT THE COMMENT AT THE TOP).ahk:
- ;NOTE: since the fly process will take a long time, the temporary key duration will stay on 500ms for a long time.. so I might need to temporarily change it back to -1 in other functions!
- #Requires AutoHotkey 2.0
- A_KeyDelay := -1 ; For Send b/c it reverts to the Event SendMode when another AHK script installs a native low-level keyboard/mouse hook
- /* TODO:
- pause depleted-fly-energy mode when chat gets opened
- resume either sufficient-fly-energy mode or depleted-fly-energy mode when chat gets closed
- pause sufficient-fly-energy mode when "s" gets pressed and chat isn't open and then execute Send("s down") instead
- resume sufficient-fly-energy mode when "w" gets pressed and chat isn't open
- pause depleted-fly-energy mode when "s" gets pressed
- resume depleted-fly-energy mode when "w" gets pressed
- when auto-fly stops, then release whichever key remained pressed if sufficient-fly-energy mode was active, if "w" remained pressed then it should auto-run instead
- */
- ; Auto-Fly (required resolution: Full Screen - 2560 x 1440)
- ~Space::
- {
- Sleep(500)
- if (DetermineFlyStatus())
- {
- keyDurationPrevious := SetKeyDelay(, 500)
- isFlyEnergyDepleted := false
- Send("{w down}")
- loop
- {
- if (DetermineFlyStatus())
- {
- if (isFlyEnergyDepleted)
- SendEvent("w")
- else if (PixelGetColor(1270, 1230) = 0x181B18)
- isFlyEnergyDepleted := true
- else
- Sleep(50)
- }
- else
- break
- }
- A_KeyDuration := keyDurationPrevious
- }
- DetermineFlyStatus() => PixelGetColor(1111, 1230) = 0x764E1B && PixelGetColor(1455, 1230) = 0xAA6404
- }
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 4/21/24 >> AHKv2 Guild Wars 2 - backup containing some old code.ahk:
- #Requires AutoHotkey 2.0
- F12::Reload() ;FOR TESTING
- ; Any attempt to launch this script when it's already running will reload it (the dialog box that normally appears in this situation gets skipped)
- #SingleInstance Force
- A_KeyDelay := -1 ; For Send b/c it reverts to the Event SendMode when another AHK script installs a low-level keyboard hook
- A_MouseDelay := -1 ; For sending a left- or right-click with Send b/c it reverts to the Event SendMode when another AHK script installs a low-level keyboard hook
- AutoRun := {IsActive: false} ; Ad hoc object, usable w/ dot notation (no need for class)
- HotIfWinActive("ahk_exe Gw2-64.exe")
- ;Run("C:\Program Files\Guild Wars 2\Gw2-64.exe")
- EVENT_OBJECT_CREATE := 0x8000
- ;DllCall("SetWinEventHook", "UInt", EVENT_OBJECT_CREATE, "UInt", EVENT_OBJECT_CREATE, "Ptr", 0, "Ptr", CallbackCreate(HandleGuildWars2Event), "UInt", 0, "UInt", 0, "UInt", 0)
- ;ManageApp() ; Terminates the macro when the game window doesn't exist any longer and wasn't being restarted either (keep this at the bottom of the auto-execute section)
- #HotIf (WinActive("ahk_exe Gw2-64.exe"))
- ; To hide the OSD
- Volume_Up::SoundSetVolume("+2")
- Volume_Down::SoundSetVolume("-2")
- ~w::
- ~s::AutoRun.IsActive := false
- ~r::AutoRun.IsActive := !AutoRun.IsActive
- $F3::
- F4::LButtonAboutFace("F3") ; Keep LButton pressed (not RButton) when using About Face if you need to keep the enemy targeted (otherwise you'll lose the target, but can't be automated)
- $'::return ; Mount-up hotkey
- LButton:: ; Necessary when making a `LButton up` hotkey (but I was gonna use this for chat and mount-up click detection anyway)
- {
- Send("{LButton down}")
- if (GetKeyState("RButton"))
- AutoRun.IsActive := false
- }
- ; Serves mainly as a postponeable hotkeys
- LButton up::Send("{LButton up}") ; Necessary when making a `LButton` hotkey (but I needed this to be postponeable anyway)
- RButton::
- {
- Send("{RButton down}")
- if (GetKeyState("LButton"))
- AutoRun.IsActive := false
- }
- RButton up::Send("{RButton up}")
- ;********** LIBRARY **********
- ; This will remove the HDR flickering issue when the gw2 launcher creates a fullscreen wnd
- HandleGuildWars2Event(hWinEventHook, event, hWnd, *)
- {
- try
- if (WinGetClass(hWnd) = "ArenaNet_Gr_Window_Class")
- {
- WinSetTransparent(0, hWnd)
- Sleep(2000)
- WinSetTransparent("Off", hWnd)
- }
- }
- ; Terminates the macro if the game doesn't restart itself within 30 seconds. And also has recursive code, which restarts this method each time the game crashes and immediately restarts
- ManageApp()
- {
- if (WinWait("ahk_exe Gw2-64.exe",, 30))
- {
- WinWaitClose()
- ManageApp()
- }
- else
- ExitApp()
- }
- ; [EVEN BETTER SOLUTION TO MAKE AboutFace ROTATE RELIABLY; by programmatically holding LButton and "w" pressed while fnKey is send]
- ; [actually, I think you can even fix the issue where AboutFace doesn't rotate; by programmatically holding RButton pressed while it does the camera wiggle. Before the fnKey is send ofc]
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(fnKey)
- {
- Hotkey("$4", (*) => Send("4"), "On") ; Makes it postponeable
- Critical()
- if (!GetKeyState("LButton") && GetKeyState("RButton")) ; With RButton down, that means the cursor is already in a safe spot
- {
- ; This prevents About Face from doing nothing
- if (!AutoRun.IsActive)
- Send("r")
- ; Holds the LButton pressed down while it sends the fn key (the following keeps auto-run: {LButton down} + {RButton down} = manual run + camera rotating along with the character)
- Send("{RButton up}{LButton down}{" fnKey "}{LButton up}") ; is prevented
- if (!AutoRun.IsActive)
- Sleep(40), Send("r")
- ; Delay logically pressing RButton down again to prevent the camera from turning 180 degrees
- Sleep(525)
- A_CoordModeMouse := "Screen"
- MouseGetPos(&startCursorX, &startCursorY)
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- while (GetKeyState("RButton", "P"))
- {
- static cursorMoveThreshold := 10
- MouseGetPos(&cursorX, &cursorY)
- if
- (
- cursorX < startCursorX - cursorMoveThreshold ||
- cursorX > startCursorX + cursorMoveThreshold ||
- cursorY < startCursorY - cursorMoveThreshold ||
- cursorY > startCursorY + cursorMoveThreshold
- )
- {
- Send("{RButton down}")
- break
- }
- Sleep(10)
- }
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- ;if (GetKeyState("RButton", "P"))
- ;Send("{RButton down}")
- }
- else if (!GetKeyState("LButton")) ; No mouse buttons are being pressed down, that means the cursor might be in an unsafe spot! So watch out for that when using the About Face fn key
- {
- ; This prevents About Face from doing nothing
- if (!AutoRun.IsActive)
- Send("r")
- ; Makes it postponeable
- ;Hotkey("$RButton", (*) => Send("{RButton down}"), "On")
- ;Hotkey("$RButton up", (*) => Send("{RButton up}"), "On")
- ; Holds the LButton pressed down (whether it's in a safe spot or not, moving the cursor programmatically looks bad so I'm skipping that) while it sends the fn key
- Send("{LButton down}{" fnKey "}{LButton up}")
- if (!AutoRun.IsActive)
- Sleep(40), Send("r")
- ; Postpone any RButton down presses that might occur, to prevent the camera from turning 180 degrees
- Sleep(525)
- ;SetTimer((*) => (Hotkey("$RButton", "Off"), Hotkey("$RButton up", "Off")), -1)
- }
- else
- {
- ; This prevents About Face from doing nothing
- if (!AutoRun.IsActive)
- Send("r")
- Send("{" fnKey "}")
- if (!AutoRun.IsActive)
- Sleep(40), Send("r")
- }
- SetTimer((*) => Hotkey("$4", "Off"), -1) ; Makes it use the faster native fn instead of being postponeable (after any postponed ones have been sent)
- }
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 5/28/24 >> AHKv2 Guild Wars 2 - backup from right before I added the mount-up and auto-fly feature.ahk:
- #Requires AutoHotkey 2.0
- F12::Reload() ;FOR TESTING (MIGHT ALSO HAVE COMMENTED-OUT THE `Run` & `ManageApp` BELOW, UNCOMMENT THEM WHEN EVERYTHING WORKS)
- ; Any attempt to launch this script when it's already running will reload it (the dialog box that normally appears in this situation gets skipped)
- #SingleInstance Force
- ; To make it work when the active gw2 window is elevated
- if (!InStr(A_AhkPath, "_UIA.exe"))
- {
- Run("*UIAccess " A_ScriptFullPath)
- ExitApp()
- }
- A_HotkeyInterval := 0 ; To disable the warning dialog (can otherwise appear when a hotkey was being pressed down for too long while being postponed)
- A_CoordModeMouse := "Screen"
- A_KeyDelay := -1, A_KeyDuration := -1, A_MouseDelay := -1 ; For Send b/c it reverts to the Event SendMode when another AHK script installs a native low-level keyboard/mouse hook
- autoRun := {IsActive: false} ; Ad hoc object, usable w/ dot notation (no need for class)
- HotIfWinActive("ahk_exe Gw2-64.exe") ; For hotkeys that are created at runtime
- ; To remove blue flickering at startup, the gw2 exe properties are set to both compatibility mode "Windows Vista (Service Pack 2)" and settings "Run this program as an administrator".
- ; This cmd runs an admin task that's added to Task Scheduler w/ start program action "%ProgramFiles%\Guild Wars 2\Gw2-64.exe", so there won't be an elevation prompt every time you start gw2
- Run("schtasks /run /tn `"Guild Wars 2`"",, "Hide")
- ManageApp() ; Terminates the macro when the game window doesn't exist any longer and wasn't being restarted either (keep this at the bottom of the auto-execute section)
- #HotIf (WinActive("ahk_exe Gw2-64.exe"))
- ; To hide the OSD
- Volume_Up::SoundSetVolume("+2")
- Volume_Down::SoundSetVolume("-2")
- ~w::
- ~s::autoRun.IsActive := false
- ~r::autoRun.IsActive := !autoRun.IsActive
- $F3::
- F4::LButtonAboutFace("F3") ; Keep LButton pressed (not RButton) when using About Face if you need to keep the enemy targeted (otherwise you'll lose the target, but rly can't be automated)
- ; ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
- $'::return ; Mount-up hotkey
- LButton:: ; TODO: add chat and mount-up click detection
- {
- Send("{LButton down}")
- if (GetKeyState("RButton"))
- autoRun.IsActive := false
- }
- ; These serve mainly as postponeable hotkeys (and apparently you cannot make a btn-down hotkey w/o making a btn-up hotkey, and vice versa)
- LButton up::Send("{LButton up}")
- RButton::
- {
- Send("{RButton down}")
- if (GetKeyState("LButton"))
- autoRun.IsActive := false
- }
- RButton up::Send("{RButton up}")
- ;********** LIBRARY **********
- /*
- If compatibility mode + admin doesn't reliably remove blue flickering at startup, then use this instead:
- EVENT_OBJECT_CREATE := 0x8000
- DllCall("SetWinEventHook", "UInt", EVENT_OBJECT_CREATE, "UInt", EVENT_OBJECT_CREATE, "Ptr", 0, "Ptr", CallbackCreate(HandleGuildWars2Event), "UInt", 0, "UInt", 0, "UInt", 0)
- */
- ; This will remove the blue flickering issue when the gw2 launcher creates a fullscreen wnd
- HandleGuildWars2Event(hWinEventHook, event, hWnd, *)
- {
- try
- if (WinGetClass(hWnd) = "ArenaNet_Gr_Window_Class")
- {
- WinSetTransparent(0, hWnd)
- Sleep(2050)
- WinSetTransparent("Off", hWnd)
- }
- }
- ; Terminates the macro if the game doesn't restart itself within 30 seconds. And also has recursive code, which restarts this method each time the game crashes and immediately restarts
- ManageApp()
- {
- if (WinWait("ahk_exe Gw2-64.exe",, 30))
- {
- WinWaitClose()
- ManageApp()
- }
- else
- ExitApp()
- }
- ; Uses the About Face feature without unintentionally turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(fnKey)
- {
- static cursorMoveThreshold := 5
- Hotkey("$4", (*) => Send("4"), "On") ; Makes it postponeable
- Critical()
- if (!GetKeyState("LButton") && GetKeyState("RButton")) ; With RButton down, that means the cursor is already in a safe spot
- {
- BlockInput("MouseMove")
- Send("{RButton up}")
- ; This prevents About Face from doing nothing
- if (!autoRun.IsActive)
- Send("r")
- ; Holds the LButton pressed down while it sends the fn key (the following stops auto-run: {LButton down} + {RButton down} = manual run + camera rotating along with the character)
- Send("{LButton down}{" fnKey "}{LButton up}")
- if (!autoRun.IsActive)
- Sleep(40), Send("r")
- ; Delay logically pressing RButton down again to prevent the camera from turning 180 degrees
- Sleep(525)
- BlockInput("MouseMoveOff")
- MouseGetPos(&startCursorX, &startCursorY)
- Critical("Off")
- Sleep(-1)
- SetTimer((*) => Hotkey("$4", "Off"), -1) ; Makes it use the faster native fn instead of being postponeable (after any postponed ones have been sent)
- Sleep(1)
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- while (GetKeyState("RButton", "P"))
- {
- MouseGetPos(&cursorX, &cursorY)
- if
- (
- GetKeyState("LButton", "P") ||
- cursorX < startCursorX - cursorMoveThreshold ||
- cursorX > startCursorX + cursorMoveThreshold ||
- cursorY < startCursorY - cursorMoveThreshold ||
- cursorY > startCursorY + cursorMoveThreshold
- )
- {
- Send("{RButton down}")
- return
- }
- Sleep(0)
- }
- }
- else if (!GetKeyState("LButton")) ; No mouse buttons are being pressed down, that means the cursor might be in an unsafe spot! So watch out for that when using the About Face fn key
- {
- ; This prevents About Face from doing nothing
- if (!autoRun.IsActive)
- Send("r")
- ; Holds the LButton pressed down (whether it's in a safe spot or not, moving the cursor programmatically looks bad so I'm skipping that) while it sends the fn key
- Send("{LButton down}{" fnKey "}{LButton up}")
- ; Postpone any RButton down presses that might occur, to prevent the camera from turning 180 degrees, and stop auto-run again if it was activated above
- if (autoRun.IsActive)
- Sleep(525)
- else
- Sleep(40), Send("r"), Sleep(485)
- }
- else if (!GetKeyState("RButton") && !autoRun.IsActive) ; This prevents About Face from doing nothing when merely LButton is pressed
- Send("r{" fnKey "}"), Sleep(40), Send("r")
- else ; When both LButton and RButton are being pressed down then there are no issues (it will intentionally rotate both the character and the camera)
- Send("{" fnKey "}")
- SetTimer((*) => Hotkey("$4", "Off"), -1) ; Makes it use the faster native fn instead of being postponeable (after any postponed ones have been sent)
- }
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 4/21/24 >> AHKv2 Guild Wars 2 - backup of minimumRepressDelay that somehow doesn't work in this code structure.ahk:
- #Requires AutoHotkey 2.0
- F12::Reload() ;FOR TESTING
- ; Any attempt to launch this script when it's already running will reload it (the dialog box that normally appears in this situation gets skipped)
- #SingleInstance Force
- A_HotkeyInterval := 0 ; To disable the warning dialog (can otherwise appear when a hotkey was being pressed down for too long while being postponed)
- A_CoordModeMouse := "Screen"
- A_KeyDelay := -1 ; For Send b/c it reverts to the Event SendMode when another AHK script installs a low-level keyboard hook
- A_MouseDelay := -1 ; For sending a left- or right-click with Send b/c it reverts to the Event SendMode when another AHK script installs a low-level keyboard hook
- autoRun := {IsActive: false} ; Ad hoc object, usable w/ dot notation (no need for class)
- aboutFace := {IsActive: false} ; Ad hoc object, usable w/ dot notation (no need for class)
- HotIfWinActive("ahk_exe Gw2-64.exe") ; For hotkeys that are created at runtime
- ;Run("C:\Program Files\Guild Wars 2\Gw2-64.exe")
- EVENT_OBJECT_CREATE := 0x8000
- ;DllCall("SetWinEventHook", "UInt", EVENT_OBJECT_CREATE, "UInt", EVENT_OBJECT_CREATE, "Ptr", 0, "Ptr", CallbackCreate(HandleGuildWars2Event), "UInt", 0, "UInt", 0, "UInt", 0)
- ;ManageApp() ; Terminates the macro when the game window doesn't exist any longer and wasn't being restarted either (keep this at the bottom of the auto-execute section)
- #HotIf (WinActive("ahk_exe Gw2-64.exe"))
- ; To hide the OSD
- Volume_Up::SoundSetVolume("+2")
- Volume_Down::SoundSetVolume("-2")
- ~w::
- ~s::autoRun.IsActive := false
- ~r::autoRun.IsActive := !autoRun.IsActive
- $F3::
- F4::LButtonAboutFace("F3") ; Keep LButton pressed (not RButton) when using About Face if you need to keep the enemy targeted (otherwise you'll lose the target, but rly can't be automated)
- ; ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
- $'::return ; Mount-up hotkey
- LButton:: ; Necessary when making a `LButton up` hotkey (but I was gonna use this for chat and mount-up click detection anyway)
- {
- Send("{LButton down}")
- if (GetKeyState("RButton"))
- autoRun.IsActive := false
- }
- ; These serve mainly as a postponeable hotkeys
- LButton up::Send("{LButton up}") ; Necessary when making a `LButton` hotkey (but I needed this to be postponeable anyway)
- RButton::
- {
- Send("{RButton down}")
- if (GetKeyState("LButton"))
- autoRun.IsActive := false
- }
- RButton up::Send("{RButton up}")
- ;********** LIBRARY **********
- ; This will remove the HDR flickering issue when the gw2 launcher creates a fullscreen wnd
- HandleGuildWars2Event(hWinEventHook, event, hWnd, *)
- {
- try
- if (WinGetClass(hWnd) = "ArenaNet_Gr_Window_Class")
- {
- WinSetTransparent(0, hWnd)
- Sleep(2050)
- WinSetTransparent("Off", hWnd)
- }
- }
- ; Terminates the macro if the game doesn't restart itself within 30 seconds. And also has recursive code, which restarts this method each time the game crashes and immediately restarts
- ManageApp()
- {
- if (WinWait("ahk_exe Gw2-64.exe",, 30))
- {
- WinWaitClose()
- ManageApp()
- }
- else
- ExitApp()
- }
- ; Uses the About Face feature without unintentionally turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(fnKey)
- {
- static cursorMoveThreshold := 5, minimumRepressDelay := 700 ;525
- if (aboutFace.IsActive)
- return
- else
- aboutFace.IsActive := true
- Hotkey("$4", (*) => Send("4"), "On") ; Makes it postponeable
- Critical()
- if (!GetKeyState("LButton") && GetKeyState("RButton")) ; With RButton down, that means the cursor is already in a safe spot
- {
- Send("{RButton up}")
- ; This prevents About Face from doing nothing
- if (!autoRun.IsActive)
- Send("r")
- ; Holds the LButton pressed down while it sends the fn key (the following stops auto-run: {LButton down} + {RButton down} = manual run + camera rotating along with the character)
- Send("{LButton down}{" fnKey "}{LButton up}")
- if (!autoRun.IsActive)
- Sleep(40), Send("r")
- ; Delay logically pressing RButton down again to prevent the camera from turning 180 degrees
- ;Sleep(525)
- startTime := A_TickCount
- MouseGetPos(&startCursorX, &startCursorY)
- Critical("Off")
- Sleep(-1)
- SetTimer((*) => Hotkey("$4", "Off"), -1) ; Makes it use the faster native fn instead of being postponeable (after any postponed ones have been sent)
- Sleep(1)
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- while (GetKeyState("RButton", "P"))
- {
- MouseGetPos(&cursorX, &cursorY)
- if
- (
- GetKeyState("LButton", "P") ||
- cursorX < startCursorX - cursorMoveThreshold ||
- cursorX > startCursorX + cursorMoveThreshold ||
- cursorY < startCursorY - cursorMoveThreshold ||
- cursorY > startCursorY + cursorMoveThreshold
- )
- {
- ; Delay logically pressing RButton down again to prevent the camera from turning 180 degrees
- if (!GetKeyState("LButton", "P") && (repressDelay := A_TickCount - startTime) < minimumRepressDelay)
- Sleep(repressDelay) ;, send("{enter}{sleep 500}A) " repressDelay)
- ;else
- ;send("{enter}{sleep 500}B) " repressDelay)
- ;return
- ;send("r{LButton down}") ; auto-run could've been off already at this point
- ;sleep(20)
- ;send("{LButton up}")
- ;sleep(20)
- Send("{RButton down}")
- ;sleep(20)
- ;send("r")
- aboutFace.IsActive := false
- return
- }
- Sleep(0)
- }
- }
- else if (!GetKeyState("LButton")) ; No mouse buttons are being pressed down, that means the cursor might be in an unsafe spot! So watch out for that when using the About Face fn key
- {
- ; This prevents About Face from doing nothing
- if (!autoRun.IsActive)
- Send("r")
- ; Holds the LButton pressed down (whether it's in a safe spot or not, moving the cursor programmatically looks bad so I'm skipping that) while it sends the fn key
- Send("{LButton down}{" fnKey "}{LButton up}")
- if (!autoRun.IsActive)
- Sleep(40), Send("r")
- ; Postpone any RButton down presses that might occur, to prevent the camera from turning 180 degrees
- Sleep(autoRun.IsActive ? minimumRepressDelay : minimumRepressDelay - 40)
- }
- else if (!GetKeyState("RButton") && !autoRun.IsActive) ; This prevents About Face from doing nothing when merely LButton is pressed
- Send("r{" fnKey "}"), Sleep(40), Send("r")
- else ; When both LButton and RButton are being pressed down then there are no issues (it will intentionally rotate both the character and the camera)
- Send("{" fnKey "}")
- SetTimer((*) => Hotkey("$4", "Off"), -1) ; Makes it use the faster native fn instead of being postponeable (after any postponed ones have been sent)
- aboutFace.IsActive := false
- }
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 4/22/24 >> desktop shortcut properties for AHKv1.txt:
- shortcut on desktop was set to
- target: "C:\Users\loren\Downloads\AutoHotkey\Guild Wars 2\Guild Wars 2 - NEW 5.ahk"
- start in: C:\Users\loren\Downloads\AutoHotKey
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 9/14/22 >> Guild Wars 2 - NEW 2 (backup containing some more code that didn't rly seem necessary).ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will be ignored (skips the dialog box and leaves the old instance running)
- #SingleInstance Ignore
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- ; The code below only executes for the Guild Wars 2 window
- #IfWinActive Guild Wars 2
- ; These hotkeys aren't needed straight away and can be turned on when any of these hotkeys actually need to be used
- HotKey, LButton, Off
- HotKey, RButton, Off
- ToggleHotkeys()
- {
- HotKey, v, Toggle
- HotKey, F3, Toggle
- HotKey, F4, Toggle
- HotKey, LButton, Toggle
- }
- ; Suspends hotkeys when making the input field of the chat active with the Enter key (and it will unsuspend the hotkeys when Enter is pressed again)
- Enter::
- ToggleHotkeys()
- Send, {Enter}
- return
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- SendEvent {Click -15 0 0 Relative}
- SendEvent {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- HotKey, RButton, On
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- SendEvent {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- HotKey, RButton, Off
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- HotKey, RButton, On
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- SendEvent {Click %initialCursorX% %initialCursorY% 0}
- HotKey, RButton, Off
- }
- }
- F3::
- F4::LButtonAboutFace("F3")
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- 4::Send, {4}
- '::
- useMountUpCode := !useMountUpCode ; Toggled boolean variable that becomes true when mounting up
- if (useMountUpCode)
- {
- if (GetKeyState("LButton", "P") and GetKeyState("RButton", "P")) ; IF physically pressed down both mouse buttons
- {
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- Send, {'} ; Mount up while the mouse buttons are still pressed in
- return
- }
- else if (GetKeyState("RButton", "P")) ; IF physically pressed down right mouse button
- {
- Send, {LButton up}{RButton up} ; Removes glitchy auto-run behaviour where it suddenly stops
- Sleep, 25 ; Removes glitchy auto-run behaviour where it suddenly stops
- Send, {LButton down}{RButton down} ; Press both mouse buttons (prevents stopping active auto-run permanently below by stopping it temporarily)
- WiggleCamera() ; Wiggling camera to make mouse movement work when the mouse gets controlled by the user
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- if (GetKeyState("LButton", "P") and GetKeyState("RButton", "P")) ; IF physically pressed down both mouse buttons
- Send, {'} ; Mount up while the mouse buttons are still pressed in
- else
- { ; ELSE executing code of this scope
- Send, {'} ; Mount up while the mouse buttons are still pressed in
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- Send, {LButton up} ; Release left mouse button
- Send, {r} ; Use auto-run instead
- }
- return
- }
- else ; ELSE
- {
- Send, {LButton down}{RButton down} ; Press both mouse buttons
- WiggleCamera() ; Wiggling camera to make mouse control work when done by the user
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- Send, {'} ; Mount up while the mouse buttons are still pressed in
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- if (GetKeyState("LButton", "P") and GetKeyState("RButton", "P")) ; IF physically pressed down both mouse buttons
- return ; Keep holding both mouse buttons
- else ; ELSE
- Send, {LButton up}{RButton up} ; Release both mouse buttons
- }
- }
- else
- Send, {'} ; Use default behaviour when mounting down
- return
- ; Left-click outside the chat area (when this hotkey gets enabled, is off by default) will unsuspend the disabled hotkeys as well, because they only need to stay disabled while chatting
- ~LButton::
- MouseGetPos, currentCursorX, currentCursorY
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleHotkeys()
- return
- ; The right mouse button can be manually disabled by turning this hotkey on
- RButton::return
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 9/15/22 >> Guild Wars 2 - NEW 2.ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will be ignored (skips the dialog box and leaves the old instance running)
- #SingleInstance Ignore
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- ; The code below only executes for the Guild Wars 2 window
- #IfWinActive Guild Wars 2
- ; These hotkeys aren't needed straight away and can be turned on when any of these hotkeys actually need to be used
- HotKey, LButton, Off
- HotKey, RButton, Off
- ToggleHotkeys()
- {
- HotKey, v, Toggle
- HotKey, F3, Toggle
- HotKey, F4, Toggle
- HotKey, LButton, Toggle
- }
- ; Suspends hotkeys when making the input field of the chat active with the Enter key (and it will unsuspend the hotkeys when Enter is pressed again)
- Enter::
- ToggleHotkeys()
- Send, {Enter}
- return
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- SendEvent {Click -15 0 0 Relative}
- SendEvent {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- HotKey, RButton, On
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- SendEvent {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- HotKey, RButton, Off
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- HotKey, RButton, On
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- SendEvent {Click %initialCursorX% %initialCursorY% 0}
- HotKey, RButton, Off
- }
- }
- F3::
- F4::LButtonAboutFace("F3")
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- 4::Send, {4}
- ; This fixes the bug where the character suddenly rotates in a random manner when the player goes on their mount while auto-run is active and the right mouse button is being pressed
- '::
- isMountUpAction := !isMountUpAction ; Toggled boolean variable that becomes true when mounting up
- if (isMountUpAction and GetKeyState("RButton", "P") and !GetKeyState("LButton", "P")) ; IF physically pressed down right mouse button but not left mouse button
- {
- Send, {LButton up}{RButton up} ; Removes glitchy auto-run behaviour where it suddenly stops
- Sleep, 25 ; Removes glitchy auto-run behaviour where it suddenly stops
- Send, {LButton down}{RButton down} ; Press both mouse buttons (prevents auto-run from being stopped accidentally later on)
- WiggleCamera() ; Wiggling camera to make mouse movement work when the mouse gets controlled by the user
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- if (GetKeyState("LButton", "P") and GetKeyState("RButton", "P")) ; IF physically pressed down both mouse buttons
- Send, {'} ; Mount up while the mouse buttons are still pressed in
- else
- { ; ELSE executing code of this scope
- Send, {'} ; Mount up while the mouse buttons are still pressed in
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- Send, {LButton up} ; Release left mouse button
- Send, {r} ; Use auto-run instead
- }
- }
- else
- Send, {'} ; Use default behaviour when mounting down and when other key state combinations are detected
- return
- ; Left-click outside the chat area (when this hotkey gets enabled, is off by default) will unsuspend the disabled hotkeys as well, because they only need to stay disabled while chatting
- ~LButton::
- MouseGetPos, currentCursorX, currentCursorY
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleHotkeys()
- return
- ; The right mouse button can be manually disabled by turning this hotkey on
- RButton::return
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 9/23/22 >> Guild Wars 2 - NEW 3 - Custom auto-run,-fly that doesn't work very well.ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will be ignored (skips the dialog box and leaves the old instance running)
- #SingleInstance Ignore
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- isChatActive := false
- isCustomAutoRunTemporarilyDisabled := false
- isCustomAutoRunEnabled := false
- ; These hotkeys aren't needed straight away and can be turned on when they need to be used (so here they get turned off as their default state)
- ToggleMovementHotkeys(true)
- HotKey, RButton, Off
- ; Runs the game and terminates the macro when the game window doesn't exist any longer (keep this at the bottom of the auto-execute section)
- ;RunWait, "C:\Program Files\Guild Wars 2\Gw2-64.exe"
- ;ExitApp
- LeftMouseButtonBaseAction(skipMovementHotkeysToggle := false)
- {
- Global
- if (GetKeyState("LButton", "P"))
- {
- Send, {LButton down}
- Loop, 5
- {
- if (GetKeyState("RButton", "P"))
- {
- isCustomAutoRunEnabled := false
- Send, {w up}
- if (!skipMovementHotkeysToggle)
- ToggleMovementHotkeys()
- Break
- }
- Sleep, 100
- }
- KeyWait, LButton
- Send, {LButton up}
- }
- else
- Send, {LButton}
- }
- ToggleChatState(shouldSendLButtonManually, shouldSendEnterManually)
- {
- Global
- if (isCustomAutoRunTemporarilyDisabled)
- {
- ; Closing the chat (LButton down is used sometimes and won't close the chat)
- Send, {Enter}
- if (shouldSendLButtonManually)
- LeftMouseButtonBaseAction(true)
- ; Use custom auto-run again if the method above didn't disable it
- if (isCustomAutoRunEnabled)
- {
- Send, {w up}
- Send, {w down}
- ToggleMovementHotkeys()
- isCustomAutoRunTemporarilyDisabled := false
- }
- }
- else if (isCustomAutoRunEnabled)
- {
- ; Use normal auto-run instead (temporarily)
- Send, {F10}
- ; Opening the chat (LButton is not necessary here)
- Send, {Enter}
- isCustomAutoRunTemporarilyDisabled := true
- ToggleMovementHotkeys()
- }
- else if (!shouldSendLButtonManually and shouldSendEnterManually)
- Send, {Enter}
- HotKey, r, Toggle
- HotKey, t, Toggle
- HotKey, v, Toggle
- isChatActive := !isChatActive
- }
- LeftMouseButtonAction(shouldSendLButtonManually)
- {
- Global
- MouseGetPos, currentCursorX, currentCursorY
- if (isChatActive)
- {
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleChatState(shouldSendLButtonManually, false)
- }
- else if (currentCursorX < 482 and currentCursorY > 1370)
- ToggleChatState(shouldSendLButtonManually, false)
- else if (shouldSendLButtonManually)
- LeftMouseButtonBaseAction()
- }
- ; The code below only executes for the Guild Wars 2 window when custom auto-run is enabled
- #If (WinActive("Guild Wars 2") and isCustomAutoRunEnabled)
- ; Left-click outside the chat area with an active chat input field and left-click inside an inactive chat input field both toggles the chat state of the macro as well
- LButton::LeftMouseButtonAction(true)
- ; The code below only executes for the Guild Wars 2 window when custom auto-run is disabled
- #If (WinActive("Guild Wars 2") and !isCustomAutoRunEnabled)
- ; Left-click outside the chat area with an active chat input field and left-click inside an inactive chat input field both toggles the chat state of the macro as well
- ~LButton::LeftMouseButtonAction(false)
- ; The code below only executes for the Guild Wars 2 window
- #If (WinActive("Guild Wars 2"))
- ; Prevents hotkey interference when the chat is being used and vice versa
- Enter::ToggleChatState(false, true)
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- Send, {Click -15 0 0 Relative}
- Send, {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- HotKey, RButton, On
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- HotKey, RButton, Off
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- HotKey, RButton, On
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- HotKey, RButton, Off
- }
- }
- F3::
- F4::LButtonAboutFace("F3")
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- 4::Send, {4}
- ToggleMovementHotkeys(skipCustomAutoRunHotkeys := false)
- {
- HotKey, w, Toggle
- HotKey, s, Toggle
- if (!skipCustomAutoRunHotkeys)
- {
- HotKey, r, Toggle
- HotKey, t, Toggle
- }
- }
- ; These movement hotkeys will also stop the custom auto-run effect
- ~w::
- isCustomAutoRunEnabled := false
- ToggleMovementHotkeys()
- return
- ~s::
- isCustomAutoRunEnabled := false
- Send, {w up}
- ToggleMovementHotkeys()
- return
- r::
- t::
- ; This will prevent the forward movement hotkey action (one that might've been done earlier in this frame or an older frame), to cause this auto-run action not to work
- if (GetKeyState("w") or GetKeyState("w", "P"))
- {
- KeyWait, w
- Sleep, 500
- }
- ;else ; this code below doesn't fix 2..* restarts, and doesn't seem to matter what I try..
- {
- Send, {w up}
- Sleep, 200
- Send, {w down}
- Sleep, 300
- Send, {w up}
- Sleep, 200
- ;Send, {w}
- ;Send, {s}
- ;Send, {s down}
- ;Sleep, 500
- ;Send, {s up}
- }
- Send, {w down}
- if (isCustomAutoRunEnabled)
- ToggleMovementHotkeys()
- isCustomAutoRunEnabled := true
- return
- ; This fixes the bug where the character suddenly rotates in a random manner when the player goes on their mount while auto-run is active and the right mouse button is being pressed
- ~'::
- ; Toggled boolean variable that becomes true when mounting up
- isMountUpAction := !isMountUpAction
- ; This is for when the player actually mounts up and is physically pressing the right mouse button but not the left mouse button (aka the situation where the bug happens)
- if (isMountUpAction and GetKeyState("RButton", "P") and !GetKeyState("LButton", "P"))
- {
- ; The best cursor placement to have when the mouse buttons are no longer pressed and the center of the screen also guarantees the code to work
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- halfWindowWidth := windowWidth / 2
- halfWindowHeight := windowHeight / 2
- ; This is also necessary to make the original bugfix work and a high sleep time helps the user with regaining camera control automatically
- Send, {RButton up}
- Sleep, 100
- ; Press both mouse buttons (prevents auto-run from being stopped accidentally later on and this also makes wiggling the camera possible)
- Send, {Click %halfWindowWidth% %halfWindowHeight% Down}{RButton down}
- ; Wiggling camera to make mouse movement work when the mouse gets controlled by the user and holding both mouse buttons for atleast 50 milliseconds longer
- WiggleCamera()
- Sleep, 50
- ; Executes code for physical mouse button state combinations (when both mouse buttons are physically pressed then it'll simply return without releasing them)
- if (!GetKeyState("LButton", "P") and GetKeyState("RButton", "P"))
- {
- ; Release left mouse button and use auto-run instead
- Send, {LButton up}
- Send, {r}
- }
- else if (!GetKeyState("LButton", "P") and !GetKeyState("RButton", "P"))
- ; Releases both mouse buttons
- Send, {LButton up}{RButton up}
- }
- return
- ; The right mouse button can be manually disabled by turning this hotkey on
- RButton::return
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 9/19/22 >> Guild Wars 2 - NEW 3 - SetTimer.ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will be ignored (skips the dialog box and leaves the old instance running)
- #SingleInstance Ignore
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- Run, "C:\Program Files\Guild Wars 2\Gw2-64.exe"
- ; Terminates the macro when the game window doesn't exist any longer
- TerminateAutomatically()
- {
- if (!WinExist("Guild Wars 2"))
- ExitApp
- }
- ; Checks every 10 minutes if the macro can be terminated and invokes the method when it can
- SetTimer, TerminateAutomatically, 600000
- ; The code below only executes for the Guild Wars 2 window
- #IfWinActive Guild Wars 2
- ; This hotkey isn't needed straight away and can be turned on when it needs to be used
- HotKey, RButton, Off
- ToggleChatState()
- {
- HotKey, v, Toggle
- global isChatActive := !isChatActive
- }
- ; Prevents hotkey interference when the chat is being used
- ~Enter::ToggleChatState()
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- Send, {Click -15 0 0 Relative}
- Send, {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- HotKey, RButton, On
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- HotKey, RButton, Off
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- HotKey, RButton, On
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- HotKey, RButton, Off
- }
- }
- F3::
- F4::LButtonAboutFace("F3")
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- 4::Send, {4}
- ; This fixes the bug where the character suddenly rotates in a random manner when the player goes on their mount while auto-run is active and the right mouse button is being pressed
- ~'::
- ; Toggled boolean variable that becomes true when mounting up
- isMountUpAction := !isMountUpAction
- ; This is for when the player actually mounts up and is physically pressing the right mouse button but not the left mouse button (aka the situation where the bug happens)
- if (isMountUpAction and GetKeyState("RButton", "P") and !GetKeyState("LButton", "P"))
- {
- ; The best cursor placement to have when the mouse buttons are no longer pressed and the center of the screen also guarantees the code to work
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- halfWindowWidth := windowWidth / 2
- halfWindowHeight := windowHeight / 2
- ; This is also necessary to make the original bugfix work and a high sleep time helps the user with regaining camera control automatically
- Send, {RButton up}
- Sleep, 100
- ; Press both mouse buttons (prevents auto-run from being stopped accidentally later on and this also makes wiggling the camera possible)
- Send, {Click %halfWindowWidth% %halfWindowHeight% Down}{RButton down}
- ; Wiggling camera to make mouse movement work when the mouse gets controlled by the user and holding both mouse buttons for atleast 50 milliseconds longer
- WiggleCamera()
- Sleep, 50
- ; Executes code for physical mouse button state combinations (when both mouse buttons are physically pressed then it'll simply return without releasing them)
- if (!GetKeyState("LButton", "P") and GetKeyState("RButton", "P"))
- {
- ; Release left mouse button and use auto-run instead
- Send, {LButton up}
- Send, {r}
- }
- else if (!GetKeyState("LButton", "P") and !GetKeyState("RButton", "P"))
- ; Releases both mouse buttons
- Send, {LButton up}{RButton up}
- }
- return
- ; Left-click outside the chat area with an active chat input field and left-click inside an inactive chat input field both toggles the chat state of the macro as well
- ~LButton::
- MouseGetPos, currentCursorX, currentCursorY
- if (isChatActive)
- {
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleChatState()
- }
- else if (currentCursorX < 482 and currentCursorY > 1370)
- ToggleChatState()
- return
- ; The right mouse button can be manually disabled by turning this hotkey on
- RButton::return
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 10/11/22 6:44 PM >> Guild Wars 2 - NEW 3.ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will reload it (the dialog box that normally appears in this situation gets skipped)
- #SingleInstance Force
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- ; This hotkey isn't needed straight away and can be turned on when it needs to be used
- HotKey, RButton, Off
- ; Terminates the macro if the game doesn't restart itself within 30 seconds. And also has recursive code, which restarts this method each time the game crashes and immediately restarts
- ManageApp()
- {
- WinWait, Guild Wars 2,, 30
- if (ErrorLevel == 1)
- ExitApp
- else
- {
- WinWaitClose
- ManageApp()
- }
- }
- ; Runs the game and terminates the macro when the game window doesn't exist any longer and wasn't being restarted either (keep this at the bottom of the auto-execute section)
- RunWait, "C:\Program Files\Guild Wars 2\Gw2-64.exe"
- ManageApp()
- ; The code below only executes for the Guild Wars 2 window
- #IfWinActive Guild Wars 2
- ToggleChatState()
- {
- HotKey, v, Toggle
- global isChatActive := !isChatActive
- }
- ; Prevents hotkey interference when the chat is being used
- ~Enter::ToggleChatState()
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- Send, {Click -15 0 0 Relative}
- Send, {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- HotKey, RButton, On
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- HotKey, RButton, Off
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- HotKey, RButton, On
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- HotKey, RButton, Off
- }
- }
- F3::
- F4::LButtonAboutFace("F3")
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- 4::Send, {4}
- ; This fixes the bug where the character suddenly rotates in a random manner when the player goes on their mount while auto-run is active and the right mouse button is being pressed
- ~'::
- ; Toggled boolean variable that becomes true when mounting up
- isMountUpAction := !isMountUpAction
- ; This is for when the player actually mounts up and is physically pressing the right mouse button but not the left mouse button (aka the situation where the bug happens)
- if (isMountUpAction and GetKeyState("RButton", "P") and !GetKeyState("LButton", "P"))
- {
- Critical
- ; The best cursor placement to have when the mouse buttons are no longer pressed and the center of the screen also guarantees the code to work
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- halfWindowWidth := windowWidth / 2
- halfWindowHeight := windowHeight / 2
- ; This is also necessary to make the original bugfix work and a high sleep time helps the user with regaining camera control automatically
- Send, {RButton up}
- Sleep, 100
- ; Press both mouse buttons (prevents auto-run from being stopped accidentally later on and this also makes wiggling the camera possible)
- Send, {Click %halfWindowWidth% %halfWindowHeight% Down}{RButton down}
- ; Wiggling camera to make mouse movement work when the mouse gets controlled by the user and holding both mouse buttons for atleast 50 milliseconds longer
- WiggleCamera()
- Sleep, 50
- ; Executes code for physical mouse button state combinations (when both mouse buttons are physically pressed then it'll simply return without releasing them)
- if (!GetKeyState("LButton", "P") and GetKeyState("RButton", "P"))
- {
- ; Release left mouse button and use auto-run instead
- Send, {LButton up}
- Send, {r}
- }
- else if (!GetKeyState("LButton", "P") and !GetKeyState("RButton", "P"))
- ; Releases both mouse buttons
- Send, {LButton up}{RButton up}
- }
- return
- ; Left-click outside the chat area with an active chat input field and left-click inside an inactive chat input field both toggles the chat state of the macro as well
- ~LButton::
- MouseGetPos, currentCursorX, currentCursorY
- if (isChatActive)
- {
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleChatState()
- }
- else if (currentCursorX < 482 and currentCursorY > 1370)
- ToggleChatState()
- return
- ; The right mouse button can be manually disabled by turning this hotkey on
- RButton::return
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 10/11/22 7:33 PM >> Guild Wars 2 - NEW 4 (backup containing some more code that didn't rly seem necessary).ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will reload it (the dialog box that normally appears in this situation gets skipped)
- #SingleInstance Force
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- ; Terminates the macro if the game doesn't restart itself within 30 seconds. And also has recursive code, which restarts this method each time the game crashes and immediately restarts
- ManageApp()
- {
- WinWait, Guild Wars 2,, 30
- if (ErrorLevel == 1)
- ExitApp
- else
- {
- WinWaitClose
- ManageApp()
- }
- }
- ; Runs the game and terminates the macro when the game window doesn't exist any longer and wasn't being restarted either (keep this at the bottom of the auto-execute section)
- RunWait, "C:\Program Files\Guild Wars 2\Gw2-64.exe"
- ManageApp()
- ; The code below only executes for the Guild Wars 2 window
- #If (WinActive("Guild Wars 2"))
- ToggleChatState()
- {
- HotKey, v, Toggle
- global isChatActive := !isChatActive
- }
- ; Prevents hotkey interference when the chat is being used
- ~Enter::ToggleChatState()
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- Send, {Click -15 0 0 Relative}
- Send, {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- shouldDisableRButton := true
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- shouldDisableRButton := false
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- shouldDisableRButton := true
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- shouldDisableRButton := false
- }
- }
- F3::
- F4::LButtonAboutFace("F3")
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- 4::Send, {4}
- w::Send, {w}
- a::Send, {a}
- s::Send, {s}
- d::Send, {d}
- ; This fixes the bug where the character suddenly rotates in a random manner when the player goes on their mount while auto-run is active and the right mouse button is being pressed
- ~'::
- ; Toggled boolean variable that becomes true when mounting up
- isMountUpAction := !isMountUpAction
- ; This is for when the player actually mounts up and is physically pressing the right mouse button but not the left mouse button (aka the situation where the bug happens)
- if (isMountUpAction and GetKeyState("RButton", "P") and !GetKeyState("LButton", "P"))
- {
- Critical
- ; The best cursor placement to have when the mouse buttons are no longer pressed and the center of the screen also guarantees the code to work
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- halfWindowWidth := windowWidth / 2
- halfWindowHeight := windowHeight / 2
- ; This is also necessary to make the original bugfix work and a high sleep time helps the user with regaining camera control automatically
- Send, {RButton up}
- Sleep, 100
- ; Press both mouse buttons (prevents auto-run from being stopped accidentally later on and this also makes wiggling the camera possible)
- Send, {Click %halfWindowWidth% %halfWindowHeight% Down}{RButton down}
- ; Wiggling camera to make mouse movement work when the mouse gets controlled by the user and holding both mouse buttons for atleast 50 milliseconds longer
- WiggleCamera()
- Sleep, 50
- ; Executes code for physical mouse button state combinations (when both mouse buttons are physically pressed then it'll simply return without releasing them)
- if (!GetKeyState("LButton", "P") and GetKeyState("RButton", "P"))
- {
- ; Release left mouse button and use auto-run instead
- Send, {LButton up}
- Send, {r}
- }
- else if (!GetKeyState("LButton", "P") and !GetKeyState("RButton", "P"))
- ; Releases both mouse buttons
- Send, {LButton up}{RButton up}
- }
- return
- ; Left-click outside the chat area with an active chat input field and left-click inside an inactive chat input field both toggles the chat state of the macro as well
- ~LButton::
- MouseGetPos, currentCursorX, currentCursorY
- if (isChatActive)
- {
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleChatState()
- }
- else if (currentCursorX < 482 and currentCursorY > 1370)
- ToggleChatState()
- return
- #If (WinActive("Guild Wars 2") and !shouldDisableRButton)
- ; This postpones the right mouse button when an uninterruptible function is being executed (default behaviour)
- RButton::Send, {RButton}
- #If (WinActive("Guild Wars 2") and shouldDisableRButton)
- ; The right mouse button can be manually disabled by turning this hotkey on with the shouldDisableRButton boolean
- RButton::return
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 10/11/22 7:52 PM >> Guild Wars 2 - NEW 4 (backup of a slower alternative bc ~ symbol isn't used for postponable hotkeys LMB RMB WASD).ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will reload it (the dialog box that normally appears in this situation gets skipped)
- #SingleInstance Force
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- ; Terminates the macro if the game doesn't restart itself within 30 seconds. And also has recursive code, which restarts this method each time the game crashes and immediately restarts
- ManageApp()
- {
- WinWait, Guild Wars 2,, 30
- if (ErrorLevel == 1)
- ExitApp
- else
- {
- WinWaitClose
- ManageApp()
- }
- }
- ; Runs the game and terminates the macro when the game window doesn't exist any longer and wasn't being restarted either (keep this at the bottom of the auto-execute section)
- RunWait, "C:\Program Files\Guild Wars 2\Gw2-64.exe"
- ManageApp()
- ; The code below only executes for the Guild Wars 2 window
- #If (WinActive("Guild Wars 2"))
- ToggleChatState()
- {
- HotKey, v, Toggle
- global isChatActive := !isChatActive
- }
- ; Prevents hotkey interference when the chat is being used
- ~Enter::ToggleChatState()
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- Send, {Click -15 0 0 Relative}
- Send, {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- }
- }
- F3::
- F4::LButtonAboutFace("F3")
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- 4::Send, {4}
- RButton::Send, {RButton}
- w::Send, {w}
- a::Send, {a}
- s::Send, {s}
- d::Send, {d}
- ; This fixes the bug where the character suddenly rotates in a random manner when the player goes on their mount while auto-run is active and the right mouse button is being pressed
- ~'::
- ; Toggled boolean variable that becomes true when mounting up
- isMountUpAction := !isMountUpAction
- ; This is for when the player actually mounts up and is physically pressing the right mouse button but not the left mouse button (aka the situation where the bug happens)
- if (isMountUpAction and GetKeyState("RButton", "P") and !GetKeyState("LButton", "P"))
- {
- Critical
- ; The best cursor placement to have when the mouse buttons are no longer pressed and the center of the screen also guarantees the code to work
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- halfWindowWidth := windowWidth / 2
- halfWindowHeight := windowHeight / 2
- ; This is also necessary to make the original bugfix work and a high sleep time helps the user with regaining camera control automatically
- Send, {RButton up}
- Sleep, 100
- ; Press both mouse buttons (prevents auto-run from being stopped accidentally later on and this also makes wiggling the camera possible)
- Send, {Click %halfWindowWidth% %halfWindowHeight% Down}{RButton down}
- ; Wiggling camera to make mouse movement work when the mouse gets controlled by the user and holding both mouse buttons for atleast 50 milliseconds longer
- WiggleCamera()
- Sleep, 50
- ; Executes code for physical mouse button state combinations (when both mouse buttons are physically pressed then it'll simply return without releasing them)
- if (!GetKeyState("LButton", "P") and GetKeyState("RButton", "P"))
- {
- ; Release left mouse button and use auto-run instead
- Send, {LButton up}
- Send, {r}
- }
- else if (!GetKeyState("LButton", "P") and !GetKeyState("RButton", "P"))
- ; Releases both mouse buttons
- Send, {LButton up}{RButton up}
- }
- return
- ; Left-click outside the chat area with an active chat input field and left-click inside an inactive chat input field both toggles the chat state of the macro as well
- LButton::
- Send, {LButton}
- MouseGetPos, currentCursorX, currentCursorY
- if (isChatActive)
- {
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleChatState()
- }
- else if (currentCursorX < 482 and currentCursorY > 1370)
- ToggleChatState()
- return
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 12/30/22 >> Guild Wars 2 - NEW 4.ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will reload it (the dialog box that normally appears in this situation gets skipped)
- #SingleInstance Force
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- global isChatActive := false
- ; Terminates the macro if the game doesn't restart itself within 30 seconds. And also has recursive code, which restarts this method each time the game crashes and immediately restarts
- ManageApp()
- {
- WinWait, Guild Wars 2,, 30
- if (ErrorLevel == 1)
- ExitApp
- else
- {
- WinWaitClose
- ManageApp()
- }
- }
- ; Runs the game and terminates the macro when the game window doesn't exist any longer and wasn't being restarted either (keep this at the bottom of the auto-execute section)
- RunWait, "C:\Program Files\Guild Wars 2\Gw2-64.exe"
- ManageApp()
- ; The code below only executes for the Guild Wars 2 window
- #If (WinActive("Guild Wars 2"))
- ToggleChatState()
- {
- Hotkey, If, (WinActive("Guild Wars 2"))
- HotKey, v, Toggle
- isChatActive := !isChatActive
- }
- ; Prevents hotkey interference when the chat is being used
- ~Enter::ToggleChatState()
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- Send, {Click -15 0 0 Relative}
- Send, {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- shouldUsePostponableHotkeys := true
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- }
- shouldUsePostponableHotkeys := false
- }
- F3::
- F4::LButtonAboutFace("F3")
- ; This fixes the bug where the character suddenly rotates in a random manner when the player goes on their mount while auto-run is active and the right mouse button is being pressed
- ~'::
- ; Toggled boolean variable that becomes true when mounting up
- isMountUpAction := !isMountUpAction
- ; This is for when the player actually mounts up and is physically pressing the right mouse button but not the left mouse button (aka the situation where the bug happens)
- if (isMountUpAction and GetKeyState("RButton", "P") and !GetKeyState("LButton", "P"))
- {
- shouldUsePostponableHotkeys := true
- Critical
- ; The best cursor placement to have when the mouse buttons are no longer pressed and the center of the screen also guarantees the code to work
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- halfWindowWidth := windowWidth / 2
- halfWindowHeight := windowHeight / 2
- ; This is also necessary to make the original bugfix work and a high sleep time helps the user with regaining camera control automatically
- Send, {RButton up}
- Sleep, 100
- ; Press both mouse buttons (prevents auto-run from being stopped accidentally later on and this also makes wiggling the camera possible)
- Send, {Click %halfWindowWidth% %halfWindowHeight% Down}{RButton down}
- ; Wiggling camera to make mouse movement work when the mouse gets controlled by the user and holding both mouse buttons for atleast 50 milliseconds longer
- WiggleCamera()
- Sleep, 50
- ; Executes code for physical mouse button state combinations (when both mouse buttons are physically pressed then it'll simply return without releasing them)
- if (!GetKeyState("LButton", "P") and GetKeyState("RButton", "P"))
- {
- ; Release left mouse button and use auto-run instead
- Send, {LButton up}
- Send, {r}
- }
- else if (!GetKeyState("LButton", "P") and !GetKeyState("RButton", "P"))
- ; Releases both mouse buttons
- Send, {LButton up}{RButton up}
- shouldUsePostponableHotkeys := false
- }
- return
- ; Left-click outside the chat area with an active chat input field and left-click inside an inactive chat input field both toggles the chat state of the macro as well
- OnLButton()
- {
- MouseGetPos, currentCursorX, currentCursorY
- if (isChatActive)
- {
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleChatState()
- }
- else if (currentCursorX < 482 and currentCursorY > 1370)
- ToggleChatState()
- }
- ; The hotkeys below can be made postponable but aren't by default so that they work faster whenever possible (set the shouldUsePostponableHotkeys boolean to false when you're done using it)
- #If (WinActive("Guild Wars 2") and !shouldUsePostponableHotkeys)
- ;~LButton::OnLButton()
- ; This is necessary to test the keyboard mount-up hotkey (stops the GUI mount button from working, so that it won't interfere with my test results..)
- LButton::
- MouseGetPos, currentCursorX, currentCursorY
- if (currentCursorX > 1678 and currentCursorX < 1728 and currentCursorY > 1349 and currentCursorY < 1398)
- return
- Send, {LButton down}
- OnLButton()
- return
- LButton up::Send, {LButton up}
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- ; The hotkeys below can be made postponable by setting the shouldUsePostponableHotkeys boolean to true
- #If (WinActive("Guild Wars 2") and shouldUsePostponableHotkeys)
- 4::Send, {4}
- LButton::
- Send, {LButton down}
- OnLButton()
- return
- LButton up::Send, {LButton up}
- RButton::Send, {RButton}
- w::Send, {w}
- a::Send, {a}
- s::Send, {s}
- d::Send, {d}
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 4/6/24 >> Guild Wars 2 - NEW 5.ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will reload it (the dialog box that normally appears in this situation gets skipped)
- #SingleInstance Force
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- global isChatActive := false
- ; Terminates the macro if the game doesn't restart itself within 30 seconds. And also has recursive code, which restarts this method each time the game crashes and immediately restarts
- ManageApp()
- {
- WinWait, Guild Wars 2,, 30
- if (ErrorLevel == 1)
- ExitApp
- else
- {
- WinWaitClose
- ManageApp()
- }
- }
- ; Runs the game and terminates the macro when the game window doesn't exist any longer and wasn't being restarted either (keep this at the bottom of the auto-execute section)
- RunWait, "C:\Program Files\Guild Wars 2\Gw2-64.exe"
- ManageApp()
- ; The code below only executes for the Guild Wars 2 window
- #If (WinActive("Guild Wars 2"))
- ToggleChatState()
- {
- Hotkey, If, (WinActive("Guild Wars 2"))
- HotKey, v, Toggle
- isChatActive := !isChatActive
- }
- ; Prevents hotkey interference when the chat is being used
- ~Enter::ToggleChatState()
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- Send, {Click -15 0 0 Relative}
- Send, {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- shouldUsePostponableHotkeys := true
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- Send, {Click %initialCursorX% %initialCursorY% 0}
- }
- shouldUsePostponableHotkeys := false
- }
- F3::
- F4::LButtonAboutFace("F3")
- ; Should probably make some code for left-clicking on the GUI mount-up button with the mouse manually (not using the mount-up key on the keyboard..), atleast if this works
- ;'::
- ;shouldUsePostponableHotkeys := true
- ;Critical
- ;SendEvent {Click 1700 1375}
- ;SendEvent {Click 1700 1348 0}
- ;WiggleCamera()
- ;shouldUsePostponableHotkeys := false
- ;return
- ; If this code doesn't work, try the one above it <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- ; This might fix the bug where the character suddenly rotates in a random manner when the player goes on their mount
- ; Copied from "Guild Wars 2 - NEW 2 (backup containing some more code that didn't rly seem necessary).ahk" and added the postponable hotkeys boolean & critical keyword)
- '::
- useMountUpCode := !useMountUpCode ; Toggled boolean variable that becomes true when mounting up
- if (useMountUpCode)
- {
- shouldUsePostponableHotkeys := true
- Critical
- if (GetKeyState("LButton", "P") and GetKeyState("RButton", "P")) ; IF physically pressed down both mouse buttons
- {
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- Send, {'} ; Mount up while the mouse buttons are still pressed in
- return
- }
- else if (GetKeyState("RButton", "P")) ; IF physically pressed down right mouse button
- {
- Send, {LButton up}{RButton up} ; Removes glitchy auto-run behaviour where it suddenly stops
- Sleep, 25 ; Removes glitchy auto-run behaviour where it suddenly stops
- Send, {LButton down}{RButton down} ; Press both mouse buttons (prevents stopping active auto-run permanently below by stopping it temporarily)
- WiggleCamera() ; Wiggling camera to make mouse movement work when the mouse gets controlled by the user
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- if (GetKeyState("LButton", "P") and GetKeyState("RButton", "P")) ; IF physically pressed down both mouse buttons
- Send, {'} ; Mount up while the mouse buttons are still pressed in
- else
- { ; ELSE executing code of this scope
- Send, {'} ; Mount up while the mouse buttons are still pressed in
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- Send, {LButton up} ; Release left mouse button
- Send, {r} ; Use auto-run instead
- }
- return
- }
- else ; ELSE
- {
- Send, {LButton down}{RButton down} ; Press both mouse buttons
- WiggleCamera() ; Wiggling camera to make mouse control work when done by the user
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- Send, {'} ; Mount up while the mouse buttons are still pressed in
- Sleep, 50 ; Hold both mouse buttons for 50 milliseconds
- if (GetKeyState("LButton", "P") and GetKeyState("RButton", "P")) ; IF physically pressed down both mouse buttons
- return ; Keep holding both mouse buttons
- else ; ELSE
- Send, {LButton up}{RButton up} ; Release both mouse buttons
- }
- shouldUsePostponableHotkeys := false
- }
- else
- Send, {'} ; Use default behaviour when mounting down
- return
- ; Left-click outside the chat area with an active chat input field and left-click inside an inactive chat input field both toggles the chat state of the macro as well
- OnLButton()
- {
- MouseGetPos, currentCursorX, currentCursorY
- if (isChatActive)
- {
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleChatState()
- }
- else if (currentCursorX < 482 and currentCursorY > 1370)
- ToggleChatState()
- }
- ; The hotkeys below can be made postponable but aren't by default so that they work faster whenever possible (set the shouldUsePostponableHotkeys boolean to false when you're done using it)
- #If (WinActive("Guild Wars 2") and !shouldUsePostponableHotkeys)
- ;~LButton::OnLButton()
- ; This is necessary to test the keyboard mount-up hotkey (stops the GUI mount button from working, so that it won't interfere with my test results..)
- LButton::
- MouseGetPos, currentCursorX, currentCursorY
- if (currentCursorX > 1678 and currentCursorX < 1728 and currentCursorY > 1349 and currentCursorY < 1398)
- return
- Send, {LButton down}
- OnLButton()
- return
- LButton up::Send, {LButton up}
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- ; The hotkeys below can be made postponable by setting the shouldUsePostponableHotkeys boolean to true
- #If (WinActive("Guild Wars 2") and shouldUsePostponableHotkeys)
- 4::Send, {4}
- LButton::
- Send, {LButton down}
- OnLButton()
- return
- LButton up::Send, {LButton up}
- RButton::Send, {RButton}
- w::Send, {w}
- a::Send, {a}
- s::Send, {s}
- d::Send, {d}
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 9/16/22 >> Guild Wars 2 - NEW.ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will be ignored (skips the dialog box and leaves the old instance running)
- #SingleInstance Ignore
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- ; The code below only executes for the Guild Wars 2 window
- #IfWinActive Guild Wars 2
- isGameChatActive := false
- ; These hotkeys aren't needed straight away and can be turned on when any of these hotkeys actually need to be used
- ;HotKey, LButton, Off
- HotKey, RButton, Off
- ToggleHotkeys()
- {
- HotKey, v, Toggle
- HotKey, F3, Toggle
- HotKey, F4, Toggle
- ;HotKey, LButton, Toggle
- }
- ; Suspends hotkeys when making the input field of the chat active with the Enter key (and it will unsuspend the hotkeys when Enter is pressed again)
- Enter::
- ToggleHotkeys()
- Send, {Enter}
- isGameChatActive := !isGameChatActive
- return
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- SendEvent {Click -15 0 0 Relative}
- SendEvent {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- HotKey, RButton, On
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- SendEvent {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- HotKey, RButton, Off
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- HotKey, RButton, On
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- SendEvent {Click %initialCursorX% %initialCursorY% 0}
- HotKey, RButton, Off
- }
- }
- F3::
- F4::LButtonAboutFace("F3")
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- 4::Send, {4}
- ; Or maybe I should use the Wiggle method instead if this one doesn't work and if it does work then I can also try button presses without holding them down a for 50 milliseconds
- StabilizeScreen()
- {
- Send, {LButton down}{RButton down} ; Press both
- Sleep, 50 ; Hold both for 50 milliseconds
- Send, {LButton up}{RButton up} ; Release both
- }
- ; Simply calling StabilizeScreenAndRun() causes buggy run/stop behaviour. So I'm just clicking on the game button instead, to mount-up and then it returns the cursor to its initial position
- '::
- MouseGetPos, initialCursorX, initialCursorY
- SendEvent {Click 1700 1375}
- SendEvent {Click %initialCursorX% %initialCursorY% 0}
- return
- ; Left-click outside the chat area (when this hotkey gets enabled, is off by default) will unsuspend the disabled hotkeys as well, because they only need to stay disabled while chatting
- ~LButton::
- if (isGameChatActive)
- {
- MouseGetPos, currentCursorX, currentCursorY
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleHotkeys()
- }
- else
- {
- MouseGetPos, currentCursorX, currentCursorY
- if (currentCursorX > 1678 and currentCursorX < 1728 and currentCursorY > 1349 and currentCursorY < 1398)
- StabilizeScreen()
- }
- return
- ; The right mouse button can be manually disabled by turning this hotkey on
- RButton::return
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 2/19/22 >> Guild Wars 2 - Postpone all input (experiment to avoid hardcoding teleport AND movement hotkeys).ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- ; The code below only executes for the Guild Wars 2 window
- #IfWinActive Guild Wars 2
- ; These hotkeys aren't needed straight away and can be turned on when any of these hotkeys actually need to be used
- HotKey, LButton, Off
- HotKey, RButton, Off
- ;HotKey, 4, Off
- ToggleHotkeys()
- {
- HotKey, v, Toggle
- HotKey, F3, Toggle
- HotKey, F4, Toggle
- HotKey, LButton, Toggle
- }
- ; Suspends hotkeys when making the input field of the chat active with the Enter key (and it will unsuspend the hotkeys when Enter is pressed again)
- Enter::
- ToggleHotkeys()
- Send, {Enter}
- return
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- SendEvent {Click -15 0 0 Relative}
- SendEvent {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- HotKey, RButton, On
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- SendEvent {Click %initialCursorX%, %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- HotKey, RButton, Off
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- HotKey, RButton, On
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- SendEvent {Click %initialCursorX%, %initialCursorY% 0}
- HotKey, RButton, Off
- }
- }
- F3::
- F4::
- ;HotKey, 4, On
- ;BlockInput, On
- ;Input, SingleKey, L1
- ;SetTimer, CatchInput, -100
- Critical
- Sleep, 2000
- LButtonAboutFace("F3")
- ;BlockInput, Off
- ;HotKey, 4, Off
- if (useTeleport)
- {
- Send, {4}
- useTeleport := False
- }
- return
- CatchInput: ; Maybe there is a better word than 'catch' ??
- Input, SingleKey, L1
- return
- 4::Send, {4}
- ; This lets the player teleport as soon as it becomes possible (when this hotkey gets enabled, is off by default)
- ;4::useTeleport := True
- ; Left-click outside the chat area (when this hotkey gets enabled, is off by default) will unsuspend the disabled hotkeys as well, because they only need to stay disabled while chatting
- ~LButton::
- MouseGetPos, currentCursorX, currentCursorY
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleHotkeys()
- return
- ; The right mouse button can be manually disabled by turning this hotkey on
- RButton::return
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 1/19/24 >> Guild Wars 2.ahk:
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ; Any attempt to launch this script when it's already running will be ignored (skips the dialog box and leaves the old instance running)
- #SingleInstance Ignore
- ; This allows the physical mouse key states to be read, like for example GetKeyState("RButton", "P")
- #InstallMouseHook
- ; The code below only executes for the Guild Wars 2 window
- #IfWinActive Guild Wars 2
- ; These hotkeys aren't needed straight away and can be turned on when any of these hotkeys actually need to be used
- HotKey, LButton, Off
- HotKey, RButton, Off
- ToggleHotkeys()
- {
- HotKey, v, Toggle
- HotKey, F3, Toggle
- HotKey, F4, Toggle
- HotKey, LButton, Toggle
- }
- ; To hide the OSD
- Volume_Up:: SoundSet +2
- Volume_Down::SoundSet -2
- ; Suspends hotkeys when making the input field of the chat active with the Enter key (and it will unsuspend the hotkeys when Enter is pressed again)
- Enter::
- ToggleHotkeys()
- Send, {Enter}
- return
- ; Dodge Jump
- ~v::Send, {Space}
- ; The About Face feature is only guaranteed to work if the camera has rotated since the last time the player had moved (so this rotates it a bit and then back again)
- WiggleCamera()
- {
- ; Using the lowest possible mouse delay for a wiggle that's barely noticeable (going even lower will make the wiggle stop working)
- SetMouseDelay, 1
- SendEvent {Click -15 0 0 Relative}
- SendEvent {Click 15 0 0 Relative}
- }
- ; Uses the About Face feature without turning the camera along with it (requires the keybind that's used in guild wars 2)
- LButtonAboutFace(functionKey)
- {
- Critical
- MouseGetPos, initialCursorX, initialCursorY
- WinGetActiveStats, windowTitle, windowWidth, windowHeight, windowX, windowY
- if (GetKeyState("LButton") and GetKeyState("RButton"))
- Send, {%functionKey%}
- else if (GetKeyState("LButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the left mouse button was held pressed down (before this method got called)
- Send, {LButton up}
- Sleep, 40
- Send, {LButton down}
- WiggleCamera()
- Send, {%functionKey%}
- }
- else if (GetKeyState("RButton"))
- {
- ; Removes glitchy camera behaviour that would otherwise have happened if the cursor had been moved while the right mouse button was held pressed down (before this method got called)
- Send, {RButton up}
- Send, {RButton down}
- WiggleCamera()
- ; Preventing the camera from both accidentally turning 180 degrees and stopping any movement
- Send, {RButton up}
- HotKey, RButton, On
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- Click, %windowWidth% %windowY% Down
- Send, {%functionKey%}
- Click, Up
- SendEvent {Click %initialCursorX% %initialCursorY% 0}
- ; Make the right mouse button become pressed down again as long as it's still physically pressed down, but only as soon as it stops leading to unwanted behaviour
- if (GetKeyState("RButton", "P"))
- {
- ; Delay the upcoming action to prevent the camera from turning 180 degrees and then the right mouse button will also stay pressed down
- Sleep, 525
- if (GetKeyState("RButton", "P"))
- Send, {RButton down}
- }
- HotKey, RButton, Off
- }
- else
- {
- ; Holds the LButton pressed down (in top-right corner) while it sends the specified function key
- HotKey, RButton, On
- Click, %windowWidth% %windowY% Down
- WiggleCamera()
- Send, {%functionKey%}
- Click, Up
- SendEvent {Click %initialCursorX% %initialCursorY% 0}
- HotKey, RButton, Off
- }
- }
- F3::
- F4::LButtonAboutFace("F3")
- ; This is where all the hotkeys should be that can be postponed (like when trying to use a teleport skill when LButtonAboutFace is being executed, which is an uninterruptible function..)
- 4::Send, {4}
- ; Left-click outside the chat area (when this hotkey gets enabled, is off by default) will unsuspend the disabled hotkeys as well, because they only need to stay disabled while chatting
- ~LButton::
- MouseGetPos, currentCursorX, currentCursorY
- if (currentCursorX > 490 or currentCursorY < 1147)
- ToggleHotkeys()
- return
- ; The right mouse button can be manually disabled by turning this hotkey on
- RButton::return
- *********************************************************************************************************************************************************************************************
- MODIFIED AT: 7/29/24 >> README.txt:
- it might be that I need to programmatically use temporarily only auto-run and RMB instead of both LMB and RMB when both are physically pressed and the ' hotkey gets used
- not sure, seemed like the issue only happens when both were physically pressed and the ' hotkey got used.. but the issue wasn't very disturbing, so maybe it gets fixed partially, dunno
- hard to tell what exactly happened, if it was really the warclaw mount-up issue or not
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement