| 1 | ; #FUNCTION# =====================================================
|
|---|
| 2 | ; Name...........: __GUICtrlTab_ClickTab
|
|---|
| 3 | ; Description ...: Clicks a tab
|
|---|
| 4 | ; Syntax.........: _GUICtrlTab_ClickTab($hWnd, $iIndex[, $sButton = "left"[, $fMove = False[,
|
|---|
| 5 | ; $iClicks = 1[, $iSpeed = 1]]]])
|
|---|
| 6 | ; Parameters ....: $hWnd - Handle to control
|
|---|
| 7 | ; $iIndex - Specifies the zero based index of the item
|
|---|
| 8 | ; $fButton - Button to click with
|
|---|
| 9 | ; $fMove - If True, the mouse will be moved.
|
|---|
| 10 | ; - If False, the mouse does not move.
|
|---|
| 11 | ; $iClicks - Number of clicks
|
|---|
| 12 | ; $iSpeed - Mouse movement speed
|
|---|
| 13 | ; Return values .:
|
|---|
| 14 | ; Author ........: Paul Campbell (PaulIA)
|
|---|
| 15 | ; Modified.......: Gary Frost (gafrost)
|
|---|
| 16 | ; : PsaltyDS - Modified to use ControlClick() when $fMove = False so window
|
|---|
| 17 | ; does not have to be active
|
|---|
| 18 | ; Remarks .......:
|
|---|
| 19 | ; Related .......:
|
|---|
| 20 | ; Link ..........;
|
|---|
| 21 | ; Example .......; Yes
|
|---|
| 22 | ; ================================================================
|
|---|
| 23 | Func __GUICtrlTab_ClickTab($hwnd, $iIndex, $sButton = "left", $fMove = False, $iClicks = 1, $iSpeed = 1)
|
|---|
| 24 | Local $iX, $iY, $tPoint, $tRect, $iMode, $aPos, $hWinParent, $avTabPos
|
|---|
| 25 | If $Debug_TAB Then _GUICtrlTab_ValidateClassName($hwnd)
|
|---|
| 26 | If Not IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
|
|---|
| 27 |
|
|---|
| 28 | If Not $fMove Then
|
|---|
| 29 | ; Don't move mouse, use ControlClick()
|
|---|
| 30 | $hWinParent = _WinAPI_GetParent($hwnd)
|
|---|
| 31 | $avTabPos = _GUICtrlTab_GetItemRect($hwnd, $iIndex)
|
|---|
| 32 | $iX = $avTabPos[0] + (($avTabPos[2] - $avTabPos[0]) / 2)
|
|---|
| 33 | $iY = $avTabPos[1] + (($avTabPos[3] - $avTabPos[1]) / 2)
|
|---|
| 34 | ControlClick($hWinParent, "", $hwnd, $sButton, $iClicks, $iX, $iY)
|
|---|
| 35 | Else
|
|---|
| 36 | ; Original code to move mouse and click (requires active window)
|
|---|
| 37 | $tRect = _GUICtrlTab_GetItemRectEx($hwnd, $iIndex)
|
|---|
| 38 | $tPoint = _WinAPI_PointFromRect($tRect, True)
|
|---|
| 39 | $tPoint = _WinAPI_ClientToScreen($hwnd, $tPoint)
|
|---|
| 40 | _WinAPI_GetXYFromPoint($tPoint, $iX, $iY)
|
|---|
| 41 | $iMode = Opt("MouseCoordMode", 1)
|
|---|
| 42 | MouseClick($sButton, $iX, $iY, $iClicks, $iSpeed)
|
|---|
| 43 | Opt("MouseCoordMode", $iMode)
|
|---|
| 44 | EndIf
|
|---|
| 45 | EndFunc ;==>__GUICtrlTab_ClickTab
|
|---|