Skip to content

Instantly share code, notes, and snippets.

@pstengel
Last active December 8, 2021 04:22
Show Gist options
  • Save pstengel/c2280476e34dd89dbf12e36f5e9a440a to your computer and use it in GitHub Desktop.
Save pstengel/c2280476e34dd89dbf12e36f5e9a440a to your computer and use it in GitHub Desktop.
Automatically open many Hearthstone packs with AutoHotkey
; **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
@syntax53
Copy link

syntax53 commented Oct 22, 2021

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