Jump to content

Right Clicking Program in Tray


Recommended Posts

Hi there, a new user of AutoIt so please bear with me!!

Simply I'd like to right click a program in the tray area, in this case the program is Google Drive. Now sometimes the tray icon is in the main bit, but sometimes you have to click the little arrow and it's in that area. Sorry for the bad explanation, I can't think of the correct technical terms!!

I used the simple mousemove command at first but then realised when testing that the icon moves around on different computers.

So any help on how I could go about this would be much appreciated.

Thanks,

Tom

Link to comment
Share on other sites

Hi, thanks for the quick response this is working great!

Few questions, firstly is there anyway to have it look for two of three tooltips because sometimes Google Drive can say different things.

Secondly, how can I select one of the items from the menu after clicking the icon without using mousemove?

Thankyou

Link to comment
Share on other sites

Few questions, firstly is there anyway to have it look for two of three tooltips because sometimes Google Drive can say different things.

Yes, use an array and a for statement (see help file)

Secondly, how can I select one of the items from the menu after clicking the icon without using mousemove?

Use the Send function, e.g : {UP}{ENTER}

Br, FireFox.

Link to comment
Share on other sites

I'm having problems with implementing the array and for statement. I understand arrays but don't really know how to go about using them. I did read the documentation although it's not that simple to quickly jump into.

Thanks again for the help,

Tom

Edit: I tried the array example but then I tried to use the $string as $sToolTipTitle but it appears to randomly right click my dekstop. :/

Edited by tomgholmes
Link to comment
Share on other sites

okay.

Here is an array version with an added parameter to match exactly or not the tooltip text :

#include <GuiToolBar.au3>

#region EXAMPLE
Global $aToolTipTitle[3] = ["pause me !", "tooltip1", "tooltip2"]

TraySetToolTip($aToolTipTitle[0])

Global $aSystray_ButtonData = Systray_GetIconIndex($aToolTipTitle)

If $aSystray_ButtonData = 0 Then
    MsgBox(16, "Error code " & @error, "Icon not found in system tray")
Else
    _GUICtrlToolbar_ClickButton($aSystray_ButtonData[0], $aSystray_ButtonData[1], "right")
EndIf
#endregion EXAMPLE

Func Systray_GetIconIndex($aSystrayGetIconIndex_ToolTipTitle, $blSystrayGetIconIndex_ExpandSystray = True, $blSystrayGetIconIndex_ExactMatch = False)
    Local $aSystrayGetIconIndex_CtrlCLASS[2] = ["Shell_TrayWnd", "NotifyIconOverflowWindow"], $aSystrayGetIconIndex_ReturnData[2]
    Local $iSystrayGetIconIndex_CtrlCount = 1, $hSystrayGetIconIndex_CtrlHandle, $iSystrayGetIconIndex_ButtonCount

    Switch @OSVersion
        Case "WIN_VISTA", "WIN_7"
            $iSystrayGetIconIndex_CtrlCount = 2
    EndSwitch

    For $iSystrayGetIconIndex_CtrlIndex = 0 To $iSystrayGetIconIndex_CtrlCount - 1
        $hSystrayGetIconIndex_CtrlHandle = ControlGetHandle("[Class:" & $aSystrayGetIconIndex_CtrlCLASS[$iSystrayGetIconIndex_CtrlIndex] & "]", "", "[Class:ToolbarWindow32;Instance:1]")
        If @error Then
            Return SetError(2, 0, 0)
        EndIf

        $iSystrayGetIconIndex_ButtonCount = _GUICtrlToolbar_ButtonCount($hSystrayGetIconIndex_CtrlHandle)
        If $iSystrayGetIconIndex_ButtonCount = 0 Then
            Return SetError(3, 0, 0)
        EndIf

        For $iSystrayGetIconIndex_ButtonIndex = 0 To $iSystrayGetIconIndex_ButtonCount - 1
;~          ConsoleWrite(_GUICtrlToolbar_GetButtonText($hSystrayGetIconIndex_CtrlHandle, $iSystrayGetIconIndex_ButtonIndex) & @CRLF)

            For $iSystrayGetIconIndex_ToolTip = 0 To UBound($aSystrayGetIconIndex_ToolTipTitle) - 1
                If (Not $blSystrayGetIconIndex_ExactMatch And StringInStr(_GUICtrlToolbar_GetButtonText($hSystrayGetIconIndex_CtrlHandle, $iSystrayGetIconIndex_ButtonIndex), $aSystrayGetIconIndex_ToolTipTitle[$iSystrayGetIconIndex_ToolTip])) _
                        Or ($blSystrayGetIconIndex_ExactMatch And _GUICtrlToolbar_GetButtonText($hSystrayGetIconIndex_CtrlHandle, $iSystrayGetIconIndex_ButtonIndex) = $aSystrayGetIconIndex_ToolTipTitle) Then
                    If $iSystrayGetIconIndex_CtrlIndex = 1 And $blSystrayGetIconIndex_ExpandSystray Then
                        ControlClick("[CLASS:" & $aSystrayGetIconIndex_CtrlCLASS[0] & "]", "", "[CLASS:Button; INSTANCE:1]", "left")
                    EndIf

                    $aSystrayGetIconIndex_ReturnData[0] = $hSystrayGetIconIndex_CtrlHandle
                    $aSystrayGetIconIndex_ReturnData[1] = $iSystrayGetIconIndex_ButtonIndex

                    Return $aSystrayGetIconIndex_ReturnData
                EndIf
            Next
        Next
    Next

    Return SetError(1, 0, 0)
EndFunc   ;==>Systray_GetIconIndex

Note: It will return the first match found.

Br, FireFox.

Edited by FireFox
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...