rasim Posted March 18, 2008 Posted March 18, 2008 Hi! Very often i see messages e.g. "I kill program from task manager, but icon of this program still showed in system tray. How can clear taskbar from icons of killed app.`s?" And i have written this script: #include <WinAPI.au3> $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "") $hParent = ControlGetHandle($hTaskBar, "", "TrayNotifyWnd1") $hWnd = ControlGetHandle($hParent, "", "ToolbarWindow321") $WinRect = _WinAPI_GetWindowRect($hWnd) $aMousePos = MouseGetPos() $Left = DllStructGetData($WinRect, "Left") $Right = DllStructGetData($WinRect, "Right") $Top = DllStructGetData($WinRect, "Top") For $i = $Left To $Right MouseMove($i, $Top, 0) Next MouseMove($aMousePos[0], $aMousePos[1], 0)
Moderators SmOke_N Posted March 18, 2008 Moderators Posted March 18, 2008 Valik did something similar here: http://www.autoitscript.com/forum/index.ph...ic=7404&hl= a while ago. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
rasim Posted March 18, 2008 Author Posted March 18, 2008 Valik did something similar here: http://www.autoitscript.com/forum/index.ph...ic=7404&hl= a while ago.LOL. I don`t know about Valik`s solution Thanks.
rasim Posted March 18, 2008 Author Posted March 18, 2008 I haven't tried the script yet, but does it move the cursor towards the 'dead' icon, to clear the icon?Yes
Keymaker Posted May 21, 2008 Posted May 21, 2008 @rasim, This little script did the trick for me and reliably removed my left over icons. Thanks!
r2du-soft Posted September 4, 2024 Posted September 4, 2024 (edited) ; Refresh taskbar icons without killing explorer.exe Func RefreshTaskbarIcons() ; Constants for the Windows message Local $HWND_BROADCAST = 0xFFFF Local $WM_SETTINGCHANGE = 0x001A ; Send a message to all windows to refresh taskbar icons DllCall("user32.dll", "int", "SendMessageTimeout", _ "hwnd", $HWND_BROADCAST, _ "uint", $WM_SETTINGCHANGE, _ "wparam", 0, _ "lparam", "str", "TrayIcons", _ "uint", 2, _ "uint", 1000, _ "uint*", 0) EndFunc ; Call the function to refresh taskbar icons RefreshTaskbarIcons() Edited September 4, 2024 by r2du-soft argumentum 1
ioa747 Posted September 5, 2024 Posted September 5, 2024 (edited) i tried it but couldn't get it to work I'm doing something wrong? expandcollapse popup#include <GUIConstantsEx.au3> Local $aProcces[6] = [5] ;Run GUI_Example in separate process as example Window ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If $CmdLine[0] > 0 Then ExampleGUI($CmdLine[1]) Exit EndIf For $i = 1 To $aProcces[0] $aProcces[$i] = Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptFullPath & '" GUI_Example' & $i) ConsoleWrite($i & ") $aProcces=" & $aProcces[$i] & @CRLF) Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sleep(10000) For $i = 1 To $aProcces[0] If ProcessExists($aProcces[$i]) Then ProcessClose($aProcces[$i]) Next ExampleGUI("Main GUI") $hMyGUI = WinWait("Main GUI") ;---------------------------------------------------------------------------------------- Func ExampleGUI($sTitle) Local $hGUI, $iMethod1, $iMethod2, $Result $hGUI = GUICreate($sTitle, 300, 200) If $sTitle = "Main GUI" Then $iMethod1 = GUICtrlCreateButton("Method1 ", 10, 10) $iMethod2 = GUICtrlCreateButton("Method2 ", 10, 40) EndIf GUISetState(@SW_SHOW) Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $iMethod1 $Result = RefreshTaskbarIcons() ConsoleWrite('- $Result = ' & $Result & ' >Error code: ' & @error & @CRLF) ;### Debug Console Case $iMethod2 ShellTrayRefresh() EndSwitch WEnd EndFunc ;==>ExampleGUI ;---------------------------------------------------------------------------------------- ; Refresh taskbar icons without killing explorer.exe Func RefreshTaskbarIcons() ; Constants for the Windows message Local $HWND_BROADCAST = 0xFFFF Local $WM_SETTINGCHANGE = 0x001A ; Send a message to all windows to refresh taskbar icons DllCall("user32.dll", "int", "SendMessageTimeout", _ "hwnd", $HWND_BROADCAST, _ "uint", $WM_SETTINGCHANGE, _ "wparam", 0, _ "lparam", "str", "TrayIcons", _ "uint", 2, _ "uint", 1000, _ "uint*", 0) EndFunc ;---------------------------------------------------------------------------------------- ; Title...........: ShellTrayRefresh.au3 ; Description.....: Refreshes ShellTray to remove leftover zombie icons ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ; https://www.autoitscript.com/forum/topic/139260-autoit-snippets/page/25/#comment-1529091 ;---------------------------------------------------------------------------------------- Func ShellTrayRefresh() Local $aStartPos = MouseGetPos() Local $hTrayWnd = WinGetHandle("[CLASS:Shell_TrayWnd]") Local $hTlb = ControlGetHandle($hTrayWnd, "", "ToolbarWindow324") Local $hBtn = ControlGetHandle($hTrayWnd, "", "Button2") Local $aPos = ControlGetPos($hTrayWnd, "", $hBtn) Local $aTPos = ControlGetPos($hTrayWnd, "", $hTlb) For $i = ($aPos[0] - 1) + ($aPos[2] / 2) To $aPos[0] + $aPos[2] + $aTPos[2] Step $aPos[2] MouseMove($i, @DesktopHeight - 3, 1) ;~ ConsoleWrite("$i=" & $i & @CRLF) ;~ Sleep(10) Next MouseMove($aStartPos[0], $aStartPos[1], 1) EndFunc ;==>ShellTrayRefresh and looking for a clue I found this I didn't understand, But it looks a lot like that https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_SendMessageTimeout.htm Edited December 8, 2024 by ioa747 UpDate ToolbarWindow323 to ToolbarWindow324 I know that I know nothing
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now