I would like to see if there is a way to determine If at anytime the active window becomes a specific value then execute a series of commands that logs me on.
#IfWinExits works great for only accepting a specific Hot Key Sequence to execute my code.
However, it would be good if it saw the window title was X then performed y commands without prompting.
Active Window Question
-
- Posts: 3
- Joined: 16 Jan 2018, 15:11
Re: Active Window Question
I'm new here, so I may not be right here; but it looks like your looking for WinWait?
Alternatively you could do this:
Code: Select all
^q::
WinWait, windowName
do stuff
return
Code: Select all
^q::
loop ; Infinite loop until window exists (or could use active depending on what you want)
{
if (IfWinExist)
{
do stuff
return ; Ends the script
}
}
Re: Active Window Question
You can try this as it doesn't require waiting for the window or looping:Cheers!
Code: Select all
Gui +HwndHwnd
DllCall("RegisterShellHookWindow", "Ptr", Hwnd)
MsgNum := DllCall("RegisterWindowMessage", "Str", "SHELLHOOK")
OnMessage(MsgNum, "ShellMessage")
Return
ShellMessage(wParam, lParam) {
WinGetTitle, Title, ahk_id %lParam%
if ((wParam = 1 ; HSHELL_WINDOWCREATED
|| wParam = 4) ; HSHELL_WINDOWACTIVATED
&& InStr(Title, "Notepad"))
ToolTip, %Title% ; Replace with your commands
}
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)