如何在 ahk 中暂停/恢复后显示 msgbox?

问题描述

我试图在暂停和恢复时显示一个 MsgBox。我被困住了。它不执行 MsgBox 语句。我可以理解原因并在没有运气的情况下修改代码。对于在状态更改后显示 MsgBoxes 的解决方法的任何帮助,我们真的很感激。

!Pause::
If (A_IsPaused)
{               
    MsgBox,"Resumed",1
    Pause
}
Else
{
    MsgBox,"Paused",1     
    Pause
}

返回

解决方法

问题是因为您也暂停了该特定的热键线程。
另一个答案只是因为另一个暂停在另一个热键中,因此使用 #if 是错误的。

您应该像这样使用 OperateOnUnderlyingThread 命令的 Pause(docs) 参数:

!Pause::
    If (A_IsPaused)
    {               
        MsgBox,"Resumed",1
        Pause,1
    }
    Else
    {
        MsgBox,"Paused",1     
        Pause,1
    }
return
,

因为

#If(Win) 指令在特定程序忽略 键(- 组合)或执行一些您认为不受欢迎的操作。

这应该有效:

Task