Autohotkey 我需要中断自动热键脚本,然后在其他位置重新启动它。

Autohotkey 我需要中断自动热键脚本,然后在其他位置重新启动它。,autohotkey,Autohotkey,如果脚本挂在我的一个subrutines中,我想中断它,并使它从我的getout标签继续 类似暂停切换的东西,可以让我在暂停结束后更改线程的执行点 这可能吗?您可以使用try/catch,当发现错误时,在其他位置运行事先编写的单独脚本,然后终止原始脚本 示例: loop, read, c:\storefile.txt { store_select := A_index - 1 sleep, 1000 gosub, selectstore gosub, login gosub, makeandor

如果脚本挂在我的一个subrutines中,我想中断它,并使它从我的getout标签继续

类似暂停切换的东西,可以让我在暂停结束后更改线程的执行点


这可能吗?

您可以使用try/catch,当发现错误时,在其他位置运行事先编写的单独脚本,然后终止原始脚本

示例:

loop, read, c:\storefile.txt
{
store_select := A_index - 1
sleep, 1000
gosub, selectstore
gosub, login
gosub, makeandorrunreport
gosub, Emailreport
getout: ; label pointer for logging out and moving on
gosub, logout
gosub, startprism
}
pause

我宁愿担心你的剧本被挂起来;此外,(过度)使用goto标签也很糟糕。它通常只在遇到意外错误时挂起。我将记录错误,以便稍后对其进行解释,但同时我希望继续进行下一个循环迭代。我通常使用循环从屏幕上的给定点复制文本,只有当复制的内容与预期相符时才会中断。但是,我控制的软件中的意外错误可以阻止我的任何突发事件爆发。因此,如果我检测到挂起,我真的需要一种方法来强制我的脚本移动到注销标签。
try  ; Attempts to execute code.
{
    loop, read, c:\storefile.txt
    {
        store_select := A_index - 1
        sleep, 1000
        gosub, selectstore
        gosub, login
        gosub, makeandorrunreport
        gosub, Emailreport
        getout: ; label pointer for logging out and moving on
        gosub, logout
        gosub, startprism
    }
    pause
}
catch e  ; Handles the first error/exception raised by the block above.
{
    Run, Script\from\separate\location.ahk  ; Run script from somewhere else.
    ExitApp ; Kill off the current script.
}