; Script can be directly run by or compiled into an .exe by the open-source software AutoHotkey
; https://www.autohotkey.com

;
; Front Matter
;

; Include relevant libraries
#Include ../lib/Prelude.ahk
#Include ../lib/HoldRepeat.ahk

; Make this a wrapper script
WrapperPath:="shell:AppsFolder\Microsoft.MinecraftUWP_8wekyb3d8bbwe!App"
WrapperWindow:="Minecraft"
#Include ../lib/Wrapper.ahk

; Send an F4 to activate fullscreen
Sleep 1000
Send {F4 down}
Sleep 100
Send {F4 up}

;
; Hotkeys
;

; Remap LAlt so it doesn't active Minecraft's Alt+Space menu shortcut
#InputLevel 1
*LAlt::vkFF
#InputLevel 0
vkFF & Tab::
Send {Alt down}
Send {Blind}{Tab}
SetTimer, AltUp, -1
return
AltUp:
KeyWait LAlt
Send {Alt up}
return

; Hold/Autoclick mouse buttons
; Holds if single click, autoclicks if double click
vkFF & LButton UP::HoldOrRepeat("LButton",["LButton","RButton","MButton"])
vkFF & RButton UP::HoldOrRepeat("RButton",["RButton","LButton","MButton"])

; Autorun
vkFF & w UP::Hold("w",["w","s"])
vkFF & s UP::Hold("s",["w","s"])
vkFF & a UP::Hold("a",["a","d","w","s"])
vkFF & d UP::Hold("d",["d","a","w","s"])

; Hold crouch
vkFF & Shift UP::Hold("Shift",["Shift","Ctrl"])

; Autojump/auto-ascend
vkFF & Space UP::Hold("Space",["Space","Shift"])

; Mouse button 4: auto-takeoff
; Macro assumes you have your fireworks in the first hotbar slot
XButton1::
Loop, 5 {
    Send {Space down}
    Sleep 10
}
Send {Space up}1
Sleep 225
Loop, 5 {
    Send {Space down}
    Sleep 10
}
Send {Space up}{RButton}
return