#Persistent
#NoEnv
#Warn
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#SingleInstance Force
ListLines Off
SendMode Input
SetDefaultMouseSpeed, 0
SetMouseDelay, -1
SetKeyDelay, -1, -1
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen

global AutoPanickActive := false  ; Flag to indicate AutoPanick priority

SetTimer, AutoPanick, 50
SetTimer, AutoRefill, 30000
SetTimer, AfkKillCompleto, Off
SetTimer, AutoFood, 600000

autoRopeAndShovelIndex := 0
autoCaniVetesIndex := 0
autoFoodCombinationIndex := 0
toggle := false  ; Initialize the toggle variable at the start

^!p::Pause  ; Press Ctrl+Alt+P to pause. Press it again to resume.
^!s::Suspend, Toggle
^!r::Reload  ; Reload the script

!Esc:: ; Alt + Esc hotkey
    Process, Close, AutoHotkey.exe
return

;===== Rotacao Ataque =====

/:: ; full rotacao com utito
    if AutoPanickActive
        return
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Random, sleepDuration, 50, 60

	send, {F8}
    sleep %sleepDuration%
	send, {F1}
    sleep %sleepDuration%
    send, {F4}
    sleep %sleepDuration%
    send, 2
    sleep %sleepDuration%
    send, {F6}
    sleep %sleepDuration%
    send, {F2}
    sleep %sleepDuration%
    send, {F4}
    sleep %sleepDuration%
    send, 2
    sleep %sleepDuration%
    send, {F5}
    sleep %sleepDuration%
    send, {F3}
    sleep %sleepDuration%
    send, {F4}
    sleep %sleepDuration%
    send, 2
    sleep %sleepDuration%
    send, {F7}
    sleep %sleepDuration%
        
    Send, {Alt down}
    MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle
    Send, {Alt up}
    sleep %sleepDuration%
        
    Send, {Shift down}
    Click, Right, 1927 + offsetX, 741 + offsetY ; sqm cima
    Click, Right, 2049 + offsetX, 741 + offsetY ; sqm cima direita
    Click, Right, 2050 + offsetX, 870 + offsetY ; sqm direita
    Click, Right, 2051 + offsetX, 995 + offsetY ; sqm direita baixo
    Click, Right, 1924 + offsetX, 995 + offsetY ; sqm baixo
    Click, Right, 1801 + offsetX, 995 + offsetY ; sqm baixo esquerda
    Click, Right, 1801 + offsetX, 870 + offsetY ; sqm esquerda
    Click, Right, 1801 + offsetX, 744 + offsetY ; sqm cima esquerda
    Click, Right, 1925 + offsetX, 870 + offsetY ; sqm meio
    Send, {Shift up}
    sleep %sleepDuration%
Return

.:: ; full rotacao sem utito
    if AutoPanickActive
        return
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Random, sleepDuration, 50, 60

    send, {F1}
    sleep %sleepDuration%
    send, {F4}
    sleep %sleepDuration%
    send, 2
    sleep %sleepDuration%
    send, {F6}
    sleep %sleepDuration%
    send, {F2}
    sleep %sleepDuration%
    send, {F4}
    sleep %sleepDuration%
    send, 2
    sleep %sleepDuration%
    send, {F5}
    sleep %sleepDuration%
    send, {F3}
    sleep %sleepDuration%
    send, {F4}
    sleep %sleepDuration%
    send, 2
    sleep %sleepDuration%
    send, {F7}
    sleep %sleepDuration%
        
    Send, {Alt down}
    MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle
    Send, {Alt up}
    sleep %sleepDuration%
        
    Send, {Shift down}
    Click, Right, 1927 + offsetX, 741 + offsetY ; sqm cima
    Click, Right, 2049 + offsetX, 741 + offsetY ; sqm cima direita
    Click, Right, 2050 + offsetX, 870 + offsetY ; sqm direita
    Click, Right, 2051 + offsetX, 995 + offsetY ; sqm direita baixo
    Click, Right, 1924 + offsetX, 995 + offsetY ; sqm baixo
    Click, Right, 1801 + offsetX, 995 + offsetY ; sqm baixo esquerda
    Click, Right, 1801 + offsetX, 870 + offsetY ; sqm esquerda
    Click, Right, 1801 + offsetX, 744 + offsetY ; sqm cima esquerda
    Click, Right, 1925 + offsetX, 870 + offsetY ; sqm meio
    Send, {Shift up}
    sleep %sleepDuration%
