Re: Refresh System tray Icons
Posted: 12 Aug 2020, 06:53
Noesis's script works for me ; I just had to change "ToolbarWindow322" to "ToolbarWindow323". I am using Win10 Pro v1903.
Let's help each other out
https://www.autohotkey.com/boards/
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=19832
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
}
masato wrote: ↑26 Jun 2017, 21:04[...]But I add at the end of itCode: 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% }
so that it will be executed every 10 seconds in the backgroundCode: Select all
SetTimer, Tray_Refresh, 9999 While true Sleep, 999
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?
Well it has stoppedA Keymaker wrote: ↑16 Feb 2023, 16:09For me, in 2023Q1 still being stuck on Windows 10 Enterprise 20H2 x64, this works
[...]
works in win11-64, tytyllinfeng wrote: ↑22 Jun 2022, 12:52Building 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 }