Sign in to follow this  
Followers 0
JohnSAutoIt

Make Tray Icon visible prior to mouse click

8 posts in this topic

In my explorations of the System Tray, after finding an icon on a partial tooltip name, I tried clicking the icon with the mouse. That worked fine on visible icons. I then tried to show the icon if it was not visible. I searched the forum and found some seemingly relevant code. After several tries I think it was the TraySetIcon() that worked but did something undesired. I now have all icons permanently visible and I cannot reset using the Taskbar settings (neither can I test the script on hidden icons any more!). Below is the code as it was when I first tried the setting. What instruction should I have used to temporarily show the icon and how do I restore my "Hide Inactive Icons" Taskbar.

Local $iSystray_ButtonNumber
    For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1
        Local $sText = _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber)
        If StringInStr($sText, $sToolTipTitle) > 0 Then
        TraySetIcon()
        _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSysTray_ButtonNumber, $sButtonside, $bMouseMove, $iClicks, 0)
        Return $sText
    EndIf
    Next

Share this post


Link to post
Share on other sites



JohnSAutoit,

You can get the "Hidden When Inactive" icons to reappear for long enough to click them by using ControlClick on the "open" arrow to the left of the systray like this:

#Include <GuiToolBar.au3>

Global $hSysTray_Handle

$iSystray_ButtonNumber = Get_Systray_Index("") ; 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")

Exit

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

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

The systray returns to normal fairly quickly, but a displayed traymenu remains active in my experience.

M23

P.S. I have alterd the above code to reflect your improvement! :D


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 for the code. When clicking with the mouse I assumed that the mouse movement parameter $fMove would move the mouse to the icon if True; if False would leave the mouse pointer where it was but still click the icon. That does not appear to be the case, it always moves the mouse pointer.

The second question in my post was how do I get the System Tray back to the "Hide Inactive Icons" state. It permanently shows all icons and cannot be unjammed. As I said, that means I cannot test your new code.

Share this post


Link to post
Share on other sites

JohnSAutoIt,

The _GUICtrlToolbar_ClickButton command does not move the mouse for me unless I set the $fMove parameter to true. :huggles:

As to restoring your systray, this is what I do on my Vista system to clear the old icons from <TaskBar properties - Notification Area - Customise> list - it has the secondary effect of resetting all the current icons to "Show", so it might unjam your system. But no guarantees... :D

CLEARING THE TRAY ICON HISTORY

> run 'regedit.exe'

> goto key 'HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion \TrayNotify'

> delete keys 'IconStreams' & 'PastIconsStream'

> start task manager, go to processes and kill explorer.exe

> go to applications in the task manager, hit new task and type 'explorer.exe'

> explorer will now reboot and your icons should return.

Good luck. :

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

#5 ·  Posted (edited)

Instead of "true/false" I'm using a variable $fMouseMove. If I set $fMouseMove to true or false, the mouse moves to the icon. If I set $fMouseMove to "" the mouse does not move. I've checked the value of $fMouseMove immediately prior to the click command and even moved the setting directly before.:

ControlClick($hTaskBarHandle, "", "[CLASS:Button; INSTANCE:1]")
$fMouseMove = "false"
_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right", $fMouseMove)

The above mod to your script will move the mouse if you use true or false; it will not move if you use "". Maybe this is one of those things I just cannot see or you are going to say it works fine for you! Does the True and False have to be Boolean? That may make the difference. If it does, I'm in the process of checking myself.

I have XP and the keys were in a different place but I found them. Your procedure re-loaded the icons but did not restore the tray reveal arrow. I was subsequently making a script to display all Tooltips and for some reason that has reset the tray reveal arrow.

Edited by JohnSAutoIt

Share this post


Link to post
Share on other sites

JohnSAutoIt,

If you want to use Boolean variables, you need to omit the quotation marks - look at how the syntax hightlighting appears here:

False ; = boolean false
"false" ; = literal string "f" & "a" & "l" & "s" & "e"

So I would suggest this would keep your mouse where it is:

$fMouseMove = False

Glad you got your systray arrow back. :D Have you tried out the code to click on the hidden icons? You might need to change the ID of the button as you are using XP - the Au3 Window Info tool will give you the correct values.

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

I found the "false" error but not in time to beat you! I went round the houses looking to see if you had to Dim boolean.

When I tried the script with the System Tray jammed, it chose the Start Button. I had noted that I would have to check once I got the reveal arrow back. You were right, in XP it's [CLASS:Button; INSTANCE:2]. Works fine to date. Thanks for the help (= True).

Share this post


Link to post
Share on other sites

JohnSAutoIt,

Glad I could help. :D

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