Page 1 of 1

How to detect when the desktop become ative?

Posted: 15 Aug 2022, 02:48
by katia
There's any window event that happens or any WINAPI, in could tell me when the desktop 'Progman' becomes the foreground window?

I would like to avoid 'hackish' things like using Settimers constantly checking WinActive or something similar.

So far what I tried was listening to EVENT_SYSTEM_MINIMIZESTART using SetWinEventHook and on each notification compare the title/class to check if it's 'Progman'.

I wonder if there's any 'better' option to do this.

Re: How to detect when the desktop become ative?

Posted: 15 Aug 2022, 06:51
by mikeyww
Welcome to this AutoHotkey forum!

Although you can use a WinWait, I think you will find that one can view the desktop without having it be the active window-- just as with other windows.

Code: Select all

#SingleInstance Force
GroupAdd, desktop, ahk_class WorkerW
GroupAdd, desktop, ahk_class Progman
Loop {
 WinWaitActive, ahk_group desktop
 MsgBox, 64, Done, Yep!
 WinWaitNotActive
}