【问题标题】:How can I use an AutoHotkey message box with a timer when the Text of the message contains variables?当消息的文本包含变量时,如何使用带有计时器的 AutoHotkey 消息框?
【发布时间】:2019-08-12 19:41:38
【问题描述】:

在调试 AHK 脚本时,我喜欢添加 MsgBox 语句以帮助我了解已到达一段代码,并且我可能希望在消息中包含一些变量。我希望消息框有一个超时,所以它会在 5 秒后自动关闭。我想坚持使用消息框,而不是使用工具提示或依赖我需要包含在脚本中的函数。

我正在寻找单行代码,以便在不需要时轻松将其注释掉。

我遇到的问题是将多个变量传递给 Text 参数的 MsgBox 将它与 Timeout 参数的定位混淆。有没有另一种方式来编写我的变量,这样它们就不会被解释为单独的参数?

WinGetPos, X, Y, W, H, A  ; "A" to get the active window's position.

; The timeout on this example does not work and the 5 is not shown.
MsgBox, 64, Debug, The active window is at %X%, %Y%, %W%, %H%, 5

; The timeout on this example works.  Is there a way to write this on one line?
msg=The active window is at %X%, %Y%, %W%, %H%
MsgBox, 64, Debug, %msg%, 5

【问题讨论】:

  • 发布到 Stack Overflow 就像有一只橡皮鸭。在试图清楚地解释我真正在寻找什么的过程中,我想到了有助于我搜索的新术语。

标签: autohotkey


【解决方案1】:

如果您的消息文本中有逗号,则需要使用反引号 ` 符号对其进行转义。

MsgBox, 64, Debug, The active window is at %X%`, %Y%`, %W%`, %H%, 5

还有其他字符也需要escaped

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-09
    • 1970-01-01
    • 2018-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多