Return

b:: ;1 combo rotacao
    if AutoPanickActive
        return
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Random, sleepDuration, 50, 60

    send, {F1}
    sleep %sleepDuration%
    send, {F4}
    sleep %sleepDuration%
    send, F2
    sleep %sleepDuration%
    send, {F6}
    sleep %sleepDuration%
        
    Send, {Alt down}
    MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle
    Send, {Alt up}
    sleep %sleepDuration%
        
    Send, {Shift down}
    Click, Right, 1927 + offsetX, 741 + offsetY ; sqm cima
    Click, Right, 2049 + offsetX, 741 + offsetY ; sqm cima direita
    Click, Right, 2050 + offsetX, 870 + offsetY ; sqm direita
    Click, Right, 2051 + offsetX, 995 + offsetY ; sqm direita baixo
    Click, Right, 1924 + offsetX, 995 + offsetY ; sqm baixo
    Click, Right, 1801 + offsetX, 995 + offsetY ; sqm baixo esquerda
    Click, Right, 1801 + offsetX, 870 + offsetY ; sqm esquerda
    Click, Right, 1801 + offsetX, 744 + offsetY ; sqm cima esquerda
    Click, Right, 1925 + offsetX, 870 + offsetY ; sqm meio
    Send, {Shift up}
    sleep %sleepDuration%
Return

n:: ;2 combo rotacao
    if AutoPanickActive
        return
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Random, sleepDuration, 50, 60

    send, {F2}
    sleep %sleepDuration%
    send, {F4}
    sleep %sleepDuration%
    send, 2
    sleep %sleepDuration%
    send, {F6}
    sleep %sleepDuration%
        
    Send, {Alt down}
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle
    Send, {Alt up}
    sleep %sleepDuration%
        
    Send, {Shift down}
    Click, Right, 1927 + offsetX, 741 + offsetY ; sqm cima
    Click, Right, 2049 + offsetX, 741 + offsetY ; sqm cima direita
    Click, Right, 2050 + offsetX, 870 + offsetY ; sqm direita
    Click, Right, 2051 + offsetX, 995 + offsetY ; sqm direita baixo
    Click, Right, 1924 + offsetX, 995 + offsetY ; sqm baixo
    Click, Right, 1801 + offsetX, 995 + offsetY ; sqm baixo esquerda
    Click, Right, 1801 + offsetX, 870 + offsetY ; sqm esquerda
    Click, Right, 1801 + offsetX, 744 + offsetY ; sqm cima esquerda
    Click, Right, 1925 + offsetX, 870 + offsetY ; sqm meio
    Send, {Shift up}
    sleep %sleepDuration%
Return

m:: ;3 combo rotacao
    if AutoPanickActive
        return
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Random, sleepDuration, 50, 60

    send, {F3}
    sleep %sleepDuration%
    send, {F4}
    sleep %sleepDuration%
    send, 2
    sleep %sleepDuration%
    send, {F5}
    sleep %sleepDuration%
        
    Send, {Alt down}
    MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle
    Send, {Alt up}
    sleep %sleepDuration%
        
    Send, {Shift down}
    Click, Right, 1927 + offsetX, 741 + offsetY ; sqm cima
    Click, Right, 2049 + offsetX, 741 + offsetY ; sqm cima direita
    Click, Right, 2050 + offsetX, 870 + offsetY ; sqm direita
    Click, Right, 2051 + offsetX, 995 + offsetY ; sqm direita baixo
    Click, Right, 1924 + offsetX, 995 + offsetY ; sqm baixo
    Click, Right, 1801 + offsetX, 995 + offsetY ; sqm baixo esquerda
    Click, Right, 1801 + offsetX, 870 + offsetY ; sqm esquerda
    Click, Right, 1801 + offsetX, 744 + offsetY ; sqm cima esquerda
    Click, Right, 1925 + offsetX, 870 + offsetY ; sqm meio
    Send, {Shift up}
    sleep %sleepDuration%
