Jump to content
Sign in to follow this  
gsx

[Solved] Desktop Detection

Recommended Posts

gsx

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

Share this post


Link to post
Share on other sites
ajag

The CLASS is "Progman" not "Program"

If WinActive("[CLASS:Progman; Title:Program Manager]") Then

A-Jay


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

Share this post


Link to post
Share on other sites
gsx

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)

Share this post


Link to post
Share on other sites
ajag

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)

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.