wookiee Posted January 19, 2008 Share Posted January 19, 2008 Howzit Im writing a macro and I need to mouse click on the programs in the taskbar I know I have to activate the taskbar window to use the mouse co-ordinates in taskbar window, how do I do this Please help and thank you for your time Regards wookiee ( hair to the throne) Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 19, 2008 Share Posted January 19, 2008 Howzit Im writing a macro and I need to mouse click on the programs in the taskbar I know I have to activate the taskbar window to use the mouse co-ordinates in taskbar window, how do I do this Please help and thank you for your time Regards wookiee ( hair to the throne) The entire tray is a window. The taskbar is a Toolbar control in the tray window. The apps on the taskbar are buttons on that Toolbar control. Here's a demo to show how to work with them: #include <GuiToolbar.au3> Opt("WinTitleMatchMode", 4) ; Get handle to tray window $hTrayWindow = WinGetHandle("[CLASS:Shell_TrayWnd; INSTANCE:1]") ConsoleWrite("Debug: $hTrayWindow = " & $hTrayWindow & @LF) ; Get handle to Toolbar control (taskbar) $hTaskBar = ControlGetHandle($hTrayWindow, "", "[CLASS:ToolbarWindow32; INSTANCE:2]") ConsoleWrite("Debug: $hTaskBar = " & $hTaskBar & @LF) ; List the buttons with Index/CommandID/Text $iTaskCount = _GUICtrlToolbar_ButtonCount($hTaskBar) ConsoleWrite("Debug: $iTaskCount = " & $iTaskCount & @LF) For $n = 0 To $iTaskCount - 1 $iButtonIndex = $n $iButtonCommandID = _GUICtrlToolbar_IndexToCommand($hTaskBar, $iButtonIndex) $sButtonText = _GUICtrlToolbar_GetButtonText($hTaskBar, $iButtonCommandID) ConsoleWrite("Debug: Index: " & $iButtonIndex & " Command ID: " & $iButtonCommandID & " Text: " & $sButtonText & @LF) Next Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GaryFrost Posted January 19, 2008 Share Posted January 19, 2008 The entire tray is a window. The taskbar is a Toolbar control in the tray window. The apps on the taskbar are buttons on that Toolbar control. Here's a demo to show how to work with them: #include <GuiToolbar.au3> Opt("WinTitleMatchMode", 4) ; Get handle to tray window $hTrayWindow = WinGetHandle("[CLASS:Shell_TrayWnd; INSTANCE:1]") ConsoleWrite("Debug: $hTrayWindow = " & $hTrayWindow & @LF) ; Get handle to Toolbar control (taskbar) $hTaskBar = ControlGetHandle($hTrayWindow, "", "[CLASS:ToolbarWindow32; INSTANCE:2]") ConsoleWrite("Debug: $hTaskBar = " & $hTaskBar & @LF) ; List the buttons with Index/CommandID/Text $iTaskCount = _GUICtrlToolbar_ButtonCount($hTaskBar) ConsoleWrite("Debug: $iTaskCount = " & $iTaskCount & @LF) For $n = 0 To $iTaskCount - 1 $iButtonIndex = $n $iButtonCommandID = _GUICtrlToolbar_IndexToCommand($hTaskBar, $iButtonIndex) $sButtonText = _GUICtrlToolbar_GetButtonText($hTaskBar, $iButtonCommandID) ConsoleWrite("Debug: Index: " & $iButtonIndex & " Command ID: " & $iButtonCommandID & " Text: " & $sButtonText & @LF) Next Good use of the Toolbar udf Here's some other stuff to look at that I was playing around with a while back: http://www.autoitscript.com/forum/index.ph...c=59287&hl= SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 19, 2008 Share Posted January 19, 2008 Good use of the Toolbar udf Here's some other stuff to look at that I was playing around with a while back: http://www.autoitscript.com/forum/index.ph...c=59287&hl= I'm curious why it lists two buttons for each app. I actually have three apps on the taskbar: Firefox, SciTE, and the help file. This is the output of the script: >Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\AutoIt3\Scripts\Test_1.au3" Debug: $hTrayWindow = 0x005A007C Debug: $hTaskBar = 0x001E00E0 Debug: $iTaskCount = 6 Debug: Index: 0 Command ID: 0 Text: Firefox Debug: Index: 1 Command ID: 1 Text: Fun with the taskbar - AutoIt Forums - Mozilla Firefox Debug: Index: 2 Command ID: 4 Text: SciTE - a Scintilla based Text Editor Debug: Index: 3 Command ID: 5 Text: C:\Program Files\AutoIt3\Scripts\Test_1.au3 - SciTE [1 of 3] Debug: Index: 4 Command ID: 6 Text: Microsoft® HTML Help Executable Debug: Index: 5 Command ID: 7 Text: AutoIt Help +>11:03:42 AutoIT3.exe ended.rc:0 Two indexes and two CommandIDs for each app...? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
wookiee Posted January 19, 2008 Author Share Posted January 19, 2008 The entire tray is a window. The taskbar is a Toolbar control in the tray window. The apps on the taskbar are buttons on that Toolbar control. Here's a demo to show how to work with them: #include <GuiToolbar.au3> Opt("WinTitleMatchMode", 4) ; Get handle to tray window $hTrayWindow = WinGetHandle("[CLASS:Shell_TrayWnd; INSTANCE:1]") ConsoleWrite("Debug: $hTrayWindow = " & $hTrayWindow & @LF) ; Get handle to Toolbar control (taskbar) $hTaskBar = ControlGetHandle($hTrayWindow, "", "[CLASS:ToolbarWindow32; INSTANCE:2]") ConsoleWrite("Debug: $hTaskBar = " & $hTaskBar & @LF) ; List the buttons with Index/CommandID/Text $iTaskCount = _GUICtrlToolbar_ButtonCount($hTaskBar) ConsoleWrite("Debug: $iTaskCount = " & $iTaskCount & @LF) For $n = 0 To $iTaskCount - 1 $iButtonIndex = $n $iButtonCommandID = _GUICtrlToolbar_IndexToCommand($hTaskBar, $iButtonIndex) $sButtonText = _GUICtrlToolbar_GetButtonText($hTaskBar, $iButtonCommandID) ConsoleWrite("Debug: Index: " & $iButtonIndex & " Command ID: " & $iButtonCommandID & " Text: " & $sButtonText & @LF) Next Link to comment Share on other sites More sharing options...
wookiee Posted January 19, 2008 Author Share Posted January 19, 2008 (edited) The entire tray is a window. The taskbar is a Toolbar control in the tray window. The apps on the taskbar are buttons on that Toolbar control. Here's a demo to show how to work with them: #include <GuiToolbar.au3> Opt("WinTitleMatchMode", 4) ; Get handle to tray window $hTrayWindow = WinGetHandle("[CLASS:Shell_TrayWnd; INSTANCE:1]") ConsoleWrite("Debug: $hTrayWindow = " & $hTrayWindow & @LF) ; Get handle to Toolbar control (taskbar) $hTaskBar = ControlGetHandle($hTrayWindow, "", "[CLASS:ToolbarWindow32; INSTANCE:2]") ConsoleWrite("Debug: $hTaskBar = " & $hTaskBar & @LF) ; List the buttons with Index/CommandID/Text $iTaskCount = _GUICtrlToolbar_ButtonCount($hTaskBar) ConsoleWrite("Debug: $iTaskCount = " & $iTaskCount & @LF) For $n = 0 To $iTaskCount - 1 $iButtonIndex = $n $iButtonCommandID = _GUICtrlToolbar_IndexToCommand($hTaskBar, $iButtonIndex) $sButtonText = _GUICtrlToolbar_GetButtonText($hTaskBar, $iButtonCommandID) ConsoleWrite("Debug: Index: " & $iButtonIndex & " Command ID: " & $iButtonCommandID & " Text: " & $sButtonText & @LF) Next Thank you for the imfo but Im having a problem implementing the examples you gave me into the Macro,here is the macro Ive writen(I want to use the mouse click to select the minimized program, if you dont mind go down into the macro, I have written in red were I need to go into the task bar and select a certain program,again thanks for your time and patients Global $Paused HotKeySet("^+e","vExit") ;hotkey to stop the script HotKeySet("{PAUSE}","TogglePause") Func TogglePause() $Paused = NOT $Paused While $Paused Sleep(100) Wend EndFunc Func vExit() Exit EndFunc Sleep (10000) While 1 = 1 ; SELECTION OF PROGRAM FROM TASKBAR Over here I need to enter the task bar and click on a minimized program Mouseclick ("left",544,11)-co-ordinates for mouse click in taskbar Sleep (1000) ; UNDOCKING Mouseclick ("left",77,984) Sleep (40000) ; CLICK SHIELD BOOSTER MouseClick ("left",765,954) Sleep (1000) ; CLICK PEOPLE & PLACES Mouseclick ("left",19,193) Sleep (3000) ; CLICK BELT Mouseclick ("right",618,624) Sleep (1000) ; CLICK WARP TO LOCATION WITHIN 0M Mouseclick ("left",654,636) Sleep (60000) ; CLICK PEOPLE AND PLACES OFF Mouseclick ("left",821,479) Sleep (1000) ; CLICK RIOD IN OVERVIEW Mouseclick ("left",1141,181) Sleep (1000) ; CLICK LOCK TARGET Mouseclick ("left",1129,114) Sleep (5000) ; CLICK STRIP MINER/ ICE HARVESTER 1 Mouseclick ("left",789,912) Sleep (1000) ; CLICK STRIP MINER/ ICE HARVESTER 2 Mouseclick ("left",741,913) Sleep (1226000) ; CLICK PEOPLE & PLACES Mouseclick ("left",19,193) Sleep (3000) ; CLICK *STATION MouseClick ("Right",671,606) Sleep (1000) ; CLICK WARP TO LOCATION WITHIN 0M (BACK TO STATION) Mouseclick ("left",766,617) Sleep (50000) ; CLICK *STATION MouseClick ("Right",671,606) Sleep (1000) ; CLICK DOCK MouseClick ("Left",701,635) Sleep (1000) ; CLICK *STATION MouseClick ("Right",671,606) Sleep (1000) ; CLICK DOCK MouseClick ("Left",701,635) Sleep (50000) ; CLICK PEOPLE AND PLACES OFF Mouseclick ("left",821,479) Sleep (2000) ; MOVE MOUSE OVER ROIDS MouseMove (182,953) Sleep (1000) ; CLICK ROID & DRAG TO HANGAR MouseClickDrag ("left",182,953,1069,931) Sleep (5000) Wend Edited January 19, 2008 by wookiee Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 21, 2008 Share Posted January 21, 2008 (edited) Thank you for the imfo but Im having a problem implementing the examples you gave me into the Macro,here is the macro Ive writen(I want to use the mouse click to select the minimized program, if you dont mind go down into the macro, I have written in red were I need to go into the task bar and select a certain program,again thanks for your time and patients Global $Paused HotKeySet("^+e","vExit") ;hotkey to stop the script HotKeySet("{PAUSE}","TogglePause") Func TogglePause() $Paused = NOT $Paused While $Paused Sleep(100) Wend EndFunc Func vExit() Exit EndFunc Sleep (10000) While 1 = 1 ; SELECTION OF PROGRAM FROM TASKBAR Over here I need to enter the task bar and click on a minimized program Mouseclick ("left",544,11)-co-ordinates for mouse click in taskbar Sleep (1000) ; ... I don't understand why you are using static mouse coordinates to click on it. How do you know they won't change? Using the techniques illustrated above, get the handle for the toolbar, and the CommandID of the particular app's item. Then you can get coordinates with _GUICtrlToolbar_GetButtonRect() and mouse click if you must, or just use _GuiCtrlToolBar_ClickButton(), or _GuiCtrlToolBar_ClickIndex(). Ah, but there's a hitch... and we needed to help Gary with his failing memory... But he came through for us whith his update to PaulIA's AU3LIB and here are the functions: expandcollapse popup; #FUNCTION# ================================================================================ ; Name...........: _GUICtrlToolbar_ClickButton ; Description ...: Clicks a specific button ; Syntax.........: _GUICtrlToolbar_ClickButton($hWnd, $iCommandID[, $sButton = "left"[, $fMove = False[, $iClicks = 1[, $iSpeed = 1]]]]) ; Parameters ....: $hWnd - Handle to the control ; $iCommandID - Button command ID ; $sButton - Button to click ; $fMove - Mouse movement flag: ; | True - Mouse will be moved ; |False - Mouse will not be moved ; $iClicks - Number of clicks ; $iSpeed - Mouse movement speed ; Return values .: ; Author ........: Paul Campbell (PaulIA) ; Modified.......: Gary Frost ; Remarks .......: ; Related .......: _GUICtrlToolbar_ClickAccel, _GUICtrlToolbar_ClickIndex ; Link ..........; ; Example .......; Yes ; ========================================================================================= Func _GUICtrlToolbar_ClickButton($hWnd, $iCommandID, $sButton = "left", $fMove = False, $iClicks = 1, $iSpeed = 1) If $Debug_TB Then _GUICtrlToolbar_ValidateClassName($hWnd) Local $tPoint, $tRect, $iX, $iY, $iMode, $aPos $tRect = _GUICtrlToolbar_GetButtonRectEx($hWnd, $iCommandID) $tPoint = _WinAPI_PointFromRect($tRect) $tPoint = _WinAPI_ClientToScreen($hWnd, $tPoint) _WinAPI_GetXYFromPoint($tPoint, $iX, $iY) If Not $fMove Then $iMode = Opt("MouseCoordMode", 1) $aPos = MouseGetPos() Opt("MouseCoordMode", $iMode) _WinAPI_ShowCursor(False) MouseClick($sButton, $iX, $iY, $iClicks, $iSpeed) MouseMove($aPos[0], $aPos[1], 0) _WinAPI_ShowCursor(True) Else MouseClick($sButton, $iX, $iY, $iClicks, $iSpeed) EndIf EndFunc ;==>_GUICtrlToolbar_ClickButton ; #FUNCTION# ================================================================================ ; Name...........: _GUICtrlToolbar_ClickIndex ; Description ...: Clicks a specific button using it's index ; Syntax.........: _GUICtrlToolbar_ClickIndex($hWnd, $iIndex[, $sButton = "left"[, $fMove = False[, $iClicks = 1[, $iSpeed = 1]]]]) ; Parameters ....: $hWnd - Handle to the control ; $iIndex - Button index ; $sButton - Button to click ; $fMove - Mouse movement flag: ; | True - Mouse will be moved ; |False - Mouse will not be moved ; $iClicks - Number of clicks ; $iSpeed - Mouse movement speed ; Return values .: ; Author ........: Paul Campbell (PaulIA) ; Modified.......: ; Remarks .......: ; Related .......: _GUICtrlToolbar_ClickAccel, _GUICtrlToolbar_ClickButton ; Link ..........; ; Example .......; Yes ; ========================================================================================= Func _GUICtrlToolbar_ClickIndex($hWnd, $iIndex, $sButton = "left", $fMove = False, $iClicks = 1, $iSpeed = 1) If $Debug_TB Then _GUICtrlToolbar_ValidateClassName($hWnd) Local $iCommandID $iCommandID = _GUICtrlToolbar_IndexToCommand($hWnd, $iIndex) _GUICtrlToolbar_ClickButton($hWnd, $iCommandID, $sButton, $fMove, $iClicks, $iSpeed) EndFunc ;==>_GUICtrlToolbar_ClickIndex Edited January 21, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
testmeout Posted January 24, 2008 Share Posted January 24, 2008 I added the functions into GuiToolbar.au3, but I got the error: C:\Program Files\AutoIt3\Include\GuiToolbar.au3 (2105) : ==> Unknown function name.: $tPoint = _WinAPI_PointFromRect($tRect) $tPoint = ^ ERROR So I also needed to added the following functions into WinAPI.au3, just to let you know. expandcollapse popup; #FUNCTION# ==================================================================================================== ================ ; Description ...: Returns the top/left coordinates of a tagRECT as a tagPOINT structure ; Parameters ....: $tRect - tagRECT structure ; $fCenter - If True, the return will be a point at the center of the rectangle, otherwise the left/top ; +coordinates are returned. ; Return values .: Success - tagPOINT structure ; Author ........: Paul Campbell (PaulIA) ; Remarks .......: This function is used to get the click position for many of the click functions in the library ; Related .......: ; ==================================================================================================== =========================== Func _WinAPI_PointFromRect(ByRef $tRect, $fCenter = True) Local $iX1, $iY1, $iX2, $iY2, $tPoint $iX1 = DllStructGetData($tRect, "Left") $iY1 = DllStructGetData($tRect, "Top") $iX2 = DllStructGetData($tRect, "Right") $iY2 = DllStructGetData($tRect, "Bottom") If $fCenter Then $iX1 = $iX1 + (($iX2 - $iX1) / 2) $iY1 = $iY1 + (($iY2 - $iY1) / 2) EndIf $tPoint = DllStructCreate($tagPOINT) DllStructSetData($tPoint, "X", $iX1) DllStructSetData($tPoint, "Y", $iY1) Return $tPoint EndFunc ;==>_WinAPI_PointFromRect ; #FUNCTION# ==================================================================================================== ================ ; Description ...: Returns the X/Y values from a tagPOINT structure ; Parameters ....: $tPoint - tagPOINT structure ; $iX - X value ; $iY - Y value ; Return values .: ; Author ........: Paul Campbell (PaulIA) ; Remarks .......: This function extracts the X/Y values from a tagPOINT structure ; Related .......: _Lib_GetPointFromXY, _Lib_GetXYFromRect ; ==================================================================================================== =========================== Func _WinAPI_GetXYFromPoint(ByRef $tPoint, ByRef $iX, ByRef $iY) $iX = DllStructGetData($tPoint, "X") $iY = DllStructGetData($tPoint, "Y") EndFunc ;==>_WinAPI_GetXYFromPoint Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 24, 2008 Share Posted January 24, 2008 I added the functions into GuiToolbar.au3, but I got the error:C:\Program Files\AutoIt3\Include\GuiToolbar.au3 (2105) : ==> Unknown function name.: $tPoint = _WinAPI_PointFromRect($tRect) $tPoint = ^ ERRORSo I also needed to added the following functions into WinAPI.au3, just to let you know.Thanks for posting what you found. Did it work once you resolved that? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
testmeout Posted January 24, 2008 Share Posted January 24, 2008 Thanks for posting what you found. Did it work once you resolved that? Yup works great! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now