Sign in to follow this  
Followers 0
Guest danp

Win2K cmd.exe window text

9 posts in this topic

Newbie question: Is it commonly understood that Win2K "cmd.exe" windows are of such form/structure that AutoIt cannot see the window text? The SPY app tells me Window title is "DOS", but no Window Text, regardless of what I see. So I expect since SPY cannot see the text, neither can AutoIt.

Wondering if it's part of newbie learning curve that says "nope.. can't see the text because.... ". Or maybe there's some properties of the window that need to be changed that will enable text accessibility.

Thanks.

Share this post


Link to post
Share on other sites



you are correct that you cannot automatically SEE the text in a cmd window... could try...

I follow the logic, and your quick reply appreciated.

Share this post


Link to post
Share on other sites

You also have the option of redirecting the DOS output to a file which AU3 can then access:

;let's build an array of files in a folder
    $aFiles = _GetFileList("C:\WINNT")
    msgBox(0,"Number of files",$aFiles[0])

Func _GetFileList($psFolder)
   ;decide on a temp file
    $sTmp = @TempDir & "\~getlist.lst"
   ;Reroute a DIR command to the temp file
    RunWait(@COMSPEC & " /c DIR /B /A-D """ & $psFolder & """>""" & $sTmp & """", "", @SW_HIDE)
   ;Read the textfile into an array
    $sFileList = FileRead($sTmp, FileGetSize($sTmp))
   ;Cleanup
    FileDelete($sTmp)
   ;And leave
    Return StringSplit(StringReplace($sFileList, @CRLF, @LF),@LF)
EndFunc

.. HTH :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You also have the option of redirecting the DOS output to a file which AU3 can then access:

This wont work if we are working with a DOS application..it works with dos commands though...

If we have an Input box in a DOS application...AutoIT cannot recognize these controls...and getting the text is also a problem...should have the flexibility....

larry's idea might work but not comprehensive....

-Bala

Edited by Balachander K

Share this post


Link to post
Share on other sites

This wont work if we are working with a DOS application..it works with dos commands though...

If we have an Input box in a DOS application...AutoIT cannot recognize these controls...and getting the text is also a problem...should have the flexibility....

larry's idea might work but not comprehensive....

-Bala

Get the latest Beta and check out the I/O redirection flags for the RUN() function:

Run ( "filename" [, "workingdir" [, flag[, standard_i/o_flag]]] )

standard_i/o_flag

[optional] Provide a meaningful handle to one or more STD I/O streams of the child process.

1 ($STDIN_CHILD) = Provide a handle to the child's STDIN stream

2 ($STDOUT_CHILD) = Provide a handle to the child's STDOUT stream

4 ($STDERR_CHILD) = Provide a handle to the child's STDERR stream

Set the flag for $STDOUT_CHILD and then you read it with the StdoutRead() function.

By setting $STDOUT_CHILD + $STDIN_CHILD, you can be interactive using StdoutRead() and StdinWrite().

Cool new stuff in the Beta! :D


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

#6 ·  Posted (edited)

i am not able to make it work.

#include <Constants.au3>

$foo = Run(@ComSpec & " /c abcd.defg.com 10345", "", @SW_MAXIMIZE,$STDIN_CHILD + $STDOUT_CHILD)
Sleep(5000)
StdinWrite($foo, "USERID{TAB}PASSWORD")
Sleep(5000)
While 1
    $line = StdoutRead($foo)
    If @error = -1 Then ExitLoop
    MsgBox(0, "STDOUT read:", $line)
Wend

Its just not sending the userid and password...it exits peacefully without throwing any error...

Edited by Balachander K

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

@Balachander K

Try keeping the @ComSpec window open by using the /k switch instead of /c.

Edit:

Not sure, but you may need to have your StdinWrite() after the StdOutRead, as that maybe when Comspec is ready to receive the data.

Edited by MHz

Share this post


Link to post
Share on other sites

@Balachander K: Looks like you want to telnet.

#include <Constants.au3>

$foo = Run("telnet abcd.defg.com 10345", "", @SW_MAXIMIZE,$STDIN_CHILD + $STDOUT_CHILD)
Sleep(2000)
MsgBox(0, "", Stdoutread($foo))
StdinWrite($foo, "USERID{TAB}PASSWORD")
Sleep(5000)
While 1
    $line = StdoutRead($foo)
    If @error = -1 Then ExitLoop
    MsgBox(0, "STDOUT read:", $line)
Wend

I have not tested this, and I don't think it will even work, but give it a try anyway.

#)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Thanks guys...but both the suggestions are not working.....

/k option does keep it visible but the telnet is not going thro...

For the nfwu code...its same result like mine...

I am sticking to larry's suggestion. in fact i completed my code with that and its perfectly fine as of now....

Larry/anyone can u explain what ("!{SPACE}es{ENTER}") actually does??

Thanks and Regards,

Bala

Edited by Balachander K

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