【发布时间】: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