Jump to content

[Solved] Desktop Detection


gsx
 Share

Recommended Posts

Hi,

Since I cannot find a solution, I hope somebody can tell it.

I like to show a tooltip when Desktop is on focus. I tried the following code but it does not work.

AutoItSetOption("WinTitleMatchMode", 4)

While 1
    If WinActive("[CLASS:Program; Title:Program Manager]") Then
        ToolTip("Desktop is active.")
    Else
        ToolTip("Desktop is not active")
    EndIf
    Sleep(88)
WEnd

Thanks.

Edited by gsx
Link to comment
Share on other sites

Thank you A-Jay, it worked!

By the way, is it possible to detect Desktop by just hovering over it, which does not require necessarily to activate desktop?

This thread seems to be talking about it but I cannot apply the code to my need.

Opt("WinTitleMatchMode", 4)
$hWnd = WinGetHandle("classname=Progman")
DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", 0x111, "int", 28931, "int", 0)
Link to comment
Share on other sites

Try this

#include <WinAPI.au3>

$DesktopHandle = ControlGetHandle("[CLASS:Progman]", "", "SysListView321")
While 1
    $MousePos = _WinAPI_GetMousePos()
    $WinHandle = _WinAPI_WindowFromPoint($MousePos)
    If $WinHandle = $DesktopHandle Then MsgBox(0,"Ding-Dong","Gotcha")
    Sleep(100)
WEnd

A-Jay

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...