Jump to content

How to determine if Program Manager has focus?


qwert
 Share

Recommended Posts

I need a way to determine if the desktop is "up" ... like after the user clicks Show Desktop.

Autoit Window Info detects it correctly, but my script steps produce a blank result.  (Other windows are correctly reported.)

$sTitle = WinGetTitle("[active]")
MsgBox (0, "", $sTitle, 0)

Any suggestion will be appreciated.

 

None.thumb.PNG.1e7dcbfc6032ec74f624fd4e3

Detect_PMgr.thumb.PNG.433e16f775f38214c8

 

 

Link to comment
Share on other sites

Works fine when Program Manager is actually active.

WinActivate("Program Manager")

$sTitle = WinGetHandle("[ACTIVE]")
ConsoleWrite(WinGetTitle($sTitle) & @LF)

You'll probably find that the title-less window you got belongs to explorer.exe

Possible that this might get you started.

#include <Process.au3>

MsgBox(0,"Desktop visible",_DesktopOnTop())

Func _DesktopOnTop()
    $sTitle = WinGetTitle("(ACTIVE]")
    $sPName = _ProcessGetName(WinGetProcess(WinGetHandle("[ACTIVE]")))
    If ($sTitle = "" And $sPName = "explorer.exe") Or ($sTitle = "Program Manager") Then
        Return True
    EndIf
    Return False
EndFunc   ;==>_DesktopOnTop

 

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

If I understand, this could work :

#include <WinAPISys.au3>
MsgBox(0, "", "Desktop is active ?" & @CRLF & _DesktopActive() )

Func _DesktopActive()
    Return ( WinGetHandle("[ACTIVE]") = _WinAPI_GetShellWindow() )
EndFunc

Or this :

#include <WinAPISys.au3>

MsgBox(0, "", "Desktop is active ?" & @CRLF & _DesktopActive() )

Func _DesktopActive()
    Return ( BitAND( WinGetState( _WinAPI_GetShellWindow() ), 8 ) <> 0 )
    ; Return (WinActive( _WinAPI_GetShellWindow()) > 0) ; Or this
EndFunc

 

 

 

Edited by jguinch
Link to comment
Share on other sites

@JohnOne:  Yes, the combination of the two checks seems to be the answer ... although I haven't tested a lot of cases.  Thanks for the suggestion.

$sTitle = WinGetTitle("(ACTIVE]")
    $sPName = _ProcessGetName(WinGetProcess(WinGetHandle("[ACTIVE]")))

@jguinch:  It seems that those methods should work, but I can't make them do so.  Before calling _DesktopActive(), I place the cursor in the center of the desktop and left click once to make sure it's active ... but the function always returns False.

Thanks for both responses.

 

 

 

 

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...