Jump to content

List applications open on the TaskBar?

Recommended Posts


I am trying to find a way to detect if two applications are running (and visible in the GUI).  One sits in the system tray (which I've got sorted) but another launches (so is easily visible as a running process) but seems to delay until showing in the GUI but the "WinExists" command seems to pick it up a few seconds before it's actually visible!

The bit of script that detects the system tray app is modified from somewhere on these forums that finds the text labels from all of the tray icons...

Func Get_Systray_IconText($sToolTipTitle)
    Local $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
    Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle)
    Local $iSystray_ButtonNumber
    For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1
        Local $sText = _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber)
        If StringInStr($sText, $sToolTipTitle) = 1 Then
            Return $sText
    Return SetError(1, 0, "")

So I was hoping that there was something nearly identical that detects icons in the Taskbar in a near-identical way as ProcessExists and WinExists commands seem to detect it too early and I really need to detect the time that the window is visible to the user which seems to be when it spawns it's taskbar icon.

Any ideas?

Link to comment
Share on other sites


- WinList() for active windows (even shows me all open FF tabs, cool, didn't know that :) )

- ProcessList() for processes

Edit: sorry, I get what your problem is.

Have you tried WinGetState() yet?

It can check if a certain window is visible.

Edited by Radiance
Link to comment
Share on other sites

Thanks, but I suspect that WinList() will also list the MSHTA.exe window I am looking for early as presumably is uses the same API as the WinExists command and the process opens some 10 seconds or so before the windows is visible so that is no use to me hence why I am looking specifically for when an icon is displayed on the taskbar.

Link to comment
Share on other sites

Did some playing around with above suggestion.

#include <WinAPI.au3>

While 1
    If Not WinExists(WinGetHandle("[CLASS:Notepad]")) Then
        $hWnd = (WinGetHandle("[CLASS:Notepad]"))
        ConsoleWrite("Win now exists  " & @CRLF)
        $VAR = _WinAPI_IsWindowVisible($hWnd)
        ConsoleWrite("$VAR =  " & $VAR & @CRLF)
Console output
Win now exists  
$VAR =  0
Win now exists  
$VAR =  1
Win now exists  
$VAR =  1

It does seem that  "_WinAPI_IsWindowVisible" is showing False ($VAR = 0) for the first few seconds of loading the window that according to WinExists already exists.... so to speak ;)

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

  • Create New...