Return

;===== Combo com Direcao (exori min, waves, etc) =====;

Up::
    Send, {Ctrl down}{w}{Ctrl up} ; direcao pra cima
    Send, +{F1}                 ; exori min
return

Down::
    Send, {Ctrl down}{s}{Ctrl up} ; direcao pra baixo
    Send, +{F1}                 ; exori min
return

Left::
    Send, {Ctrl down}{a}{Ctrl up} ; direcao pra esquerda
    Send, +{F1}                 ; exori min
return

Right::
    Send, {Ctrl down}{d}{Ctrl up} ; direcao pra direita
    Send, +{F1}                 ; exori min
return

;===== Runas =====;

Numpad1:: ; 1 runa ataque aoe
While GetKeyState("Numpad1","P") && !AutoPanickActive
{
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Random, sleepDuration, 50, 60

    Send, {Alt down}{Numpad1}{Alt up}    
    MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle
    sleep %sleepDuration%
}
Return

Numpad2:: ; 2 runa ataque aoe
While GetKeyState("Numpad2","P") && !AutoPanickActive
{
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Random, sleepDuration, 50, 60

    Send, {Alt down}{Numpad2}{Alt up}    
    MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle
    sleep %sleepDuration%
}
Return

Numpad3:: ; 3 runa ataque aoe
While GetKeyState("Numpad3","P") && !AutoPanickActive
{
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Random, sleepDuration, 50, 60

    Send, {Alt down}{Numpad3}{Alt up}    
    MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle
    sleep %sleepDuration%
}
Return

Numpad0:: ; 4 runa ataque aoe
While GetKeyState("Numpad0","P") && !AutoPanickActive
{
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Random, sleepDuration, 50, 60

    Send, {Alt down}{Numpad0}{Alt up}    
    MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle
    sleep %sleepDuration%
}
Return

Numpad4:: ; 5 runa ataque aoe
While GetKeyState("Numpad4","P") && !AutoPanickActive
{
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Random, sleepDuration, 50, 60

    Send, {Alt down}{Numpad4}{Alt up}    
    MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle
    sleep %sleepDuration%
}       
Return

XButton2:: ; magic wall runa
While GetKeyState("XButton2","P") && !AutoPanickActive
{
    MouseGetPos, StartX, StartY
    Send, {Alt down}{Numpad0}{Alt up}
    MouseMove, %StartX%, %StartY%
    MouseClick, Left
    Random, sleepDuration, 40, 50
    sleep %sleepDuration%
}
return

XButton1:: ; runa principal ataque
While GetKeyState("XButton1","P") && !AutoPanickActive
{
    MouseGetPos, StartX, StartY
    Send, {Alt down}{Numpad4}{Alt up}
    MouseMove, %StartX%, %StartY%
    MouseClick, Left
    Random, sleepDuration, 40, 50
    sleep %sleepDuration%
}
return

;===== Quality of Life =====;

CapsLock:: ; autoescada
    if AutoPanickActive
        return
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
        
    Click, Right, 1927 + offsetX, 741 + offsetY ; sqm cima
    Click, Right, 2049 + offsetX, 741 + offsetY ; sqm cima direita
    Click, Right, 2050 + offsetX, 870 + offsetY ; sqm direita
    Click, Right, 2051 + offsetX, 995 + offsetY ; sqm direita baixo
    Click, Right, 1924 + offsetX, 995 + offsetY ; sqm baixo
    Click, Right, 1801 + offsetX, 995 + offsetY ; sqm baixo esquerda
    Click, Right, 1801 + offsetX, 870 + offsetY ; sqm esquerda
    Click, Right, 1801 + offsetX, 744 + offsetY ; sqm cima esquerda
    Click, Right, 1925 + offsetX, 870 + offsetY ; sqm meio
    Random, sleepDuration, 50, 60
    sleep %sleepDuration%
