siage Posted August 4, 2009 Share Posted August 4, 2009 Hello all, I'm the new comer to AutoIt, I write my first AutoIt script to perform check disk task in winpe environment,when the script executed, a window popup and then waiting the user's confirm, I use send("{Y 1}{enter 1}") to input Y and enter, but it seemed not work.I think the popuped windows not active. I use the LANDesk provisioning to execute AutoIt script,it execute startnet.cmd first, then call AutoIt script. My script run("chkdsk /r e:") sleep(2000) send("{Y 1}{enter 1}") sleep(2000) send("{Y 1}{enter 1}") sleep(2000) send("{Y 1}{enter 1}") Who can help me to resolve it ? Link to comment Share on other sites More sharing options...
water Posted August 4, 2009 Share Posted August 4, 2009 (edited) What do you want to achieve with send("{Y 1}{enter 1}") Send Key "Y" followed by "Enter"? In this case you should code: Send("Y{ENTER}") Edited August 4, 2009 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
siage Posted August 4, 2009 Author Share Posted August 4, 2009 What do you want to achieve with send("{Y 1}{enter 1}") Send Key "Y" followed by "Enter"? In this case you should code: Send("Y{ENTER}") I thought {Y 1} input Y only once, I followed your instruction, it worked well.I'll fix it. but how can I make sure the "Y" send to the correct cmd window?I mean the window with chkdsk command? Link to comment Share on other sites More sharing options...
Ascend4nt Posted August 5, 2009 Share Posted August 5, 2009 (edited) @siage *edit: oops, misunderstood what was going on.. chkdsk is prompting for input with another window? Have you tried using the AutoIT Window Info tool to see what the window's title, classname, etc are? You should be able to get a handle to that, and send a command to it based on what you want to do. If there are buttons, you could just send a 'space' to the 'Yes' button etc Edited August 5, 2009 by Ascend4nt My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
whim Posted August 5, 2009 Share Posted August 5, 2009 @siage try doing it with just the cmd line: Run(@ComSpec & " /c echo y | chkdsk /r e:") (not tested on chkdsk, but works fine on a format command for me) Link to comment Share on other sites More sharing options...
herewasplato Posted August 5, 2009 Share Posted August 5, 2009 @siage,Welcome to the forum :-)I thought {Y 1} input Y only once, ...The syntax that you used is correct, but not needed. The brackets are optional except when sending a key like ENTER, ESC, PAUSE...The number of times to send it is also optional if it is 1 time.So:Send("Y")Send("{Y}")Send("{Y 1}")are the same.And:Send("YY")Send("{Y}{Y}")Send("{Y 2}")are the same.Anyway, whim gave you a good solution. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Danny35d Posted August 5, 2009 Share Posted August 5, 2009 (edited) Siage welcome to AutoIt check the help file and search for StdinWriteThis code is from the StdinWrite() help file example slightly modify to your need:#include <Constants.au3> Local $PID = Run("chkdsk /r e:", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) ; Write string to STDIN StdinWrite($PID, 'Y' & @CRLF) ; Calling with no 2nd arg closes stream StdinWrite($PID) ; Read from child's STDOUT and show Local $data While True $data &= StdoutRead($PID) If @error Then ExitLoop Sleep(25) WEnd MsgBox(0, "Debug", $data) Edited August 6, 2009 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line 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