Jump to content

How to operate a icon in system tray?


Recommended Posts

There is a program running in system tray, and I want my script to click the icon, how can I do it?

System tray is a toolbar of desktop,"[CLASS:ToolbarWindow32; INSTANCE:1]". But I cannot get the program ID which is running in system tary, for purpose of operate the icon, I should get the icon loation first, I tried to use the icon tooltip, if the text of tooltip is what i want, then move mouse to the location and click it. But I cannot get the icon tooltips in system tray as well. Dose this idea which use tooltip is correct? how can I get the tooltip in system tray?

Thanks in advance.

Edited by yarsye
Link to comment
Share on other sites

I am not sure but I would say the system tray just has icons there and when you click there or put there mouse there Windows (explore.exe) does the translation required.

I can only recommend using mouse functions. Then use sleep if there is a delay between the mousing going over it and the tooltip displaying.

I also recommend searching the forum to see if this has been tried before.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

  • 4 weeks later...

Hello. I have the same problem. I am trying to develop a program in c# and i have the same problem. I know the class of the program, I know the caption of window so basically I know the handle of the program. BUT without the id of the button in taskbar, because that program only works in taskbar, don't have any other windows, I cannot send any commands to it. If u have solved the problem please contact me to mitrynicolae@yahoo.com and give me that script. I am still looking for some commands I can give to system tray something like activate or dblclick or something. Maybe I figure it out. By the way add me anyway to your messenger list because if I can get something for C# I will translate it for vbscripting for you.

Link to comment
Share on other sites

  • Moderators

Hi all,

Missed this topic the first time round.

Here is a script to right-click on a systray icon - you just need to add the tooltip text of the icon you are trying to click.

#Include <GuiToolBar.au3>

Global $hSysTray_Handle, $iSystray_ButtonNumber

Global $sToolTipTitle = "" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here

$iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle)

If $iSystray_ButtonNumber = 0 Then
    MsgBox(16, "Error", "Icon not found in system tray")
    Exit
Else
    Sleep(500)
    _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
EndIf

Exit

;............

Func Get_Systray_Index($sToolTipTitle)

    ; 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 wanted tooltip
    For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1
        If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) = 1 Then ExitLoop
    Next

    If $iSystray_ButtonNumber = $iSystray_ButCount Then
        Return 0 ; Not found
    Else
        Return $iSystray_ButtonNumber ; Found
    EndIf

EndFunc

The script is not foolproof - sometimes it does not find the icon. >_< I have found that using the first word/words of the tooltip text gives the best results.

If anyone has any improvements, please share them!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi all,

Here is a script to right-click on a systray icon - you just need to add the tooltip text of the icon you are trying to click.

I tried using this script, and it doesn't quite work. It finds the right icon, but when it executes the Right-Click, it brings up the main Taskbar menu (Toolbars, Adjust Date/Time, Cascade Windows, etc.) instead of the one for the specific icon. I have tried this with a couple of different icons to be sure it wasn't a problem just with one. And to be sure that it was gathering the information correctly, I added a couple of message boxes to display the information it had gathered:

MsgBox(0,"Button Number",$iSystray_ButtonNumber)

MsgBox(0,"Button Text",$sToolTipTitle)

I can't figure out what is wrong. I'm using the latest release version of AutoIt.

Any suggestions?

Link to comment
Share on other sites

  • Moderators

HollyN,

