There's no obvious way I've found looking at the AHK API to detect when the active window changes and to act on that information.
What I'd like to do is write an AHK script that when an application is focused, all of the other windows in the window group are also brought to the front.
Thanks!
Jeff

Method to detect active window change?
Started by
jaxelrod
, May 10 2011 09:20 PM
6 replies to this topic
#1
-
Posted 10 May 2011 - 09:20 PM

Check out my blog, http://www.tipninja.com where I share tips from optimizing your PC use, to cooking and food storage and household organization to personal happiness.
Look at shell hooks: <!-- m -->http://www.autohotke... ... 323#123323<!-- m -->
#2
-
Posted 10 May 2011 - 09:31 PM

aboutscript ⋰ apps ⋱ scripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run
You can use ShellHook to detect window activations.
:wink:
Gui +LastFound hWnd := WinExist() DllCall( "RegisterShellHookWindow", UInt,Hwnd ) MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" ) OnMessage( MsgNum, "ShellMessage" ) Return ShellMessage( wParam,lParam ) { WinGetTitle, title, ahk_id %lParam% If (wParam=4) { ;HSHELL_WINDOWACTIVATED ToolTip WinActivated`n%Title% sleep 1000 ToolTip } }Frankie beat me

#3
-
Posted 10 May 2011 - 09:34 PM

Thanks so much to both of you! I'll give it a shot.
#4
-
Posted 11 May 2011 - 03:00 AM

Check out my blog, http://www.tipninja.com where I share tips from optimizing your PC use, to cooking and food storage and household organization to personal happiness.
thank you for this, works perfectly.
There's a bug in the DLL (not the script I'm sure) where if Remote Desktop Connection has a full window, the scripts stops detecting thewindow change. If you restore RDC the script continues to detct the window changes.
There's a bug in the DLL (not the script I'm sure) where if Remote Desktop Connection has a full window, the scripts stops detecting thewindow change. If you restore RDC the script continues to detct the window changes.
#5
-
Posted 01 June 2012 - 08:47 PM

Hello again,
I never get a value 4 (HSHELL_WINDOWACTIVATED) from wParam.
OS Windows 7 Professional, 64 Bit SP1. Any hints?
Many thanks and greetings
hotkeyguy
#6
-
Posted 01 April 2015 - 12:49 AM

Depending on which window is activated you will either get wParam 4 (HSHELL_WINDOWACTIVATED) or 32772 (0x8004; HSHELL_RUDEAPPACTIVATED). The latter occurs much more frequently but you need to check for both to be safe.
#7
-
Posted 01 April 2015 - 10:45 AM
