0

问题

  • 基本上,标题说明了一切!如何通过热键停止执行热键?
  • 如何在不关闭脚本的情况下执行此操作?
  • 如何明确设置热键以优先于特定循环?

解释

我有一个执行数百次的循环(附加代码),我想创建一个终止开关。如果我停止运行脚本,我不想重新打开它,而且我需要长时间的睡眠,这样我就可以用鼠标来愚弄它了。

我正在查看各种页面,例如tutorialbreak

我试过的

例如,我应该以某种方式命名我的循环吗?因为Break不带参数,我在想:没有办法指定要中断的内容。

另一个例子:我应该在循环中添加一个热键来中断吗?如果是这样,我该怎么做?只是^!p::在每个热键下扔进一个巢穴?还是有另一种方法可以将热键添加到热键(例如,使用GetKeyState)?

答案格式

如果可能,请 使用以下代码显示不要告诉您的答案:

^!i::
{
    Loop 1300
    {
        Send ^+{PrintScreen}
        Sleep 1500
        MouseClickDrag, left, 0, 100, 600, 400
        Sleep 1000
        Send 1
        Sleep 500
    }
    Return
}
^!o::
{
    Loop 1323
    {
        Send ^+{PrintScreen}
        Sleep 1500
        MouseClickDrag, left, 0, 200, 600, 400
        Sleep 1000
        Send 1
    }
    Return
}
4

1 回答 1

1

如果您想要一个受控停止,即在脚本中的某个点,那么您可以使用热键设置一个变量并在脚本中测试该变量。当变量已设置且 IF 语句为真时,您重置该变量并退出循环。否则,您可以通过 reload 命令在随机点终止脚本。这样脚本关闭,但立即重新打开。

^!i::
MyStopVariable:=0 ; Set the variable to 0
Loop 1300
{
    If MyStopVariable
        Exit ; Or Break if you want to finish something of after the loop
    Send ^+{PrintScreen}
    Sleep 1500
    MouseClickDrag, left, 0, 200, 600, 400
    Sleep 1000
    If MyStopVariable
        Exit ; Or Break if you want to finish something of after the loop
    Sleep 500
}
Return

^!o::
MyStopVariable:=0 ; Set the variable to 0
Loop 1323
{
    If MyStopVariable
        Exit ; Or Break if you want to finish something of after the loop
    Send ^+{PrintScreen}
    Sleep 1500
    MouseClickDrag, left, 0, 200, 600, 400
    Sleep 1000
    If MyStopVariable
        Exit ; Or Break if you want to finish something of after the loop
    Send 1
}
Return

^!s:: ; Ctrl+Alt+s = stop
MyStopVariable:=1
Return

或者,您可以使用原始代码并添加重新加载。

^!s:: ; Ctrl+Alt+s = stop
    Reload
Return
于 2014-06-20T09:37:13.157 回答