Last active
May 15, 2024 14:32
-
-
Save KarlRamstedt/1d474460be27dfc8b3c9f81625484a3c to your computer and use it in GitHub Desktop.
A collection of time-saving macros for repetitive UI tasks in Lost Ark. NOTE: Delays may need to be increased for slower PCs (info in 1st comment)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv ; For performance and compatibility with future AutoHotkey releases | |
SendMode Input ; For speed and reliability | |
SetBatchLines -1 ; No script sleep, for more consistent spam behavior. Default behavior is 10ms execution then 10ms sleep | |
ListLines Off ; Increase performance by a few percent by not logging the lines of code that are executed | |
global donateSilver := false ; Guild donation is a silver sink; you lose more than you gain, so only do it if your guild needs it or if you're desperate for bloodstones | |
global supportResearch := false ; Set to false to avoid Guild Task pop-up after daily macro (happens if no active research) | |
global spam := false ; Change this to true if you want it on by default | |
spamHotkeys := ["Space"] ; Hold one of these to spam that key. Just add a key to the array to automatically make it a new spam hotkey. Shift+G spam is handled separately. | |
global BoundFuncCache := {} ; A collection of bound functions for use in Timer stopping. Func(f).Bind(k) seems to create an object and return a reference to it, without caching the result, so manual caching is required to reference the same object | |
#IfWinActive ahk_exe LOSTARK.exe ; Only trigger hotkeys when Lost Ark is the active window | |
Hotkey, IfWinActive, ahk_exe LOSTARK.exe ; Same, but for dynamically created hotkeys | |
for i, key in spamHotkeys { ; Creates hotkeys for each key in the array above | |
BoundFuncCache[key] := Func("SendBlind").Bind(key) | |
stopSpamBF := Func("StopSpam").Bind(BoundFuncCache[key]) | |
Hotkey, % "~*" . key . " Up", % stopSpamBF | |
spamBF := Func("Spam").Bind(key) ; Bind(BoundFunc) the Key to the Spam function to use it as input for the Hotkey Command | |
Hotkey, % "$*" . key, % spamBF ; $ to ensure Hotkeys can't trigger themselves | |
} | |
Spam(key){ | |
Send, % "{Blind}{" . key . " Down}" ; Required because ~ can't be used with KeyWait for blocking Auto-Repeat | |
if (spam){ | |
tmp := BoundFuncCache[key] ; SetTimer doesn't support function references in expression mode, requiring a temporary variable and regular variable dereferencing | |
SetTimer, %tmp%, 9 ; Delay between activations in ms. 9ms = 111 times per second | |
KeyWait, % key | |
} | |
} | |
StopSpam(boundFunc){ | |
SetTimer, %boundFunc%, Off | |
} | |
SendBlind(key){ ; Function-wrapper for the Send Command | |
if (WinActive("ahk_exe LOSTARK.exe")) ; In case it gets stuck(happens ~5% of the time with any looping AHK behavior, doesn't seem to exist any fix) | |
Send, % "{Blind}{" . key . "}" | |
} | |
#G:: ; Win+G toggles Spam On/Off | |
spam := !spam | |
if (spam) | |
CenteredToolTip("Spam On") | |
else { | |
CenteredToolTip("Spam Off") | |
SetTimer, GSpam, Off | |
for i, func in BoundFuncCache | |
SetTimer, %func%, Off | |
} | |
return | |
*G:: ; Hold G to spam Shift+G | |
Send, {Blind}{g Down} | |
if (spam){ | |
Send, +g | |
SetTimer, GSpam, 99 ; 10 times per second | |
KeyWait, g | |
} | |
return | |
~*G Up:: | |
SetTimer, GSpam, Off | |
return | |
GSpam(){ | |
if (WinActive("ahk_exe LOSTARK.exe")) ; In case it gets stuck(happens ~5% of the time with any looping AHK behavior, doesn't seem to exist any fix) | |
Send, +g | |
} | |
<^>!F1:: SendMessage("ENHANCED") | |
<^>!F2:: SendMessage("NORMAL") | |
<^>!F3:: SendMessage("[BigNews]") | |
^Esc::Reload ; Ctrl+Esc reloads script | |
$^I:: ; Ctrl+I to open Storage(requires Aura) | |
Send, !p ; Open Pet menu | |
Click(.626, .614, 444) ; Storage, 595 for 21:9 | |
return | |
$^P:: ; Ctrl+P to repair gear (requires Aura) | |
Send, !p ; Open Pet menu | |
Click(.626, .65, 444) ; Repair, 595 for 21:9 | |
Click(.57, .63, 999) ; Repair All | |
Send, {Esc}{Esc} | |
return | |
$^M:: ; Ctrl+M to open Mail->Write Letter (requires Aura) | |
Send, !p ; Open Pet menu | |
Click(.6, .65, 444) ; Mail, 58 for 21:9 | |
Click(.4, .26, 999) ; Write Letter | |
Click(.31, .29) ; Express Mail, 35 for 21:9 | |
Click(.37, .33) ; Select Recipient | |
return | |
$!Y:: ; Alt+Y opens Market and selects search bar | |
Send, !y ; Open Market | |
Click(.5, .23, 666) ; Search bar. Long (666ms) delay to work on first load. INCREASE if your PC loads slowly | |
return | |
$^Y:: ; Ctrl+Y opens AH and searches 1st saved search | |
OpenAH() | |
SearchAH(0) | |
return | |
$^+Y:: ; Ctrl+Y opens AH and searches saved search #1-12 | |
OpenAH() | |
Loop, 12 { | |
SearchAH(A_Index-1) | |
Sleep, 2444 | |
} | |
return | |
OpenAH(){ | |
Send, !y ; Open Market | |
Click(.26, .15, 999) ; AH tab, 32 for 21:9. Long delay to work on first load. INCREASE if your PC loads slowly | |
} | |
SearchAH(index){ | |
Click(.82, .23) ; Advanced Search, 74 for 21:9 | |
Click(.67, .26+index*.042) ; Saved search | |
Send, {Enter} ; Yes, load preset | |
Click(.52, .84) ; Search button | |
MouseMove, % A_ScreenWidth*.82, % A_ScreenHeight*.23, 0 ; End with mouse over Advanced Search | |
} | |
$+Tab:: ; Shift+Tab accepts and removes first mail | |
MouseGetPos, mouseX, mouseY ; Save mouse position | |
Click(.21, 0) ; Open Mail, 144 for 21:9 | |
Click(.1, .1) ; First Mail | |
Click(.28, .47, 444) ; Accept, 22 for 21:9 | |
Click(.33, .47, 333) ; Remove, 26 for 21:9 | |
Click(.21, 0, 1) ; Close Mail, 157 for 21:9 | |
Sleep, 9 | |
MouseMove, mouseX, mouseY, 0 ; Move mouse back to original location | |
return | |
$+VKDC:: ; Shift+Squiggly-S-symbol (key between tab and Esc on EU keyboards) loads into your Stronghold | |
Send, !u ; Open guild menu | |
MouseGetPos, mouseX, mouseY ; Save mouse position | |
Click(.48, .13, 1777) ; Guildmates tab. Long (1.8s) delay to work on first load. INCREASE if your PC loads slowly | |
Click(.85, .23) ; Stronghold button, 77 for 21:9 | |
Send, {Enter} ; Confirm | |
MouseMove, mouseX, mouseY, 0 ; Move mouse back to original location | |
return | |
$^!U:: ; Ctrl+Alt+U selects Weekly Guild Tasks for the Guild | |
Send, !u ; Open Guild menu | |
Click(.4, .13, 1777) ; Overview tab. Long delay to work on first load. INCREASE if your PC loads slowly | |
Click(.5, .48) ; Accept daily check-in | |
Click(.56, .13) ; Weekly Tasks tab | |
Click(.83, .18) ; Weekly Tasks, 77 for 21:9 | |
Click(.28, .18) ; Filter dropdown | |
Click(.28, .23) ; Favorites | |
Click(.53, .3) ; 1st | |
Send, {Enter} | |
Click(.53, .39) ; 2nd | |
Send, {Enter} | |
Click(.53, .47) ; 3rd | |
Send, {Enter}{Esc} | |
Click(.4, .13) ; Overview tab | |
MouseMove, % A_ScreenWidth*.76, % A_ScreenHeight*.32, 0 ; End with mouse over Apply | |
return ; Put semi-colon before "return" to also do weekly macro | |
$^+U:: ; Ctrl+Shift+U accepts 6 first favorite Weekly Una and 3 Guild tasks(assuming lvl5 tasks) | |
Send, !j ; Open Una menu | |
Click(.33, .15, 999) ; Weekly tab. Long delay to work on first load. INCREASE if your PC loads slowly | |
Click(.3, .19) ; Filter dropdown | |
Click(.3, .25) ; Favorites | |
Loop, 6 | |
Click(.67, .3+(A_Index-1)*.072) ; Accept | |
Send, j ; Open Quest menu | |
Click(.17, .715, 444) ; Hide all quests to avoid UI clutter, only showing guild tasks as they might differ between weeks | |
Send, j ; Close Quest menu | |
Click(.47, .14) ; Guild Request tab | |
Click(.67, .59) ; Accept 1st, 63 for 21:9 | |
Click(.67, .66, 1444) ; Accept 2nd, 63 for 21:9. Longer delay cuz accepting moves the tasks around after a short delay | |
Click(.478, .72, 1444) ; Page 2 | |
Click(.67, .3) ; Accept 3rd, 63 for 21:9 | |
Send, !j ; Close Una menu | |
return ; Put semi-colon before "return" to also do daily macro | |
$^U:: ; Ctrl+U accepts X number of favorite Daily Unas, donates Silver and supports guild research | |
DUna([0]) ; 1st one only, change to [0, 1, 2] to accept the first 3 | |
Send, !u ; Open Guild menu | |
Click(.4, .13, 1777) ; Overview tab. Long delay to work on first load. INCREASE if your PC loads slowly | |
Click(.5, .48) ; Accept daily check-in | |
if (supportResearch){ | |
Click(.77, .52) ; Support Research button | |
Click(.44, .5) ; Normal Support button | |
Click(.47, .7) ; Ok button | |
} | |
if (donateSilver){ | |
Click(.78, .87) ; Donate button | |
Click(.38, .52) ; Donate Silver button | |
} | |
Sleep, 99 | |
Send, !u ; Close Guild menu | |
return | |
DUna(indexes){ | |
Send, !j ; Open Una menu | |
Click(.23, .15, 999) ; Daily tab, 3 for 21:9. Long delay to work on first load. INCREASE if your PC loads slowly | |
Click(.26, .222) ; Filter dropdown | |
Click(.26, .33) ; Favorites | |
for i, una in indexes | |
Click(.67, .325+una*.07) ; Accept, 63 for 21:9 | |
Send, !j ; Close Una menu | |
} | |
SendMessage(message){ | |
Send, {Enter} | |
Sleep, 99 | |
Send, {Text}%message% | |
Send, {Enter} | |
} | |
Click(X, Y, delay = 99){ ; X and Y in % of screen. Delay in ms (MilliSeconds). Default value can be overridden | |
MouseMove, % A_ScreenWidth*X, % A_ScreenHeight*Y, 0 ; Location relative to screen resolution so it works with any 16:9 resolution. NOTE: MouseMove doesn't work in fullscreen mode | |
Sleep, delay ; Delay needed so the game registers the click in the new spot | |
Click | |
} | |
CenteredToolTip(text, duration = 999){ ; Duration in ms (MilliSeconds). Default value can be overridden | |
ToolTip, %text%, A_ScreenWidth/2, A_ScreenHeight/2 | |
SetTimer, RemoveToolTip, -%duration% ; Negative to only trigger once | |
} | |
RemoveToolTip(){ | |
ToolTip | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Removed the SwapKeys macro.
Copy-paste it from the older revision if you want that functionality.