Refresh System tray Icons Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
boom
Posts: 2
Joined: 12 Aug 2020, 06:47

Re: Refresh System tray Icons

12 Aug 2020, 06:53

Noesis's script works for me :bravo: ; I just had to change "ToolbarWindow322" to "ToolbarWindow323". I am using Win10 Pro v1903.
llinfeng
Posts: 86
Joined: 08 Dec 2016, 21:54
Contact:

Re: Refresh System tray Icons

22 Jun 2022, 12:52

Building on what has been said in this thread, the following function works on Win 10 Pro (Version 21H2; OS build 19044.1766).

Code: Select all

; Source: https://www.autohotkey.com/boards/viewtopic.php?t=19832
Tray_Refresh()
{
	WM_MOUSEMOVE := 0x200
	HiddenWindows := A_DetectHiddenWindows
	DetectHiddenWindows, On
	TrayTitle := "AHK_class ShellToolbarWindow323_TrayWnd"
	ControlNN := "ToolbarWindow323"
	IcSz := 24
	Loop, 2
	{
		ControlGetPos, xTray,yTray,wdTray,htTray, %ControlNN%, %TrayTitle%
		y := htTray - 10
		While (y > 0)
		{
			x := wdTray - IcSz/2
			While (x > 0)
			{
				point := (y << 16) + x
				PostMessage, %WM_MOUSEMOVE%, 0, %point%, %ControlNN%, %TrayTitle%
				x -= IcSz/2
			}
			y -= IcSz/2
		}
		TrayTitle := "AHK_class NotifyIconOverflowWindow"
		ControlNN := "ToolbarWindow321"
		IcSz := 32
	}
	DetectHiddenWindows, %HiddenWindows%
	Return
}
User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Re: Refresh System tray Icons

16 Feb 2023, 16:09

For me, in 2023Q1 still being stuck on Windows 10 Enterprise 20H2 x64, this works
masato wrote:
26 Jun 2017, 21:04
[...]

Code: Select all

Tray_Refresh()

Tray_Refresh() {
/*        Remove any dead icon from the tray menu
 *        Should work both for W7 & W10
 */
    WM_MOUSEMOVE := 0x200
    detectHiddenWin := A_DetectHiddenWindows
    DetectHiddenWindows, On

    allTitles := ["ahk_class Shell_TrayWnd"
            , "ahk_class NotifyIconOverflowWindow"]
    allControls := ["ToolbarWindow321"
                ,"ToolbarWindow322"
                ,"ToolbarWindow323"
                ,"ToolbarWindow324"]
    allIconSizes := [24,32]

    for id, title in allTitles {
        for id, controlName in allControls
        {
            for id, iconSize in allIconSizes
            {
                ControlGetPos, xTray,yTray,wdTray,htTray,% controlName,% title
                y := htTray - 10
                While (y > 0)
                {
                    x := wdTray - iconSize/2
                    While (x > 0)
                    {
                        point := (y << 16) + x
                        PostMessage,% WM_MOUSEMOVE, 0,% point,% controlName,% title
                        x -= iconSize/2
                    }
                    y -= iconSize/2
                }
            }
        }
    }

    DetectHiddenWindows, %detectHiddenWin%
}
But I add at the end of it

Code: Select all

SetTimer, Tray_Refresh, 9999

While true
    Sleep, 999
so that it will be executed every 10 seconds in the background


And I have a question about the DetectHiddenWindows: if I have a hidden window that did not crash thus not have a ghost icon in Tray [because it was never visible in Tray], will this hidden program be somehow affected?

And is it safe to run this code in a loop?
Last edited by A Keymaker on 04 Jul 2023, 05:46, edited 1 time in total.
User avatar
gt57
Posts: 3
Joined: 08 Apr 2020, 08:02

Re: Refresh System tray Icons

20 Apr 2023, 15:11

Has anyone converted a working script to AutoHotkey V2?
User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Re: Refresh System tray Icons

05 Jul 2023, 13:31

A Keymaker wrote:
16 Feb 2023, 16:09
For me, in 2023Q1 still being stuck on Windows 10 Enterprise 20H2 x64, this works
[...]
Well it has stopped

But what works is this one:
viewtopic.php?f=76&t=113015&p=503514#p503514
helloicanseeu
Posts: 7
Joined: 30 Nov 2023, 01:32

Re: Refresh System tray Icons

10 Apr 2024, 06:04

llinfeng wrote:
22 Jun 2022, 12:52
Building on what has been said in this thread, the following function works on Win 10 Pro (Version 21H2; OS build 19044.1766).

Code: Select all

; Source: https://www.autohotkey.com/boards/viewtopic.php?t=19832
Tray_Refresh()
{
	WM_MOUSEMOVE := 0x200
	HiddenWindows := A_DetectHiddenWindows
	DetectHiddenWindows, On
	TrayTitle := "AHK_class ShellToolbarWindow323_TrayWnd"
	ControlNN := "ToolbarWindow323"
	IcSz := 24
	Loop, 2
	{
		ControlGetPos, xTray,yTray,wdTray,htTray, %ControlNN%, %TrayTitle%
		y := htTray - 10
		While (y > 0)
		{
			x := wdTray - IcSz/2
			While (x > 0)
			{
				point := (y << 16) + x
				PostMessage, %WM_MOUSEMOVE%, 0, %point%, %ControlNN%, %TrayTitle%
				x -= IcSz/2
			}
			y -= IcSz/2
		}
		TrayTitle := "AHK_class NotifyIconOverflowWindow"
		ControlNN := "ToolbarWindow321"
		IcSz := 32
	}
	DetectHiddenWindows, %HiddenWindows%
	Return
}
works in win11-64, tyty

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CodeKiller, teadrinker and 204 guests