Skip to content

Instantly share code, notes, and snippets.

@KarlRamstedt
Last active May 15, 2024 14:32
Show Gist options
  • Save KarlRamstedt/1d474460be27dfc8b3c9f81625484a3c to your computer and use it in GitHub Desktop.
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)
#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
}
@KarlRamstedt
Copy link
Author

KarlRamstedt commented Mar 14, 2023

Hotkeys

G-spam: Hold G to spam Shift+G 10 times per second. WindowsKey+G to toggle the spam on/off.
Spacebar-spam: Hold Spacebar to spam it ~60 times per second. Shares the WindowsKey+G on/off toggle with G-spam.
Ctrl+I: Open Storage (requires Aura).
Ctrl+P: Repair gear (requires Aura).
Ctrl+M: Opens Mail->Write Letter for quickly sending items through mail (requires Aura).
Ctrl+U: Accepts first favorite Daily Una, accepts daily Guild check-in and optionally donates Silver and supports guild research (controlled by bools at top of script, change to true if you want them, else false).
Alt+Y: Opens Market and selects search bar.
Ctrl+Y: Opens AH and searches 1st saved search.
Ctrl+Shift+Y: Opens AH and searches saved search #1-12 with a slight delay between them.
Shift+Tab: Accepts and removes first mail (takes about 1sec to execute, so can be used every 1s to rapidly clear out mail).
Shift+§: Enters your stronghold in ~1.7sec instead of the ~7s it takes to play the song. Requires being in a guild as it goes through the guild UI. (§ is a key between Tab and Esc on EU keyboards)
Ctrl+Shift+U: Accepts 6 first favorite Weekly Una, hides tasks to reduce clutter, then accepts 3 Guild tasks(assuming lvl5 tasks).
Ctrl+Alt+U: Selects the first 3 favorite Weekly Guild Tasks for the Guild (only relevant for Leader/Officers).
AltGr+F1: F1-F3 are global message macros. Ingame text macros are character-specific. You can easily copy-paste if you need more than 3.

Notes

  • The macros are made for a medium to high-end PC. If they don't work you may need to increase some delays.
  • Made for 16:9 resolutions. Most of them will need modification to work with other aspect ratios. 21:9 might work with minor modification. Search the script for 21:9 and change the X coordinate in Click(.X, .Y) to the noted value. That will hopefully work(can't test myself).
  • Most of the macros don't work in fullscreen mode, because AHK can't move the mouse with it on.
  • Non-EU keyboard layouts may lack an AltGr key, for most of these the Right Alt key should work. If that doesn't work try replacing all instances of <^>!(AltGr modifier) with >!(Right Alt modifier) or !(Alt modifier).
  • I recommend Notepad++ with KIXtart selected under the Language menu for syntax highlighting (to make it easier to read and edit the code).

@KarlRamstedt
Copy link
Author

KarlRamstedt commented Dec 18, 2023

Removed the SwapKeys macro.
Copy-paste it from the older revision if you want that functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment