Sign in to follow this  
Followers 0
Smiley357

Command prompt

5 posts in this topic

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

Share this post


Link to post
Share on other sites



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.

:P


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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

yes I know I'm late ! Posted Image

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... Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Thanks a lot wakillon.it works.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0