【发布时间】:2017-03-17 21:20:25
【问题描述】:
我正在尝试制作一个 ahk 脚本,当新窗口打开(或重新聚焦)时会提醒您。换句话说,我希望它检测当前窗口何时发生变化。我尝试比较窗口名称以检测差异:
0::
WinGetTitle, title, A
windowTitle=%title%
MsgBox, "The current window is %title%."
return
9::
WinGetTitle, title2, A
if (%title2% = %title%)
{
success=1
}
else
{
MsgBox, "The current window changed to %title2%."
}
return
但是,
1) 我显然在变量中使用了非法字符;和
2)我宁愿使用与此不同的方法;
提前致谢!
我希望警报包含当前窗口的名称。
【问题讨论】:
-
在
if中使用括号时,不要使用%,因为变量已经自动展开了。 -
哇!有效!当我阅读错误消息时,我看着我,好像我不能在变量中使用引号。谢谢!
标签: automation autohotkey