Sign in to follow this  
Followers 0
Noviceatthis

System Tray

8 posts in this topic

Hello all

I was just wondering whether there was a function which could check for the presence of a specific program icon in the system tray

Thanks in advance

Share this post


Link to post
Share on other sites



Noviceatthis,

I show >here how to click on a specific icon if you have the tooltip text - it could be very easily modified to merely say if the icon existed. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks M23 i'll give it a go

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Apologies, still having trouble with this, when entering the tooltip, do you have to enter the entire thing, or just a few words, as the tooltip changes when the program is updated??

#include <GuiToolBar.au3>

Global $hSysTray_Handle

HotKeySet("q", "_Show")

Opt("TrayMenuMode", 3)

TrayCreateItem("One")
TrayCreateItem("Two")
TrayCreateItem("Three")
TrayCreateItem("")
$mExit_Item = TrayCreateItem("Exit")
TraySetState()
TraySetToolTip("TestScript")

While 1
    If TrayGetMsg() = $mExit_Item Then Exit
WEnd

Func _Show()

    $iSystray_ButtonNumber = Get_Systray_Index("TestScript") ; Put your traytip text here as before
    If @error Then
        MsgBox(16, "Error", "Icon not found in system tray")
        Exit
    EndIf

    $hTaskBarHandle = WinGetHandle("[Class:Shell_TrayWnd]", "")

    ControlClick($hTaskBarHandle, "", "[CLASS:Button; INSTANCE:1]")

    _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")

EndFunc   ;==>_Show

Func Get_Systray_Index($sText)

    ; Find systray handle
    $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
    If @error Then
        MsgBox(16, "Error", "System tray not found")
        Exit
    EndIf

    ; Get systray item count
    Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle)
    If $iSystray_ButCount = 0 Then
        MsgBox(16, "Error", "No items found in system tray")
        Exit
    EndIf

    ; Look for  tooltip
    For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1
        If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sText) > 0 Then ExitLoop
    Next

    If $iSystray_ButtonNumber = $iSystray_ButCount Then
        Return SetError(1, 0, -1) ; Not found
    Else
        Return $iSystray_ButtonNumber ; Found
    EndIf

EndFunc   ;==>Get_Systray_Index

^^Im using the code supplied by M23

Edited by Noviceatthis

Share this post


Link to post
Share on other sites

Noviceatthis,

It should work with any part of the traytip text - although you obviously have to make it unique to your icon. :)

I use this basic code every day without problem - what problem are you having exactly? Try adding some errorchecking and see if you can see which part is failing. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

No real problems, Just trying to figure out your coding, im not a master in this field by any means :P should be able to do it now though, thank you :)

Edited by Noviceatthis

Share this post


Link to post
Share on other sites

GOT IT!! Didn't realize that this only applied to those icons on display, not those in the extended tray, thanks

Share this post


Link to post
Share on other sites

Noviceatthis,

If your icon is likely to be hidden, you might like to look at this code. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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