Smiley357 Posted August 1, 2008 Posted August 1, 2008 Im trying to read text from the command prompt. I have tried to use $handle = WinGetHandle("classname=ConsoleWindowClass", "some text to look for")but it was unable to find the command prompt window. When I use AutoIt Window Info the only thing I get Is this. Is there any way to read a response from a command prompt window? >>>> Window <<<< Title: Command Prompt Class: ConsoleWindowClass Position: 110, 65 Size: 828, 931 Style: 0x14EF0000 ExStyle: 0x00040310 Handle: 0x005A0586 >>>> Control <<<< Class: Instance: ClassnameNN: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: 0x005804C4
PsaltyDS Posted August 1, 2008 Posted August 1, 2008 Im trying to read text from the command prompt. I have tried to use $handle = WinGetHandle("classname=ConsoleWindowClass", "some text to look for")but it was unable to find the command prompt window. When I use AutoIt Window Info the only thing I get Is this. Is there any way to read a response from a command prompt window? >>>> Window <<<< Title: Command Prompt Class: ConsoleWindowClass Position: 110, 65 Size: 828, 931 Style: 0x14EF0000 ExStyle: 0x00040310 Handle: 0x005A0586 >>>> Control <<<< Class: Instance: ClassnameNN: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: 0x005804C4 Use the $STDOUT_CHILD flag on Run() and the use StdOutRead() to get the text. I don't know any good ways to pull text from a pre-existing console window. 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
SoulA Posted August 1, 2008 Posted August 1, 2008 (edited) $foo = Run(@ComSpec & " /c tasklist /svc", @SystemDir, @SW_HIDE, $STDOUT_CHILD) Local $data = "" While True $data &= StdoutRead($foo) If @error Then ExitLoop Sleep(25) WEnd Edited August 1, 2008 by SoulA
wakillon Posted August 25, 2010 Posted August 25, 2010 (edited) yes I know I'm late ! Like says igorm in the topic ( http://www.autoitscript.com/forum/index.php?showtopic=64872 )Some times, certain command line Utility become unresponsive if you try to get output, whatever method.So I basicaly do this for Read from Command Prompt window :ClipPut ( '' ) $_ExePath = @SystemDir & '\cacls.exe' $_Pid = Run ( 'cmd /k "' & $_ExePath & '"', '', @SW_HIDE ) _WaitAndActivateWindow ( "[CLASS:ConsoleWindowClass]" ) _CopyAndCloseDosWindow ( "[CLASS:ConsoleWindowClass]" ) MsgBox ( 0, '', ClipGet ( ) ) Exit Func _WaitAndActivateWindow ( $_Title, $_Text='' ) WinWait ( $_Title, $_Text ) WinActivate ( $_Title, $_Text ) WinWaitActive ( $_Title, $_Text ) EndFunc ;==> _WaitAndActivateWindow ( ) Func _CopyAndCloseDosWindow ( $_Title, $_Text='' ) Send ( "{ESC}!{SPACE}{DOWN 6}{ENTER}{DOWN 3}{ENTER}") Send ( "!{SPACE}{DOWN 6}{ENTER}{DOWN 1}{ENTER}" ) WinClose ( $_Title, $_Text ) EndFunc ;==> _CopyAndCloseDosWindow ( )it's just to temporary troubleshoot !If it can help... Edited August 25, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
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