Last active
December 8, 2021 04:22
-
-
Save pstengel/c2280476e34dd89dbf12e36f5e9a440a to your computer and use it in GitHub Desktop.
Automatically open many Hearthstone packs with AutoHotkey
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
; **OUTDATED - See comments.** | |
; Hearthstone - Open Packs AHK Script (c) by | |
; (Paul Stengel)[https://github.com/pstengel/] | |
; | |
; Hearthstone - Open Packs AHK Script is licensed under a | |
; Creative Commons Attribution-NonCommercial 4.0 International License. | |
; | |
; You should have received a copy of the license along with this | |
; work. If not, see <http://creativecommons.org/licenses/by-nc/4.0/>. | |
; | |
; This script requires (Auto Hotkey)[https://autohotkey.com/]. Once Auto Hotkey | |
; is installed, launch Hearthstone in windowed mode, then activate this script | |
; and follow the prompts. | |
; | |
; This script may be against Blizzard/Hearthstone TOS. If you use this script, | |
; you accept any and all risk. | |
; | |
; | |
; DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING | |
; | |
InputBox | |
, iPacks | |
, Open Packs, Open Hearthstone in windowed mode`, click "Open Packs`," then enter the number of packs you need to open. | |
if !iPacks | |
ExitApp | |
if iPacks is not integer | |
{ | |
MsgBox, Invalid number of packs! | |
ExitApp | |
} | |
MsgBox | |
, 1 | |
, Open Packs | |
, Click OK to begin opening packs. Click Cancel to abort.`n`nNote: Once the script begins, you can press Esc to cancel it. Do not move your mouse or use your keyboard while the script runs. | |
IfMsgBox, Cancel | |
ExitApp | |
; | |
; Activate the Hearthstone window | |
; | |
WinActivate, Hearthstone | |
IfWinNotActive, Hearthstone | |
{ | |
MsgBox, Heathstone doesn't appear to be running! Exiting... | |
ExitApp | |
} | |
; | |
; Main pack open loop | |
; TODO: Resolution adjustment algorithm | |
; TODO: Error handling | |
; TODO: Are these the best timings? | |
; BUG: Only works if user owns only one expansion's worth of packs | |
; | |
Loop, %iPacks% { | |
Send, {Space} | |
Sleep, 4000 | |
; Top-Left Card | |
Click, 1100, 500 | |
Sleep, 100 | |
; Top-Middle Card | |
Click, 1500, 350 | |
Sleep, 100 | |
; Top-Right Card | |
Click, 2000, 500 | |
Sleep, 100 | |
; Bottom-Left Card | |
Click, 1300, 1100 | |
Sleep, 100 | |
; Bottom-Right Card | |
Click, 1800, 1100 | |
Sleep, 1250 | |
} | |
; Don't leave the last pack open | |
Send, {Space} | |
Sleep, 1250 | |
MsgBox, All packs opened! | |
; Hit Escape to abort the script | |
; TODO: Pause/resume buttons? | |
Esc::ExitApp |
Since this is where I landed searching for a solution to the horrible HS pack opening experience, I whipped this up as an iteration of the above. It simply activates the Hearthstone window and starts pressing the space bar. As soon as Hearthstone is not that active window anymore, it quits.
(This is the entire script):
WinActivate, Hearthstone
IfWinNotActive, Hearthstone
{
MsgBox, Heathstone doesn't appear to be running! Exiting...
ExitApp
}
Loop {
Send, {Space}
Sleep, 500
IfWinNotActive, Hearthstone
{
ExitApp
}
}
Esc::ExitApp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I originally wrote this script, space didn't work to reveal the cards—it only opened the next pack. I'm glad to hear they finally implemented an easier way of opening packs.
I'm going to leave the original script as-is. I haven't played in a while, so I won't be able to test any changes. However, @temzky's version looks like it would work fine—I recommend going with that one over mine if you run across this in 2021.