Sign in to follow this  
Followers 0
gsx

[Solved] Desktop Detection

5 posts in this topic

#1 ·  Posted (edited)

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



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

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

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

Great! A-Jay, thank you so much.

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  
Followers 0