I want to execute a script when the desktop is visible but I have a problem
Minimizing all or the last not minimized window will make "Shell_TrayWnd" the active window not WorkerW(which is the desktop)
If I create a group with those two,it will work but it will also work if the last active window is not minimized(the desktop is not visible)and I click on the taskbar
Is there is a way to tell if the desktop is visible?
Re: Is there is a way to tell if the desktop is visible?
If the desktop is active then the active window has class Progman or WorkerW.
However, that may not be sufficient. What if the desktop is the active window, but an inactive window (e.g. Notepad) is taking up most of the screen.
(And as you mentioned, if the taskbar is active, there may be inactive windows obscuring part/all of the desktop.)
So, I think the best solution is to check that each visible window (that has an alt-tab icon/taskbar button), is minimised. If all of those windows are minimised, then the desktop is visible.
I have 2 functions, linked below, that attempt to determine whether a window has an alt-tab icon/taskbar button. Cheers.
However, that may not be sufficient. What if the desktop is the active window, but an inactive window (e.g. Notepad) is taking up most of the screen.
(And as you mentioned, if the taskbar is active, there may be inactive windows obscuring part/all of the desktop.)
So, I think the best solution is to check that each visible window (that has an alt-tab icon/taskbar button), is minimised. If all of those windows are minimised, then the desktop is visible.
I have 2 functions, linked below, that attempt to determine whether a window has an alt-tab icon/taskbar button. Cheers.
Code: Select all
q:: ;is desktop visible
MsgBox, % IsDesktopVisible()
return
;[JEE_WinHasTaskbarButton, JEE_WinHasAltTabIcon]
;alt-tab replacement - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=37184
IsDesktopVisible()
{
local
vDHW := A_DetectHiddenWindows
DetectHiddenWindows, Off
WinGet, vWinList, List
;vOutput := "" ;diagnostic
vCount := 0
Loop % vWinList
{
hWnd := vWinList%A_Index%
WinGet, vMinMax, MinMax, % "ahk_id " hWnd
if (vMinMax = -1) ;-1: minimised
continue
;vIsVisWin := JEE_WinHasTaskbarButton(hWnd)
vIsVisWin := JEE_WinHasAltTabIcon(hWnd)
if vIsVisWin
vCount++
;diagnostic:
;WinGetTitle, vWinTitle, % "ahk_id " hWnd
;WinGetClass, vWinClass, % "ahk_id " hWnd
;if vIsVisWin
; vOutput .= vMinMax "|" vWinTitle "|" vWinClass "`r`n"
}
;diagnostic:
;if vCount
; MsgBox, % vOutput
DetectHiddenWindows, % vDHW
return !vCount
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Who is online
Users browsing this forum: Chunjee, Hansielein, Lpanatt and 320 guests