Sign in to follow this  
Followers 0
Diana (Cda)

WinWait equivalent for tray items?

7 posts in this topic

Is there an equivalent of WinWait for items that launch and automatically go into the systray? I'd like to have the same type of control as WinWait gives me to the items that are in the systray so that they appear in a certain sequence, which means that each app should load only when previous one is finally up and running.

Thanks. :D

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

Here you go.

#Include <GuiToolBar.au3>

;example
$Title = 'AutoIt - ' & @ScriptName
$Result = TrayWait($Title, 20)
If $Result Then 
    MsgBox(0,'Success',$Title)
Else
    MsgBox(0,'Failure','Timed out')
EndIf

;function itself
Func TrayWait($sTitle, $iTimeout)
    Local $iTime = TimerInit(), $cId, $iButCount, $iButCountOld
    Local $hToolbar = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
    If @error Then Return 0
    While TimerDiff($iTime) < $iTimeout*1000
        $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar)
        If $iButCount <> $iButCountOld Then
            For $i = 0 To $iButCount-1
                $cId = _GUICtrlToolbar_IndexToCommand($hToolbar, $i)
                If _GUICtrlToolbar_GetButtonText($hToolbar, $cId) = $sTitle Then Return 1
            Next
            $iButCountOld = $iButCount
        EndIf
        Sleep(Opt("WinWaitDelay"))
    WEnd
    Return 0
EndFunc
Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Here you go.

#Include <GuiToolBar.au3>
Hey, I know what these are now <g>.

I've searched for this file, I don't have it in my "Include" folder. Where did you get this file, pls?

Thanks. :D

Share this post


Link to post
Share on other sites

AutoIt v3.2.10.0


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Here you go.

#Include <GuiToolBar.au3>

;example
$Title = 'AutoIt - ' & @ScriptName
$Result = TrayWait($Title, 20)
If $Result Then 
    MsgBox(0,'Success',$Title)
Else
    MsgBox(0,'Failure','Timed out')
EndIf

;function itself
Func TrayWait($sTitle, $iTimeout)
    Local $iTime = TimerInit(), $cId, $iButCount, $iButCountOld
    Local $hToolbar = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
    If @error Then Return 0
    While TimerDiff($iTime) < $iTimeout*1000
        $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar)
        If $iButCount <> $iButCountOld Then
            For $i = 0 To $iButCount-1
                $cId = _GUICtrlToolbar_IndexToCommand($hToolbar, $i)
                If _GUICtrlToolbar_GetButtonText($hToolbar, $cId) = $sTitle Then Return 1
            Next
            $iButCountOld = $iButCount
        EndIf
        Sleep(Opt("WinWaitDelay"))
    WEnd
    Return 0
EndFunc
I never actually figured this one out. What I was trying to accomplish is to have the next app in line for launching do a "winwait" type of thing before starting up. But since there was nothing I knew how to read the app through something like winwait, the apps cascade open at different rates because one is rather slow. The trouble with that is that the app is a pesky one in one sense: when I hover anywhere near it in the systray, it opens up a monster tooltip obstructing anything else there. So by having some sort of controlled delay, which even sleep is no good for, was hoping to get it to position itself in the sytray somehow.

I later thought of using if process exists but that didn't work and just stalled the rest of the launching process even though the app was resident in the systray.

So it's best if there is something that works like winwait instead.

Is there any equivalent for winwait but for items in the systray? I don't know what the code above does, and all I ever got was a message box.

Thanks! :D

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

What I was trying to accomplish is to have the next app in line for launching...

In which queue for launching - the system startup queue?

But since there was nothing I knew how to read the app...

There is nothing you know of which will read just what information about the application?

...by having some sort of controlled delay, which even sleep is no good for, was hoping to get it to position itself in the sytray somehow.

Did you see taupe's new tray UDF's on the forums?

What is this rogue app with the huge tray menu so that we can recommend a freeware replacement for it?

Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

In which queue for launching - the system startup queue?

An AI lineup of apps that I launch. Sorry, my mistake in not being clearer as I assumed that WinWait would give that one away for sure as an AutoIt script <g>.

There is nothing you know of which will read just what information about the application?

Again, I guess I assumed somewhere on the back of my mind unconsciously that that one would be obvious, too. When we use WinWait, the information it reads is the window title. For the items in the systray, nothing registers as a window title that AI WindowsSpy or AU3Info can read.

Did you see taupe's new tray UDF's on the forums?

No. I'll do a search for this. Hopefully adding that will work.

What is this rogue app with the huge tray menu so that we can recommend a freeware replacement for it?

PowerPro. It's a launching app of enormous flexibility. It has the same type of flexibility as AI, i.e., it's a blank canvas you can build practically anything from, though it's not just a scripting language. The combination of AutoIt and PowerPro is incredible!

Unfortunately, in the AI script startup lineup I built that I launch from my USB flash drive, PowerPro experiences a huge delay for the icon to appear in the systray so that once all the apps are open (a total of about 6 small utilities I use), its icon rests too close to a clipboard extender. They both interfere with each other when the mouse is hovered over either in the systray. By having a WinWait-like delay but geared towards the systray, that would erase that problem as the queue is launched in such a way that both apps are far enough apart in the systray to not be a problem (if they would launch in sequence as it's scripted).

Is there anything like WinWait for the systray, however? That's all I was trying to find out, some way to put in a delay in the systray launch that involved something as reliable as WinWait and not just a sleep function.

Thanks much. :)

Edited by Diana (Cda)

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