I'm trying to make an ahk script that alerts you when a new window is opened (or brought back to focus). In other words, I want it to detect when the current window changes. I've tried comparing the window names to detect a difference:
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
But,
1)I'm apparently using illegal characters in the variables; and
2)I'd rather use a different method than this;
Thanks in advance!
PS I would like the alert to contain the name of the current window.
CurrentTitle := ""
SetTimer, CheckWindow, 1000
return
CheckWindow:
WinGetTitle, NewTitle, A
if (CurrentTitle != NewTitle){
ToolTip % "Window changed to: " NewTitle
CurrentTitle := NewTitle
}
return
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.