Return

x:: ; autoropeandshovel
    if AutoPanickActive
        return
    autoRopeAndShovelIndex := (autoRopeAndShovelIndex + 1) ; Increment the index
    if (autoRopeAndShovelIndex > 18) ; Reset if it exceeds 18
        autoRopeAndShovelIndex := 1

    Random, offsetX, -5, 5
    Random, offsetY, -5, 5

    switch (autoRopeAndShovelIndex) {
        case 1:
            Send, {o}
            Click, Left, 1927 + offsetX, 741 + offsetY ; sqm cima
        case 2:
            Send, {o}
            Click, Left, 2049 + offsetX, 741 + offsetY ; sqm cima direita
        case 3:
            Send, {o}
            Click, Left, 2050 + offsetX, 870 + offsetY ; sqm direita
        case 4:
            Send, {o}
            Click, Left, 2051 + offsetX, 995 + offsetY ; sqm direita baixo
        case 5:
            Send, {o}
            Click, Left, 1924 + offsetX, 995 + offsetY ; sqm baixo
        case 6:
            Send, {o}
            Click, Left, 1801 + offsetX, 995 + offsetY ; sqm baixo esquerda
        case 7:
            Send, {o}
            Click, Left, 1801 + offsetX, 870 + offsetY ; sqm esquerda
        case 8:
            Send, {o}
            Click, Left, 1801 + offsetX, 744 + offsetY ; sqm cima esquerda
        case 9:
            Send, {o}
            Click, Left, 1925 + offsetX, 870 + offsetY ; sqm meio
        case 10:
            Send, {p}
            Click, Left, 1927 + offsetX, 741 + offsetY ; sqm cima
        case 11:
            Send, {p}
            Click, Left, 2049 + offsetX, 741 + offsetY ; sqm cima direita
        case 12:
            Send, {p}
            Click, Left, 2050 + offsetX, 870 + offsetY ; sqm direita
        case 13:
            Send, {p}
            Click, Left, 2051 + offsetX, 995 + offsetY ; sqm direita baixo
        case 14:
            Send, {p}
            Click, Left, 1924 + offsetX, 995 + offsetY ; sqm baixo
        case 15:
            Send, {p}
            Click, Left, 1801 + offsetX, 995 + offsetY ; sqm baixo esquerda
        case 16:
            Send, {p}
            Click, Left, 1801 + offsetX, 870 + offsetY ; sqm esquerda
        case 17:
            Send, {p}
            Click, Left, 1801 + offsetX, 744 + offsetY ; sqm cima esquerda
        case 18:
            Send, {p}
            Click, Left, 1925 + offsetX, 870 + offsetY ; sqm meio
    }
Return

