找回密码
 加入
搜索
查看: 4039|回复: 6

[AU3基础] 怎样刷新任务栏图标!!!

[复制链接]
发表于 2010-1-30 14:47:40 | 显示全部楼层 |阅读模式
有一个进程,在程序外部的,已经用KILL杀掉了,但仍然有一个废弃的图标在任务栏中,就是在右边的小托盘中,鼠标移动过去才会消失。因为我需要多次启动同一个进程,也会多次关闭同一个进程,所以小托盘图标会越来越多,怎样才能去掉?用程序去掉,因为没人来操作这台计算机的:(   
   
  谢谢!
发表于 2010-1-30 14:53:29 | 显示全部楼层
http://www.autoitx.com/forum.php ... 2%C8%CE%CE%F1%C0%B8
以前的解决方案

不过三恨说用API最好了,但有指针问题没解决
发表于 2010-1-30 16:33:50 | 显示全部楼层
先隐藏图标,再Kill It
发表于 2010-1-30 20:27:02 | 显示全部楼层
; ===================================================================
; _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[1]
        While $y < $posWin[3] + $posWin[1]
            Local $x = $posWin[0]
            While $x < $posWin[2] + $posWin[0]
                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[0], "int", $posStart[1])
    ; 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()
发表于 2022-3-30 15:55:08 | 显示全部楼层
本帖最后由 smooth 于 2022-3-30 16:01 编辑
afan 发表于 2010-1-30 16:33
先隐藏图标,再Kill It

没想到十几年之后,我也遇到这个问题了。三恨的代码测试了,没有效果。Windows 10企业版 21H1,19043.1586

我百度搜了到C语言刷新的代码,不知道怎么转换为AU3。
发表于 2022-3-30 16:38:04 | 显示全部楼层
smooth 发表于 2022-3-30 15:55
没想到十几年之后,我也遇到这个问题了。三恨的代码测试了,没有效果。Windows 10企业版 21H1,19043.158 ...

_SysTrayIcon_Clean 试过吗?
发表于 2022-3-30 21:15:20 | 显示全部楼层
afan 发表于 2022-3-30 16:38
_SysTrayIcon_Clean 试过吗?

报告A大,测试了,MSGBOX没有弹出来,说明没有正常工作,通知区域的残留图标也没有刷新掉。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-4 09:06 , Processed in 0.077771 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表