Skip to content

Instantly share code, notes, and snippets.

@mrasmus
Created August 20, 2021 08:45
Show Gist options
  • Save mrasmus/fca1bfed2fab2f28d8aaa68a4df56317 to your computer and use it in GitHub Desktop.
Save mrasmus/fca1bfed2fab2f28d8aaa68a4df56317 to your computer and use it in GitHub Desktop.
Destiny 2 Vendor Token AutoHotkey Script
#MaxThreadsPerHotkey 3
; Pre-Setup:
; This script requires AutoHotkey (https://www.autohotkey.com/). Install
; that first, then save this script as a .ahk file and run it -- it will
; show up in your system tray, and can be reloaded/stopped from there. While
; running, it will listen for specific key combinations to trigger macros.
; Don't forget to kill it when you're done to prevent unexpected behavior.
;
; Script Explanation:
; Vendor token spender/package collector. Pressing control + 2 spends tokens
; and picks up the resultant packages (two clicks on tokens, one on package).
; Also comes with an auto-dismantler bound to control + 3, which only holds
; down the F key repeatedly.
; Repeating either input (Control+2 again) should interrupt the action.
;
; Positions may need to be adjusted, so the script comes unarmed; once you
; test that the mouse moves are working correctly, change "false" to "true"
; on the line in the Configuration section.
; ~~~~~~~~~~ Configuration ~~~~~~~~~~
Armed := false ; Set to true to enable the clicking/deleting functions
Count := 10 ; Number of items to grab/delete; Postmaster has room for 21!
; Only adjust if the mouse moves aren't working correctly; was tested in a
; 1440p window. The values are 0-1 percentages of the window's dimensions.
rewardX_pct := 0.880
rewardY_pct := 0.13
tokenX_pct := 0.650
tokenY_pct := 0.26
; The timings are all pretty conservatively specified so they *should*
; tolerate different systems' performances, but if you want it to go faster
; then you can shorten some of them. My goal was predictable behavior.
; ~~~~~~~~~~ Script Body ~~~~~~~~~~
CoordMode, Mouse, Client
^2::
Toggle2 := !Toggle2
WinGetPos, winX, winY, winWidth, winHeight, A
rewardX := winWidth * rewardX_pct
rewardY := winHeight * rewardY_pct
tokenX := winWidth * tokenX_pct
tokenY := winHeight * tokenY_pct
Loop , %Count%
{
If (!Toggle2)
Break
MouseMove, %tokenX%, %tokenY%
Sleep 500
Loop , %Count%
{
Sleep 800
If (!Toggle2)
Break
If (Armed)
Click
}
If (!Toggle2)
Break
MouseMove, %rewardX%, %rewardY%
Sleep 500
If (Armed)
Click
Sleep 500
}
send {Esc}
Toggle2 := false
Return
^3::
Toggle3 := !Toggle3
Loop , %Count%
{
If (!Armed)
Break
If (!Toggle3)
Break
Send {f down}
Sleep 1010
Send {f up}
Sleep 1000
}
send {Esc} ; quit out of the postmaster when we're done
Toggle3 := false
Return
@mrasmus
Copy link
Author

mrasmus commented Aug 20, 2021

Getting reports that the positions are changing subtly in a way I didn't expect, based on resolution. UI scaling and such. As such, the mouse positions in the config file will likely need to be changed for anyone who isn't running with my specific setup (1440p window) will need to adjust lines 27-30. Values I helped tune for a friend running at 1080p, windowed fullscreen, for reference:

rewardX_pct := 0.94
rewardY_pct := 0.10
tokenX_pct := 0.69
tokenY_pct := 0.23

As the comments say, these are percentages, so can be adjusted by eyeballing and guess-and-check, or you can launch AHK's "Window Spy" script (it comes with AHK, in the install directory; Windows' Start menu search should find it), and calculate them more directly. You're looking for the Client Mouse Position values, divided by the Client Window dimensions (highlighted in red, below).

windowspy_example

So, for this example, 1796/1920 = 0.9354.... and 106/1080 = 0.0981....; you can pretty safely round to two figures, if you're hovering the center of the icons. That leaves us with the reward X/Y pct's above.

If you successfully tune your values to work for you, please share them as a comment with your resolution/display mode, or send them along to me so I can document them here for others. Thanks.

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