托盘栏点击函数阿里巴巴luobo4891的博客BLOG
托盘栏点击函数 作者:轮回 日期:2008-11-21字体大小: 小 中 大

托盘栏点击函数
非常方便实用的栏点击函数,支持左右键点击。
例子:
鼠标左键点击托盘程序:
_SysTray_ClickItem("千千静听", "right", 1)
鼠标左键点击托盘程序:
_SysTray_ClickItem("千千静听", "left", 1)
程序代码
#NoTrayIcon
#Include <GuiToolBar.au3>
_SysTray_ClickItem("AIMP2", "right", 1)
If @error Then MsgBox(48, "Failure", "Required item not found")
;=========# _SysTray_ClickItem #======================================================
;
;Function Name: _SysTray_ClickItem()
;Description: Click on item in Windows system tray by any substring in the title
;Parameters: $iTitle - The title of the item in Windows system tray (you can see the title of the item when mouse cursor hovered on item).
; $iButton - [optional] The button to click, "left" or "right". Default is the left button.
; $iClick - [optional] The number of times to click the mouse. Default is 1
; $sMove = [optional] True = Mouse will be moved, False (default) = Mouse will not be moved
; $iSpeed = [optional] Mouse movement speed
;Return Value(s): Success - Returns 1
; Failure - Returns 0 and sets @error to 1 if required item not found
;Requirement(s): AutoIt 3.2.10.0 and above
;Autor(s): R.Gilman (a.k.a rasim); Siao (Thanks for idea)
;
;====================================================================================
Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1, $sMove = False, $iSpeed = 1)
Local $hToolbar, $iButCount, $aRect, $hButton, $cID, $i
$hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]")
If @error Then
Return SetError(1, 0, 0)
EndIf
$iButCount = _GUICtrlToolbar_ButtonCount($hToolbar)
If $iButCount = 0 Then
Return SetError(1, 0, 0)
EndIf
$hButton = ControlGetHandle("[Class:Shell_TrayWnd]", "", "Button2")
If $hButton <> "" Then ControlClick("[Class:Shell_TrayWnd]", "", "Button2")
For $i = 0 To $iButCount - 1
$cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i)
If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $cID), $iTitle) Then
_GUICtrlToolbar_ClickButton($hToolbar, $cID, $iButton, $sMove, $iClick, $iSpeed)
Return 1
EndIf
Next
Return SetError(1, 0, 0)
EndFunc

无显示 无显示
郑重声明:资讯 【托盘栏点击函数阿里巴巴luobo4891的博客BLOG】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——