Sorry about that - works for me every time! :(

What did the 2 MsgBoxs return when you ran it? What is the ToolTip text of the icon you are trying to click? What are you putting into the $sToolTipTitle variable? Is the icon visible when you run the code? What OS?

Perhaps if you posted your whole code, I might be able to see something else which is preventing my suggested code from running. >_<

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

HollyN,

Sorry about that - works for me every time! :(

What did the 2 MsgBoxs return when you ran it? What is the ToolTip text of the icon you are trying to click? What are you putting into the $sToolTipTitle variable? Is the icon visible when you run the code? What OS?

Perhaps if you posted your whole code, I might be able to see something else which is preventing my suggested code from running. >_<

M23

Thanks for your help. Windows XP. The icon is visible on the System Tray. The first MsgBox returns "8" (which is it's position counting from the right of the System Tray). The second MsgBox returns "Application Explorer", which is the ToolTip for the icon. One feature I'd like to add (if I can get it working) is this: When the program loads, it first presents with the ToolTip "Refreshing Application Launcher" for a variable period of time. I'd love to have the script wait until that process finishes, and then go on to act on "Application Explorer".

Global $hSysTray_Handle, $iSystray_ButtonNumber

Global $sToolTipTitle = "Application Explorer" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here

$iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle)

If $iSystray_ButtonNumber = 0 Then
    MsgBox(16, "Error", "Icon not found in system tray")
    Exit
Else
    Sleep(500)
    MsgBox(0,"Button Number",$iSystray_ButtonNumber)
    MsgBox(0,"Button Text",$sToolTipTitle)
    _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
    Send("z")
EndIf

Exit

;............

Func Get_Systray_Index($sToolTipTitle)

    ; 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 wanted tooltip
    For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1
        If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) = 1 Then ExitLoop
    Next

    If $iSystray_ButtonNumber = $iSystray_ButCount Then
        Return 0 ; Not found
    Else
        Return $iSystray_ButtonNumber ; Found
    EndIf

EndFunc
Link to comment
Share on other sites

  • Moderators

HollyN,

You will not be surprised to learn that, as you have used my script basically unaltered, yours works perfectly for me. I am using Vista, but that usually causes problems rather than solving them!

Try changing this line:

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

to read:

_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right", True, 1, 0)

That will send the mouse down to the icon before it clicks.

Does the _GUICtrlToolbar_ClickButton example in the Help file work for you? One tip, add a Sleep(2000) just before the _GUICtrlToolbar_ClickButton line - otherwise it goes so fast you cannot see what is happening!

One final question: I presume the Send("z") is to activate the menu once displayed. When we get the correct menu to show (positive thinking here! >_< ), I have found that a short delay (Sleep(250) or so) is a good idea.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

I think I'm on to something: just for fun, I turned off the Auto-Hide Taskbar setting and the script works fine. Is there a way to force the Taskbar to remain visible while the script is running without changing the user's default setting? That may be all I need. Maybe it's as simple as executing an Alt-Esc...

Edited by HollyN
Link to comment
Share on other sites

I obviously meant <ctrl>-<esc>.

I'm not a programmer, so this is crude, but it works!

If $iSystray_ButtonNumber = 0 Then
    MsgBox(16, "Error", "Icon not found in system tray")
    Exit
Else
    Send("{CTRLDOWN}") ;send a <ctrl>-<esc> to bring up the Taskbar if it's hidden
    Send("{ESC}")
    Send("{CTRLUP}")
    Send("{ESC}") ;get rid of the Start Menu to avoid confusion
    Sleep(250)
    _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
    Sleep(250)
    Send("z")
EndIf

Now, even though this works, I'd love a fancier way to do it. And I'm still hoping you can help me with a loop to be sure that the icon is running in the correct state. When it first loads, the Tooltip is "Refreshing Application Launcher". When it is ready for the script, it is "Application Explorer".

Thanks again,

Holly

Link to comment
Share on other sites

  • Moderators

HollyN ,

Yup, a bit difficult to click on invisible icons! :(

Unfortunately I have come a complete blank on un-autohiding the taskbar - everything I have found suggests that you cannot do it programmatically (if such a word exists outside of Silicon Valley!). So I think your "ugly" way is it - but I have aways been of the logical-positivist tendency = if it works, use it! Besides, that is why AutoIt was designed in the first place - to automate Windows - so you are just returning to its roots. And who says you are not a programmer - your code works and there appears to be nothing "fancier". Sounds like programming to me. >_<

As to the loop, I would suggest something like the following (untested):

Local $iCount = 0
While $iSystray_ButtonNumber = 0
    MsgBox(16, "Error", "Icon not found in system tray")
    ; Increase error count
    $iCount += 1
    If $iCount > (some figure you decide to put here which gives you long enough to wait in normal circumstances) Then
        MsgBox(16, "Error", "Timed out waiting for icon")
        Exit
    Endif
WEnd

; We must have found the correct icon
Send("{CTRLDOWN}") ;send a <ctrl>-<esc> to bring up the Taskbar if it's hidden
Send("{ESC}")
Send("{CTRLUP}")
Send("{CTRLUP}")
Send("{CTRLUP}")  ; <<<<<<<<<<< always a good idea to send a few UPs - the DOWN sometimes sticks on
Send("{ESC}") ;get rid of the Start Menu to avoid confusion
Sleep(250)
_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
Sleep(250)
Send("z")

I am glad we managed to determine the reason the script did not work at first - good luck with the rest of it. You know where we are if you need anything else.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

HollyN,

Try something along these lines:

; Wait until initial state appears
Global $sToolTipTitle = "Refreshing Application Launcher" ; Tooltip text for initial state 
Do
    $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle)
Until $iSystray_ButtonNumber <> 0

; Initial state has appeared, so now we wait until app is ready for the click
$sToolTipTitle = "Application Launcher" ; Tooltip text for ready state
Do
    $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle)
