Reputation: 13
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!
P.S. I would like the alert to contain the name of the current window.
Upvotes: 0
Views: 834
Reputation: 504
CurrentTitle := ""
SetTimer, CheckWindow, 1000
return
CheckWindow:
WinGetTitle, NewTitle, A
if (CurrentTitle != NewTitle){
ToolTip % "Window changed to: " NewTitle
CurrentTitle := NewTitle
}
return
Upvotes: 2