Sign in to follow this  
Followers 0
struhlo

command prompt ControlGetText

3 posts in this topic

Hi,

does anybody know how to dig out text from windows command prompt using ControlGetText or WinGetText ?

I have used this little script to get focus but without luck :

$focus = ControlGetFocus("Command Prompt")

$text = ControlGetText("", "", "$focus")

MsgBox(0, "Text read was:", $text)

i always get blank msgbox.

When i try to check the command prompt window using au3info, i get empty fields in Basic control info for Class and Instance, after pointing the target to command prompt window.

could you please advice me what am i doing wrong, if it is possible or suggest to try some alternative solution ?

thanks a lot

Share this post


Link to post
Share on other sites



If you are using a standard run command box StdoutRead should work for you. Check it out in the autoit help file it gives an example that is pretty easy to follow:

; Demonstrates StdoutRead()
#include 

$foo = Run(@ComSpec & " /c dir foo.bar", 
@SystemDir, 
@SW_HIDE, 
$STDERR_CHILD + $STDOUT_CHILD)

While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDOUT 
read:", $line)
Wend

While 
1
    $line = StderrRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDERR 
read:", $line)
Wend

MsgBox(0, "Debug", "Exiting...")

"I have discovered that all human evil comes from this, man's being unable to sit still in a room. " - Blaise Pascal

Share this post


Link to post
Share on other sites

As you found, a Windows command line shell is a unique place with it's own rules. You can use the $STDOUT_CHILD option and StdOutRead(). This works fine, but intercepts the stream before it is displayed on the desktop console.

There have been discussions about how to both see it on the screen and capture at the same time, so it can be done. But I haven't had need of it yet, so I haven't experimented. A little searching should turn it up if you need that.

:)


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

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