Sign in to follow this  
Followers 0
TheBobynator

read dos

11 posts in this topic

#1 ·  Posted (edited)

hi,

how can i get the text from a dos window. i mean the black window. is it possible?

thx

Edited by TheBobynator

Share this post


Link to post
Share on other sites



Yes...

#include <Constants.au3>
; Example Usage
$result= _CMDreturn('net stop "Print Spooler"')
msgbox(0,"Version",$result)

;Another Example Usage
$result= _CMDreturn('net start "Print Spooler"')
msgbox(0,"Version",$result)

Func _CMDreturn($sCommand) ; This function returns the output of a DOS command as a string
    $cmdreturn = ""
    $stream = Run(@ComSpec & " /c " & $sCommand, @SystemDir, @SW_HIDE, $STDERR_MERGED + $STDIN_CHILD)
    While 1 ; loop through the return from the command until there is no more
        $line = StdoutRead($stream)
        If @error Then ExitLoop
        $cmdreturn &= $line
    WEnd
    Return $cmdreturn
EndFunc   ;==>_CMDreturn

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

this script is very complicated. :P i want to read a specific dos window. where must i put the name of the window which i want to read in?

sry for my english

Share this post


Link to post
Share on other sites

That script does not work that way. I do not think it is possible to read from a pre-existing DOS window.. unless you are looking at some kind of OCR method.


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

whats ocr? :P

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

whats ocr? :P

Optical Character Recognition.

I think you should put the keyboard down and back away slowly before your hurt anyone but yourself.

Edited by JamesBrooks

Share this post


Link to post
Share on other sites

That script does not work that way. I do not think it is possible to read from a pre-existing DOS window.. unless you are looking at some kind of OCR method.

That's exactly what I'm trying to do -- read from a pre-existing DOS window that is spawned by a windows app. I can get its process id, and I can send text to the dos window via the send command once I activate the window. However, this dos popup window does some processing of its own before asking user to input data, and I need to somehow determine when it's ready for input. Any help would definitely be appreciated!

Thanks,

Danny

Share this post


Link to post
Share on other sites

Perhaps this helps:

MsgBox(0+262144, "", "click OK to start a sample CMD window")
$cmd = "ipconfig"
Run(@ComSpec & " /k " & $cmd, "", @SW_SHOW)
MsgBox(0+262144, "", "click OK to read the window to clipbox and show result")
WinWaitActive("[CLASS:ConsoleWindowClass]")
Send("!{space}{down 6}{right}{down 3}{enter 2}")
MsgBox(0+262144, "", ClipGet())

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

Perhaps this helps:

MsgBox(0+262144, "", "click OK to start a sample CMD window")
$cmd = "ipconfig"
Run(@ComSpec & " /k " & $cmd, "", @SW_SHOW)
MsgBox(0+262144, "", "click OK to read the window to clipbox and show result")
WinWaitActive("[CLASS:ConsoleWindowClass]")
Send("!{space}{down 6}{right}{down 3}{enter 2}")
MsgBox(0+262144, "", ClipGet())
Yes, this is helpful. After searching through the forums, someone suggested the ALT+SPACE > E > S > {Enter} method of capturing the text to the clipboard, which I believe is what you're illustrating above. Thank you for the quick response!

Share this post


Link to post
Share on other sites

Yes, this is helpful. After searching through the forums, someone suggested the ALT+SPACE > E > S > {Enter} method of capturing the text to the clipboard, which I believe is what you're illustrating above. Thank you for the quick response!

ALT+SPACE > E > S > {Enter} works fine on english locale, but other languages have other letters.

For Germany it would be B(earbeiten) + A(lles markieren)

My method is language independant, :D

And even works in Windows 7. :o


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

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