I am having a problem with my script which stops working properly, roughly after every 20-30 minutes of running. The problem seems to be with the loop that i have constructed and it stopping after that specific time. It's not the entire script that stops working because for example when i press another bind on caps lock it behaves normally. Furthermore when reloading the autohotkey script i get a message that "The script could not be reloaded." which I have never experienced before this problem with the loop.
So here's the code:
#IfWinActive Tibia
SplashTextOn, 100, 40, Running, WASD
WinMove, Running,, 1, 21
;SUSPEND AND INFORMATION===================================================
CapsLock::
Suspend
Toggle := !Toggle
if (Toggle = 0)
SplashTextOn, 90, 25, Running, WASD
WinMove, Running,, 1, 27
if (Toggle = 1)
{
SplashTextOn, 120, 40, NOT RUNNING, TYPING
WinMove, NOT RUNNING,, 1497, 69
}
return
NumpadAdd::
MsgBox, You have 0.5 seconds to mouse over MAIN BACKPACK.
Sleep, 500
MouseGetPos, mainbpxpos, mainbpypos
MsgBox, You have 0.5 seconds to mouse over MAIN SLOT BACKPACK.
Sleep, 500
MouseGetPos, mainbpslotxpos, mainbpslotypos
MsgBox, You have 0.5 seconds to mouse over FOOD.
Sleep, 500
MouseGetPos, foodxpos, foodypos
MsgBox, You have 0.5 seconds to mouse over HAND.
Sleep, 500
MouseGetPos, handxpos, handypos
MsgBox, You have 0.5 seconds to mouse over BLANK on GROUND.
Sleep, 500
MouseGetPos, blankgroundxpos, blankgroundypos
MsgBox, You have 0.5 seconds to mouse over LAST BLANK.
Sleep, 500
MouseGetPos, lastblankxpos, lastblankypos
MsgBox, You have 0.5 seconds to mouse over MADE RUNES POS.
Sleep, 500
MouseGetPos, maderunesxpos, maderunesypos
MsgBox, You have 0.5 seconds to mouse over RUNBACK POSITION (OUT HOUSE).
Sleep, 500
MouseGetPos, runbackxpos, runbackypos
MsgBox, You have 0.5 seconds to mouse over RUN POSITION (IN HOUSE).
Sleep, 500
MouseGetPos, runxpos, runypos
InputBox, blankrunesleft, Blank runes left, Enter the blank runes left, , 200, 170
MsgBox, SCRIPT IS ABOUT TO RUN, CLOSE ALL BPS!
BreakLoop = 0
iamout = 0
enemy = 0
Loop
{
if (BreakLoop = 1) {
break
}
Loop, %blankrunesleft%
{
if (BreakLoop = 1) {
break
}
SetMouseDelay, 5
battleOne := ReadMemory(0x5C6950,"Tibia")
;Notify(battleOne)
if (battleOne > 0) {
MouseClick, left, runxpos, runypos
Sleep, 30000
MouseClickDrag, left, mainbpslotxpos, mainbpslotypos, blankgroundxpos, blankgroundypos
Sleep, 400
Send, {Control Down}g{Control Up}
Sleep, 200
Send, {Enter}
Sleep, 5000
iamout = 0
}
if (battleOne == 0) {
if (iamout == 0) {
MouseClick, right, mainbpxpos, mainbpypos
Sleep, 200
MouseClick, right, blankgroundxpos, blankgroundypos
Sleep, 200
MouseClickDrag, left, blankgroundxpos, blankgroundypos, mainbpslotxpos, mainbpslotypos
Sleep, 200
MouseClick, left, runbackxpos, runbackypos
iamout = 1
Sleep, 500
}
}
mana := ReadMemory(0x5C682C,"Tibia")
if (iamout == 1) {
if (mana > 999) {
MouseClick, right, foodxpos, foodypos
Sleep, 60
MouseClick, right, foodxpos, foodypos
Sleep, 60
MouseClick, right, foodxpos, foodypos
Sleep, 100
MouseClickDrag, left, lastblankxpos, lastblankypos, handxpos, handypos
Sleep, 350
Send, Adori Vita Vis
Sleep, 100
Send, {Enter}
Sleep, 500
MouseClickDrag, left, handxpos, handypos, lastblankxpos, lastblankypos
Sleep, 350
blankrunesleft -= 1
}
}
if (iamout == 1) {
if (blankrunesleft == 0) {
Sleep, 100
MouseClick, left, runxpos, runypos
Sleep, 2000
MouseClickDrag, left, mainbpslotxpos, mainbpslotypos, maderunesxpos, maderunesypos
Sleep, 400
MouseClick, right, mainbpxpos, mainbpypos
Sleep, 500
blankrunesleft = 20
iamout = 0
}
}
}
}
Esc::
BreakLoop = 1
return
#IfWinActive
Edit: To add up, I have restarted the pc and done 2 more tests on this script. The result was that it always stops running properly, after exactly 22 minutes. I have no idea what could be causing this, would appreciate any help