+x:: ; autocanivetes
    if AutoPanickActive
        return
    autoCaniVetesIndex := (autoCaniVetesIndex + 1) ; Increment the index
    if (autoCaniVetesIndex > 9) ; Reset if it exceeds 9
        autoCaniVetesIndex := 1

    Random, offsetX, -5, 5
    Random, offsetY, -5, 5

    switch (autoCaniVetesIndex) {
        case 1:
            Send, {Shift down}{p down}{p up}{Shift up}
            Sleep 10
            Click, Left, 1927 + offsetX, 741 + offsetY ; sqm cima
            Sleep 200
        case 2:
            Send, {Shift down}{[ down}{[ up}{Shift up}
            Sleep 10
            Click, Left, 2049 + offsetX, 741 + offsetY ; sqm cima direita
            Sleep 200
        case 3:
            Send, {Shift down}{] down}{] up}{Shift up}
            Sleep 10
            Click, Left, 2050 + offsetX, 870 + offsetY ; sqm direita
            Sleep 200
        case 4:
            Send, {Shift down}{p down}{p up}{Shift up}
            Sleep 10
            Click, Left, 2051 + offsetX, 995 + offsetY ; sqm direita baixo
            Sleep 200
        case 5:
            Send, {Shift down}{[ down}{[ up}{Shift up}
            Sleep 10
            Click, Left, 1924 + offsetX, 995 + offsetY ; sqm baixo
            Sleep 200
        case 6:
            Send, {Shift down}{] down}{] up}{Shift up}
            Sleep 10
            Click, Left, 1801 + offsetX, 995 + offsetY ; sqm baixo esquerda
            Sleep 200
        case 7:
            Send, {Shift down}{p down}{p up}{Shift up}
            Sleep 10
            Click, Left, 1801 + offsetX, 870 + offsetY ; sqm esquerda
            Sleep 200
        case 8:
            Send, {Shift down}{[ down}{[ up}{Shift up}
            Sleep 10
            Click, Left, 1801 + offsetX, 744 + offsetY ; sqm cima esquerda
            Sleep 200
        case 9:
            Send, {Shift down}{] down}{] up}{Shift up}
            Sleep 10
            Click, Left, 1925 + offsetX, 870 + offsetY ; sqm meio
            Sleep 200
    }
Return

AutoFood:
    if AutoPanickActive
        return
    If WinActive("ahk_class Qt5158QWindowOwnDCIcon")
    {
        autoFoodCombinationIndex := (autoFoodCombinationIndex + 1) ; Increment the index
        if (autoFoodCombinationIndex > 4)  ; Reset the index if it exceeds 4
            autoFoodCombinationIndex := 1

        ; Send the appropriate key based on the combination index
        switch (autoFoodCombinationIndex) {
            case 1:
                Send, {F9}
                Sleep 10
            case 2:
                Send, {F10}
                Sleep 10
            case 3:
                Send, {F11}
                Sleep 10
            case 4:
                Send, {F12}
                Sleep 10
        }
    }
return

AutoRefill:
    if AutoPanickActive
        return
    If WinActive("ahk_class Qt5158QWindowOwnDCIcon")
    {
        Send, {=} ;mushroom 
        Sleep 10
        Send, {i} ;deposit all
        Sleep 10
        Send, {u} ;refill
        Sleep 10
    }
return

