Active Window Question

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
JustMePatrick
Posts: 3
Joined: 16 Jan 2018, 15:11

Active Window Question

16 Jan 2018, 15:21

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.
cryosis
Posts: 2
Joined: 14 Jan 2018, 07:36

Re: Active Window Question

16 Jan 2018, 18:05

I'm new here, so I may not be right here; but it looks like your looking for WinWait?

Code: Select all

^q::
WinWait, windowName
do stuff
return
Alternatively you could do this:

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
	}
}
iPhilip
Posts: 819
Joined: 02 Oct 2013, 12:21

Re: Active Window Question

16 Jan 2018, 18:52

You can try this as it doesn't require waiting for the window or looping:

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
}
Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder, ruespe and 369 guests