Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include-once
- #include <GuiToolBar.au3>
- ; #INDEX# =======================================================================================================================
- ; Title .........: ShellTray UDF (1.1)
- ; Date ..........: 16.09.2011
- ; AutoIt Version : 3.3 + (development version = 3.3.6.0)
- ; Language ......: English
- ; Description ...: Some workarounds for GuiToolBar.au3 with the shell tray
- ; Remarks .......:
- ; Link ..........:
- ; Author ........: FichteFoll
- ;
- ; #CHANGELOG# ===================================================================================================================
- ; # 1.1 [16.09.2011]
- ; - Added: Parameter for $fMove
- ; - Added: Documentation
- ;
- ; #CURRENT# =====================================================================================================================
- ; _TrayTool_GetHandle Retrieves the control handle for any other functions
- ; _TrayTool_ClickText Enumerates all icons in tray from index and clicks the one that matches the regular expression
- ; _TrayTool_ClickIndex See _GUICtrlToolbar_ClickIndex for equivalent
- ; _TrayTool_ClickButton See _GUICtrlToolbar_ClickButton for equivalent
- ;
- ; #INTERNAL_USE_ONLY# ===========================================================================================================
- ;
- ; #TODO# ========================================================================================================================
- ; - nothing?
- ; ===============================================================================================================================
- ; ###############################################################################################################################
- ; #Function# ===========================================================================================================================================
- ; Name............: _TrayTool_GetHandle
- ; Description.....: Retrieves the control handle for any other functions
- ; Syntax..........: _TrayTool_GetHandle()
- ; Parameters......: None
- ; Return values ..:
- ; Success - The control handle
- ; Failure - 0 and @error = 1 if the control was not found
- ; Author .........: FichteFoll
- ; Modified........:
- ; Remarks ........:
- ; Related ........: ControlGetHandle
- ; Link ...........;
- ; Example ........; _TrayTool_ClickText(_TrayTool_GetHandle(), "^Skype", False, 2) ; double clicks the skype tray icon
- ; ======================================================================================================================================================
- Func _TrayTool_GetHandle()
- Local $hwndTrayTool = ControlGetHandle("[CLASS:Shell_TrayWnd; INSTANCE:1]", "", "[CLASS:ToolbarWindow32; INSTANCE:1]")
- If IsHWnd($hwndTrayTool) Then Return $hwndTrayTool
- Return SetError(1, 0, 0)
- EndFunc
- ; #Function# ===========================================================================================================================================
- ; Name............: _TrayTool_ClickText
- ; Description.....: Enumerates all icons in tray from index and clicks the one that matches the regular expression
- ; Syntax..........: _TrayTool_ClickText($hwndTrayTool, $sPattern, $sButton = "left", $iClicks = 1, $iSpeed = 1)
- ; Parameters......:
- ; $hwndTrayTool- Handle from _TrayTool_GetHandle()
- ; $sPattern - A regular expression that matches the description of the icon to click
- ; $sButton - [optional] The button with that the click should be performed
- ; $fMove - [optional] If true the mouse will be moved
- ; $iClicks - [optional] Number of clicks
- ; $iSpeed - [optional] Mouse movement speed
- ; Return values ..:
- ; Success - 1 if _GUICtrlToolbar_ClickButton is called, since this function does not have a return value
- ; Failure - 0 and @error:
- ; | 1 - $hwndTrayTool is not a handle
- ; | 2 - Regular expression not found
- ; Author .........: FichteFoll
- ; Modified........:
- ; Remarks ........:
- ; Related ........: _GUICtrlToolbar_GetButtonText, _GUICtrlToolbar_ClickButton
- ; Link ...........;
- ; Example ........; _TrayTool_ClickText(_TrayTool_GetHandle(), "^Skype", False, 2) ; double clicks the skype tray icon
- ; ======================================================================================================================================================
- Func _TrayTool_ClickText($hwndTrayTool, $sPattern, $sButton = "left", $fMove = False, $iClicks = 1, $iSpeed = 1)
- If Not IsHWnd($hwndTrayTool) Then Return SetError(1, 0, 0)
- Local $iIndex = -1, $i = 0, $sBtnStringLast = '', $sBtnStringPreLast = ''
- Local $iCmdID = _GUICtrlToolbar_IndexToCommand($hwndTrayTool, $i), $sBtnString = _GUICtrlToolbar_GetButtonText($hwndTrayTool, $iCmdID)
- While $sBtnString <> $sBtnStringLast Or $sBtnStringLast <> $sBtnStringPreLast
- If StringRegExp($sBtnString, $sPattern) Then Return _TrayTool_ClickButton($hwndTrayTool, $iCmdID, $sButton, $fMove, $iClicks, $iSpeed)
- $sBtnStringPreLast = $sBtnStringLast
- $sBtnStringLast = $sBtnString
- $i += 1
- $iCmdID = _GUICtrlToolbar_IndexToCommand($hwndTrayTool, $i)
- $sBtnString = _GUICtrlToolbar_GetButtonText($hwndTrayTool, $iCmdID)
- WEnd
- Return SetError(2, 0, 0)
- EndFunc
- ; See _GUICtrlToolbar_ClickIndex for equivalent
- Func _TrayTool_ClickIndex($hwndTrayTool, $iIndex, $sButton = "left", $fMove = False, $iClicks = 1, $iSpeed = 1)
- If Not IsHWnd($hwndTrayTool) Then Return SetError(1, 0, 0)
- Return 1 + _GUICtrlToolbar_ClickIndex($hwndTrayTool, $iIndex, $sButton, $fMove, $iClicks, $iSpeed)
- EndFunc
- ; See _GUICtrlToolbar_ClickButton for equivalent
- Func _TrayTool_ClickButton($hwndTrayTool, $iCmdID, $sButton = "left", $iClicks = 1, $iSpeed = 1)
- If Not IsHWnd($hwndTrayTool) Then Return SetError(1, 0, 0)
- Return 1 + _GUICtrlToolbar_ClickButton($hwndTrayTool, $iCmdID, $sButton, $fMove, $iClicks, $iSpeed)
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement