;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; AutoIt Version: 3.0 ; Language: English ; Platform: Win2000/XP/2003/Vista ; Author: Core Technologies Consulting, LLC ; ; Script Function: ; Sends the ENTER key to a given window ; ; Usage: ; SendEnterKeyToWindow [-d] ; where the optional -d flag specifies to show debugging ; information. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Expect at least 1 argument, the window name ; Exit if less than 1 argument if $CmdLine[0] < 1 Then MsgBox(0x40000, 'SendEnterKeyToWindow', 'Usage:' & @CRLF & @CRLF & 'SendEnterKeyToWindow [-d]') Exit(1) EndIf $windowName = $CmdLine[1] ; If the 2rd argument is -d, then show debug $showDebug = "no" if $CmdLine[0] >=2 Then if $CmdLine[2] = "-d" Then $showDebug = "yes" Endif EndIf if $showDebug = "yes" Then MsgBox(0x40000, 'SendEnterKeyToWindow', 'Parameters:' & @CRLF & @CRLF & 'Window name = "' & $windowName & '"') EndIf ; Wait for the window to become active if (WinActivate($windowName)) Then if $showDebug = "yes" Then MsgBox(0x40000, 'SendEnterKeyToWindow', 'Window "' & $windowName & '" found, sending the ENTER key.') EndIf ; Send the key press $result = ControlSend($windowName, "", "", "{ENTER}") if $showDebug = "yes" Then MsgBox(0x40000, 'SendEnterKeyToWindow', 'Done sending the ENTER key, result ="' & $result & '".') EndIf Else if $showDebug = "yes" Then MsgBox(0x40000, 'SendEnterKeyToWindow', 'Window "' & $windowName & '" NOT found.') EndIf EndIf