Sign in to follow this  
Followers 0
hvymetal

Getting Text From Dos Window

10 posts in this topic

Is there anyway to copy the full text from a dos window to the clipboard. There should be a way since it is possible do it manual using the mouse to select the window and copying to the clipboard. I want to be able to copy all the text in the dos window to parse it for certian pharses to use as feedback in my scripts. Since Autoit has the abiltiy to send keys to the dos window it should also have a way look for feedback whats going in the running program. The program that I'm using stays open so I can't just pipe the output to a text file. The program runs in a dos window and is all text based so when I manually copy and pasted it using the mouse to notepad all the information is in text form.

I tried to search the forum and did not have any luck on coming up with any answers. So if someone could suggest a way I would be very thankfull.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Do you need it for 9x or 2k/xp?

on 2k/xp:

Send("!{space}")
Send("e")
Send("s")
Send("{enter}")
Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

That will work. I just wish it didn't show the menu bar popping up. In any case it will work just not as hidden as I like it to be.

Thanks for the tip.

Share this post


Link to post
Share on other sites

Ok it didn't work completely. It only selects the first line and not the full dos box window. I tried using the Mark command in the window and and sending

controlsend("C:\","","","!{space}ek")

controlsend("C:\","","","{SHIFTDOWN}{PGDN}{RIGHT 80}{SHIFTUP}{ENTER}")

but for some reason the {SHIFTDOWN} does not work.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ok it didn't work completely.  It only selects the first line and not the full dos box window.  I tried using the Mark command in the window and and sending

controlsend("C:\","","","!{space}ek")

controlsend("C:\","","","{SHIFTDOWN}{PGDN}{RIGHT 80}{SHIFTUP}{ENTER}")

but for some reason the {SHIFTDOWN} does not work.

<{POST_SNAPBACK}>

its {SHIFT down} {SHIFT up}

treat the "ups" and "downs" as if they were numbers

(ie.) see your "{right 80}"

Edited by mcfr1es

Roger! You son of a big pile o' Monkey Nuts.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

its {SHIFT down} {SHIFT up}

treat the "ups" and "downs" as if they were numbers

According to the docs and my testing, it should be one word "{SHIFTDOWN}"

P.S. From the ControlSend docs: Note, this function cannot send all the characters that the usual Send function can (notably ALT keys) but it can send most of them--even to non-active or hidden windows! I believe there were also some issues with ControlSend and shift.

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

CyberSlug

You were right I replaced the ControlSend with Send and it worked correctly.

So if anyone wonders what I used here it is.

WinActivate ( "C:\")

send("!{space}ek{SHIFTDOWN}{PGDN}{RIGHT 80}{SHIFTUP}{ENTER}")

I just wished that there was a key like PGDN that would arrow over with one key and not using "{right 80}". The reason is that you can see the selection scan across the screen in the dosbox. So if anyone knows a better way I'm willing to listen.

All in all it works but I wish that Autoit had a way of getting the text from a dosbox built in. It would help out in the automation of Dos programs.

Edited by hvymetal

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Do you need the entire screen or just the results of the command?

Couldn't you just redirect the the output to a file?

If you still need to display on the dos screen then do a type to the file right

below the command.

Use > to create or overwrite a file.

If you wanted to append to the file use >>

Example:

RunWait(@COMSPEC & " /c ping google.com > C:\ping.txt")

RunWait(@COMSPEC & " /c type C:\ping.txt")

Edited by frogonalog

The world is flat - Class of 1492

Share this post


Link to post
Share on other sites

Frogonalog,

As I said in my orginal post the dos program stays open. So you can not just pipe it to a file. That only works on programs that run once and then exit. The program that I'm trying to automate is an OLD dos based PLC software. I want to be able to automate the process of downloading the program to the PLC. To automate it correctly I need status that I have serial commucation to the device. This information is showed on the screen so my idea is keep copying the screen and parse the result to look for the keywords if everything is ok.

Share this post


Link to post
Share on other sites

Frogonalog,

As I said in my orginal post the dos program stays open.  So you can not just pipe it to a file.  That only works on programs that run once and then exit.  The program that I'm trying to automate is an OLD dos based PLC software.  I want to be able to automate the process of downloading the program to the PLC.  To automate it correctly I need status that I have serial commucation to the device.  This information is showed on the screen so my idea is keep copying the screen and parse the result to look for the keywords if everything is ok.

<{POST_SNAPBACK}>

Sorry, you would think that I would have learned to read by now :">

I was also thinking that an API call to PeekNamedPipe using VB or vbscript and writing to a file could be done, but it sounds like you have it figured out.


The world is flat - Class of 1492

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