怎样刷新任务栏图标!!!
有一个进程,在程序外部的,已经用KILL杀掉了,但仍然有一个废弃的图标在任务栏中,就是在右边的小托盘中,鼠标移动过去才会消失。因为我需要多次启动同一个进程,也会多次关闭同一个进程,所以小托盘图标会越来越多,怎样才能去掉?用程序去掉,因为没人来操作这台计算机的:(谢谢! http://www.autoitx.com/forum.php?mod=viewthread&tid=1223&highlight=%CB%A2%D0%C2%C8%CE%CE%F1%C0%B8
以前的解决方案
不过三恨说用API最好了,但有指针问题没解决 先隐藏图标,再Kill It ; ===================================================================
; _RefreshSystemTray($nDealy = 1000)
;
; Removes any dead icons from the notification area.
; Parameters:
; $nDelay - IN/OPTIONAL - The delay to wait for the notification area to expand with Windows XP's
; "Hide Inactive Icons" feature (In milliseconds).
; Returns:
; Sets @error on failure:
; 1 - Tray couldn't be found.
; 2 - DllCall error.
; ===================================================================
Func _RefreshSystemTray($nDelay = 1000)
; Save Opt settings
Local $oldMatchMode = Opt("WinTitleMatchMode", 4)
Local $oldChildMode = Opt("WinSearchChildren", 1)
Local $error = 0
Do; Pseudo loop
Local $hWnd = WinGetHandle("classname=TrayNotifyWnd")
If @error Then
$error = 1
ExitLoop
EndIf
Local $hControl = ControlGetHandle($hWnd, "", "Button1")
; We're on XP and the Hide Inactive Icons button is there, so expand it
If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then
ControlClick($hWnd, "", $hControl)
Sleep($nDelay)
EndIf
Local $posStart = MouseGetPos()
Local $posWin = WinGetPos($hWnd)
Local $y = $posWin
While $y < $posWin + $posWin
Local $x = $posWin
While $x < $posWin + $posWin
DllCall("user32.dll", "int", "SetCursorPos", "int", $x, "int", $y)
If @error Then
$error = 2
ExitLoop 3; Jump out of While/While/Do
EndIf
$x = $x + 8
WEnd
$y = $y + 8
WEnd
DllCall("user32.dll", "int", "SetCursorPos", "int", $posStart, "int", $posStart)
; We're on XP so we need to hide the inactive icons again.
If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then
ControlClick($hWnd, "", $hControl)
EndIf
Until 1
; Restore Opt settings
Opt("WinTitleMatchMode", $oldMatchMode)
Opt("WinSearchChildren", $oldChildMode)
SetError($error)
EndFunc; _RefreshSystemTray() 本帖最后由 smooth 于 2022-3-30 16:01 编辑
afan 发表于 2010-1-30 16:33
先隐藏图标,再Kill It
没想到十几年之后,我也遇到这个问题了。三恨的代码测试了,没有效果。Windows 10企业版 21H1,19043.1586
我百度搜了到C语言刷新的代码,不知道怎么转换为AU3。
smooth 发表于 2022-3-30 15:55
没想到十几年之后,我也遇到这个问题了。三恨的代码测试了,没有效果。Windows 10企业版 21H1,19043.158 ...
_SysTrayIcon_Clean 试过吗? afan 发表于 2022-3-30 16:38
_SysTrayIcon_Clean 试过吗?
报告A大,测试了,MSGBOX没有弹出来,说明没有正常工作,通知区域的残留图标也没有刷新掉。
页:
[1]