目前在坛子里找到右下角托盘上图标的右击行为解决方法如下:
但有以下问题痛苦中,感谢您万忙中指点一下。无比感谢。
问题1: 若是: left 一般无问题,若是right就会容易在右下解多一下不是这个位置右击的菜单;
问题2: 若这个图标被卷起来了,这段代码是不起作用的。痛苦中。#NoTrayIcon
#Include <GuiToolBar.au3>
_SysTray_ClickItem("音量", "right", 1)
;====================================================================================
;Autor(s): R.Gilman (a.k.a rasim); Siao (Thanks for idea )
;====================================================================================
Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1)
Local $hToolbar, $iButCount, $aRect, $i
If Not $iTitle Then
MsgBox(16, "Error", "Please indicate title")
Return 0
EndIf
$hToolbar = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
If @error Then
MsgBox(16, "Error", "System tray not found")
Return 0
EndIf
$iButCount = _GUICtrlToolbar_ButtonCount($hToolbar)
If $iButCount = 0 Then
MsgBox(16, "Error", "Not found item in system tray")
Return
EndIf
For $i = 0 To $iButCount - 1
$cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i)
If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $i), $iTitle) Then
$aRect = _GUICtrlToolbar_GetButtonRect($hToolBar, $i)
ControlClick("[Class:Shell_TrayWnd]", "", "ToolbarWindow321", $iButton, $iClick, $aRect[0], 5)
$aRect = 0
Return 1
EndIf
Next
MsgBox(48, "Fail", "Required item not found")
EndFunc
|