Until $iSystray_ButtonNumber <> 0

; We have found the correct icon in the correct state
Send("{CTRLDOWN}") ;send a <ctrl>-<esc> to bring up the Taskbar if it's hidden
; ........

This will work if the script is running and the "Refeshing" text is available. If the script might be called when the "ready" state is already present I will have to rethink. But it is now time for bed - so if that is the case, you will have to wait until tomorrow for another instalment- sorry >_< .

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

This will work if the script is running and the "Refeshing" text is available. If the script might be called when the "ready" state is already present I will have to rethink. But it is now time for bed - so if that is the case, you will have to wait until tomorrow for another instalment- sorry >_< .

M23

PERFECT!!! (Well, it actually stalled out the first time because the second text wasn't quite right, but I figured that out quickly.)

Thanks so much for your help - this is exactly what I needed.

Holly

Link to comment
Share on other sites

  • 2 weeks later...

HollyN ,

Yup, a bit difficult to click on invisible icons! :D

Unfortunately I have come a complete blank on un-autohiding the taskbar - everything I have found suggests that you cannot do it programmatically (if such a word exists outside of Silicon Valley!). So I think your "ugly" way is it - but I have aways been of the logical-positivist tendency = if it works, use it! Besides, that is why AutoIt was designed in the first place - to automate Windows - so you are just returning to its roots. And who says you are not a programmer - your code works and there appears to be nothing "fancier". Sounds like programming to me. :D

As to the loop, I would suggest something like the following (untested):

Local $iCount = 0
While $iSystray_ButtonNumber = 0
    MsgBox(16, "Error", "Icon not found in system tray")
    ; Increase error count
    $iCount += 1
    If $iCount > (some figure you decide to put here which gives you long enough to wait in normal circumstances) Then
        MsgBox(16, "Error", "Timed out waiting for icon")
        Exit
    Endif
WEnd

; We must have found the correct icon
Send("{CTRLDOWN}") ;send a <ctrl>-<esc> to bring up the Taskbar if it's hidden
Send("{ESC}")
Send("{CTRLUP}")
Send("{CTRLUP}")
Send("{CTRLUP}")  ; <<<<<<<<<<< always a good idea to send a few UPs - the DOWN sometimes sticks on
Send("{ESC}") ;get rid of the Start Menu to avoid confusion
Sleep(250)
_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
Sleep(250)
Send("z")

I am glad we managed to determine the reason the script did not work at first - good luck with the rest of it. You know where we are if you need anything else.

M23

This is great and solves half of my problem. In my case it is the McAfee mctray icon I want to access. By following the posted code I've been able to get a menu to pop-up after the right click is sent. I need some help to send a mouse click to one of the menu items in the menu window and have the script wait until that action is completed.

Thanks for any help!

Link to comment
Share on other sites

  • Moderators

BankofDad,

First, welcome to the Autoit forums. Love the handle - I think I run one of your branches in the UK! :D

Delighted you can get the icon code to work. I have never tried to use the mouse from then on - I use Send and UP, DOWN, ENTER, etc, as you can see from this extract from one of my scripts:

Sleep(500)
_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right", True, 1, 0)
; Move around traymenu to firewall state menu
Send("{DOWN}{LEFT}")
Sleep(500)

Switch $sAction
    Case 1
        Send("{ENTER}")
    Case 2
        Send("{DOWN}{DOWN}")
        Sleep(500)
        Send("{ENTER}")
EndSwitch

Notice the Sleep(500) lines - I have found that you need to give traymenus a bit of time between the Send commands. I suppose I could play about with Opt("SendKeyDelay"), but I have never bothered.

As to waiting until the action is finished, look at WinWaitActive and find a window that indicates all is over. You may have to do a "double-shuffle" - wait until a particular window is active (task running) and then no longer active (task ended). It all depends on what exactly goes on while the task runs.

Good luck! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

BankofDad,

First, welcome to the Autoit forums. Love the handle - I think I run one of your branches in the UK! :D

Delighted you can get the icon code to work. I have never tried to use the mouse from then on - I use Send and UP, DOWN, ENTER, etc, as you can see from this extract from one of my scripts:

Sleep(500)
_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right", True, 1, 0)
; Move around traymenu to firewall state menu
Send("{DOWN}{LEFT}")
Sleep(500)

Switch $sAction
    Case 1
        Send("{ENTER}")
    Case 2
        Send("{DOWN}{DOWN}")
        Sleep(500)
        Send("{ENTER}")
EndSwitch

Notice the Sleep(500) lines - I have found that you need to give traymenus a bit of time between the Send commands. I suppose I could play about with Opt("SendKeyDelay"), but I have never bothered.

As to waiting until the action is finished, look at WinWaitActive and find a window that indicates all is over. You may have to do a "double-shuffle" - wait until a particular window is active (task running) and then no longer active (task ended). It all depends on what exactly goes on while the task runs.

Good luck! :D

M23

That did the trick! Using Send("{UP}{UP}") gets to the right spot on the menu. I'm confident I can figure out the next part, documentation and examples are plentiful here!

Many thanks for the speedy help

/BankofDad

Link to comment
Share on other sites

  • 4 months later...

Thanks to Melba23 for giving me the link to this thread :D

I am not sure why, but the script did not work at first for me. I had to make the following changes to the function:

Func Get_Systray_Index($sToolTipTitle)

    ; 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 wanted tooltip
    ;For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 =========== "OLD" instruction
    For $iSystray_ButtonNumber = 1 To $iSystray_ButCount  ; =========== MODIFIED instruction
         If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) = 1 Then ExitLoop
    Next

    ;If $iSystray_ButtonNumber = $iSystray_ButCount Then ;=========== "OLD" instruction
    If $iSystray_ButtonNumber = $iSystray_ButCount + 1 Then ; =========== MODIFIED instruction
        Return 0 ; Not found
    Else
        Return $iSystray_ButtonNumber ; Found
    EndIf

EndFunc

But after these minor changes, it works great in my computer!

Thanks again to Melba23!

Edited by Akshay07
Link to comment
Share on other sites

I don't know if the problem is fixed perminently with the autohide taskbar icons and I don't know it this option has changed for vista (I use xp) what about adding a code to the very begining of the script to autodisable the autohide?

if you right click the taskbar and go to properties, the autohide checkbox is right there in the first tab at the very bottom.

maybe a small snipit of code to bring up the taskbar properties and uncheck that box so it is off while code is running, then right before exit of the code, turn it back on?

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

  • 6 years later...

I'm a tad confused, I have TeamViewer running on my task bar and I want to right clich on it and then open a menu item it lists.

 

However this code does not pend results for me. I am assuming that the ToolTip is the the Name that is shown when you "hover" over the icon in the tray, is this correct?

Sorry for the cut image:ZF3O1hE.png

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