我的脚本无法正常运行,大约每运行20-30分钟后就会出现问题。问题似乎与我构建的循环有关,并且在特定时间之后停止。这不是整个脚本停止工作,因为例如当我按下大写锁上的另一个绑定时它表现正常。此外,重新加载autohotkey脚本时,我收到一条消息“无法重新加载脚本”。我在循环这个问题之前从未体验过。
所以这是代码:
#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
编辑:为了加起来,我重新启动了电脑,并在这个脚本上再做了2次测试。结果是它在22分钟后总是停止正常运行。我不知道是什么导致这种情况,不胜感激任何帮助
答案 0 :(得分:1)
也许你重新安排了一些事情。
使用其他热键例程将其移至顶部;热键应始终位于脚本的顶部。
Esc::
BreakLoop = 1
return
在最后return
{
这将使循环结束时脚本不会退出。
关于你每22分钟停一次 - 这可能是循环序列的长度吗?由于时间似乎是一致的,你应该能够通过留意同时发生的事件来找到问题。
另外,当它说它不会重新加载时,你能说出脚本在哪一行吗?如果右键单击托盘图标并选择“打开”,您将能够看到正在处理的行的状态。 这种调试方法还会显示每行处理和运行的时间。在你的情况下,这可能是非常有价值的。