如何刷新托盘图标
在对托盘图标进行一番操作以后,会发现显示滞后现象,用鼠标指针点一下才有反应。故需要刷新一下托盘图标,。请问如何做到,谢谢。
[ 本帖最后由 jiataifeng 于 2009-4-21 06:53 编辑 ] 不明白哦·== #Include <Constants.au3>
Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)
GUICreate("")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN,"_TRAY")
TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN,"_TRAY")
While 1
Sleep(100)
WEnd
Func _TRAY()
Select
case @TRAY_ID=$TRAY_EVENT_PRIMARYDOWN
;TraySetIcon()
Case @TRAY_ID=$TRAY_EVENT_SECONDARYDOWN
;TraySetIcon()
EndSelect
EndFunc 可以这样理解:
删除某个进程后,该进程的托盘图标还存在与托盘处。此时需要鼠标点击一下,才会消失。现在需要的就是“刷新”一下,而不用去点击。
就像刷新桌面一样的道理呀。
晕,这都无法理解了。
不过还是谢谢回答啦 _RefreshSystemTray()
http://www.autoitscript.com/forum/index.php?showtopic=7404
;=========# _RefreshSystemTray #=====================================================
;Function Name: _RefreshSystemTray()
;Description: Removes any dead icons from the notification area.
;Parameters: $nDealy - IN/OPTIONAL - The delay to wait for the notification area to expand with Windows XP's "Hide Inactive Icons" feature (In milliseconds).
;Return Value(s):Success - Returns 1
; Failure - Returns 0 and sets @error to:
; 1 - Tray couldn't be found.
; 2 - DllCall error.
;Autor(s): Valik
;====================================================================================
Func _RefreshSystemTray($nDelay = 1000)
Local $hWnd, $hControl, $posStart, $posWin, $posX, $posY, $error = 0
; Save Opt settings
Local $oldChildMode = Opt("WinSearchChildren", 1)
Local $oldMatchMode = Opt("WinTitleMatchMode", 4)
Do ; Pseudo loop
$hWnd = WinGetHandle("")
If @error Then
$error = 1
ExitLoop
EndIf
$hControl = ControlGetHandle($hWnd, "", "Button2")
; 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
$posStart = MouseGetPos()
$posWin = WinGetPos($hWnd)
$posY = $posWin
While $posY < $posWin + $posWin
$posX = $posWin
While $posX < $posWin + $posWin
DllCall("user32.dll", "int", "SetCursorPos", "int", $posX, "int", $posY)
If @error Then
$error = 2
ExitLoop 3 ; Jump out of While/While/Do
EndIf
$posX += 8
WEnd
$posY += 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("WinSearchChildren", $oldChildMode)
Opt("WinTitleMatchMode", $oldMatchMode)
If $error Then
Return SetError($error, 0, 0)
Else
Return 1
EndIf
EndFunc ;==>_RefreshSystemTray
[ 本帖最后由 sensel 于 2009-4-13 22:11 编辑 ] 强人了,,,,,,,, 貌似效果不是很好 关注ing 有没更好的 刷新环境变量试试看 关注。。。。。。。。 关注。。。。。。。。 留点回来写代码试试看{:face (125):} 做的挺漂亮的,
页:
[1]