How to detect when the desktop become ative?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
katia
Posts: 2
Joined: 09 Aug 2022, 00:27

How to detect when the desktop become ative?

Post by katia » 15 Aug 2022, 02:48

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.

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: How to detect when the desktop become ative?

Post by mikeyww » 15 Aug 2022, 06:51

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
}

Post Reply

Return to “Ask for Help (v1)”