`:: ; autoloot
    if AutoPanickActive
        return
    Send, {Shift down}
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Click, Right, 1927 + offsetX, 741 + offsetY ; sqm cima
    Click, Right, 2049 + offsetX, 741 + offsetY ; sqm cima direita
    Click, Right, 2050 + offsetX, 870 + offsetY ; sqm direita
    Click, Right, 2051 + offsetX, 995 + offsetY ; sqm direita baixo
    Click, Right, 1924 + offsetX, 995 + offsetY ; sqm baixo
    Click, Right, 1801 + offsetX, 995 + offsetY ; sqm baixo esquerda
    Click, Right, 1801 + offsetX, 870 + offsetY ; sqm esquerda
    Click, Right, 1801 + offsetX, 744 + offsetY ; sqm cima esquerda
    Click, Right, 1925 + offsetX, 870 + offsetY ; sqm meio
    Send, {Shift up}
    Sleep 10
return

^WheelUp:: ; PuxarItemsMiraPraBpLoot
    if AutoPanickActive
        return
    MouseGetPos, StartX, StartY
    Click Down
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Click Up, 3519 + offsetX, 940 + offsetY
    MouseMove, %StartX%, %StartY%
    Sleep 10
return

^WheelDown:: ; PuxarItemsBpLootPraMira
    if AutoPanickActive
        return
    MouseGetPos, StartX, StartY
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Click Down, 3519 + offsetX, 940 + offsetY
    MouseMove, %StartX%, %StartY%
    Click Up
    Sleep 10
return

!WheelUp:: ; PuxaFlorChao(Mira)PraBpFlor
    if AutoPanickActive
        return
    MouseGetPos, StartX, StartY
    Click Down
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Click Up, 3515 + offsetX, 1125 + offsetY
    MouseMove, %StartX%, %StartY%
    Sleep 10
return

!WheelDown:: ; PuxaFlorBpFlorPraChao(Mira)
    if AutoPanickActive
        return
    MouseGetPos, StartX, StartY
    Random, offsetX, -5, 5
    Random, offsetY, -5, 5
    Click Down, 3515 + offsetX, 1125 + offsetY
    MouseMove, %StartX%, %StartY%
    Click Up
    Sleep 10
return

;===== Troca de Itens =====

RingAmmyPadrao:
!<1::
    if AutoPanickActive
        return
    Send, !{F5}
    Sleep 100
    Send, !{F6}
return

;===== No Die =====

AutoPanick:
    if AutoPanickActive
        return

    xCoord := 830 ; X coordinate
    yCoord := 75  ; Y coordinate

    PixelGetColor, color, %xCoord%, %yCoord%, RGB

    RedValue := (color >> 16) & 0xFF
    GreenValue := (color >> 8) & 0xFF
    BlueValue := color & 0xFF

    if (RedValue > GreenValue + 50 && RedValue > BlueValue + 50)
    {
        AutoPanickActive := true

        ; AutoPanick actions here
        Send, {5} ;stone skin amulet (ssa)
        Sleep 10    
        Send, {6} ;mighty ring
        Sleep 10    
        Send, {8} ;avatar
        Sleep 50
        Send, {7} ;magic cura forte
        Sleep 10
        Send, {1} ;pocao cura forte
        Sleep 10

        AutoPanickActive := false
    }
return

;===== Bot =====

`;::  ; Toggle AfkKillCompleto (Use a valid hotkey)
toggle := !toggle  ; Reverse the toggle value

if toggle {
    ToolTip, AfkKillCompleto Started
    SetTimer, AfkKillCompleto, 100
} else {
    SetTimer, AfkKillCompleto, Off
    ToolTip, AfkKillCompleto Stopped
    Sleep, 1000
    ToolTip
}
Return

AfkKillCompleto:
if (toggle = false) || AutoPanickActive {
    Return
}

Random, offsetX, -5, 5
Random, offsetY, -5, 5
Random, sleepDuration, 50, 60

send, {F1}
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}
send, {F4}
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}
send, 2
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}
send, {F6}
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}
send, {F2}
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}
send, {F4}
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}
send, 2
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}
send, {F7}
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}
send, {F3}
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}
send, {F4}
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}
send, 2
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}
send, {F5}
sleep, %sleepDuration%

Send, {Alt down}
MouseClick, Left, 3134 + offsetX, 215 + offsetY ; sqm primeiro monstro battle
Send, {Alt up}
sleep, %sleepDuration%
if (toggle = false) || AutoPanickActive {
    Return
}

Send, {Shift down}
Click, Right, 1927 + offsetX, 741 + offsetY ; sqm cima
Click, Right, 2049 + offsetX, 741 + offsetY ; sqm cima direita
Click, Right, 2050 + offsetX, 870 + offsetY ; sqm direita
Click, Right, 2051 + offsetX, 995 + offsetY ; sqm direita baixo
Click, Right, 1924 + offsetX, 995 + offsetY ; sqm baixo
Click, Right, 1801 + offsetX, 995 + offsetY ; sqm baixo esquerda
Click, Right, 1801 + offsetX, 870 + offsetY ; sqm esquerda
Click, Right, 1801 + offsetX, 744 + offsetY ; sqm cima esquerda
Click, Right, 1925 + offsetX, 870 + offsetY ; sqm meio
Send, {Shift up}
sleep, %sleepDuration%
Return

in this script everything will work until the autopanick conditions (pixel colors) are met, then everything stops, autopanick sends its keys, and after sent, everythink works back, right?