如何在 ahk 中显示 paused/resumed 之后的消息框?

How to show a msgbox after paused/resumed in ahk?

我正在尝试在暂停和恢复时显示 Msgbox。我卡住了。它不执行 Msgbox 语句。我可以理解原因并修改了代码但没有运气。非常感谢任何有关在状态更改后显示 Msgbox 的解决方法的帮助。

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

return

因为

The #If(Win) directive is useful when a particular program ignores a key (- combination) or performs some action you find undesirable.

这应该有效:

!Pause::
    MsgBox, , , "Paused", 1 
    Pause
Return


#If (A_IsPaused)

    !Pause::
        MsgBox, , , "Resumed", 1
        Pause
    Return
    
#If

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

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

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