;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; AutoIt Version: 3.0 ; Language: English ; Platform: Win2000/XP/2003/Vista ; Author: Core Technologies Consulting, LLC ; ; Script Function: ; Clicks a given button on a given window ; ; Usage: ; ClickButton [-d] ; where the optional -d flag specifies to show debugging ; information. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Expect at least 2 arguments, the window and button names ; Exit if less than 2 arguments if $CmdLine[0] < 2 Then MsgBox(0x40000, 'ClickButton', 'Usage:' & @CRLF & @CRLF & 'ClickButton [-d]') Exit(1) EndIf $windowName = $CmdLine[1] $buttonName = $CmdLine[2] ; If the 3rd argument is -d, then show debug $showDebug = "no" if $CmdLine[0] >=3 Then if $CmdLine[3] = "-d" Then $showDebug = "yes" Endif EndIf if $showDebug = "yes" Then MsgBox(0x40000, 'ClickButton', 'Parameters:' & @CRLF & @CRLF & 'Window name = "' & $windowName & '"' & @CRLF & 'Button name = "' & $buttonName & '"') EndIf ; Wait for the window to become active if (WinActivate($windowName)) Then if $showDebug = "yes" Then MsgBox(0x40000, 'ClickButton', 'Window "' & $windowName & '" found, clicking the "' & $buttonName & '" button.') EndIf ; Click the button ControlClick($windowName, $buttonName, "") Else if $showDebug = "yes" Then MsgBox(0x40000, 'ClickButton', 'Window "' & $windowName & '" NOT found.') EndIf EndIf