Code: Select all
HotKey setting_Trigger, ShowGUI
My initial thought is, in my ShowGUI function, I can use MouseGetPos and WinGetClass to check the class of the window under the mouse. If it is one of WorkerW, Shell_TrayWnd, or Shell_SecondaryTrayWnd then it's over the desktop. Code example below.
But I'm wondering if there is a better way to achieve what I am after?
Code: Select all
#Requires AutoHotkey v2.0
#Warn Unreachable, off
#SingleInstance Force
HotKey "^d", ShowGUI
ShowGUI(ThisHotKey)
{
Local CMM := A_CoordModeMouse
A_CoordModeMouse := "Screen"
MouseGetPos(&mousePositionLeft, &mousePositionTop, &windowUnderMouse_windowID)
windowUnderMouse_class := WinGetClass("ahk_id " windowUnderMouse_windowID)
if (windowUnderMouse_class == "WorkerW") or (windowUnderMouse_class == "Shell_TrayWnd") or (windowUnderMouse_class == "Shell_SecondaryTrayWnd")
{
; over desktop
return
}
msgbox "not over desktop"
}