Capture text in Dos Window

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Capture text in Dos Window

Post by kpassaur » Thu Apr 28, 2005 1:05 pm

Is there any way to capture the text in a dos program window? I cannot get it with copying to the clipboard, or GetControltext. I have been forced to print the screen to a text file and then parse out the text file.

Any ideas on how this screen can be captured?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Apr 28, 2005 1:51 pm

Not sure what you mean by:
I cannot get it with copying to the clipboard
In the upper left hand corner of a DOS window there is an icon, it is part of the DOS window banner. If you pick on that icon you will get a menu. One item in that menu is "edit". If you pick "edit" you will see another menu item called "mark". after picking mark you can use your mouse to sweep across and highlight any part of the DOS window. After you get some text highlighted, pressing enter will put the "marked" text to the clipboard. You can then paste to any other windows app.

Does this help?
Dick

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Thank you

Post by kpassaur » Thu Apr 28, 2005 3:12 pm

I never knew it was there before - thanks, one thing I have noticed about it is that it does not list short cut keys, I have tried them CTRL + A and CTRL + C and it works sometimes but not always so I quess I will have to use the menu

Thanks again

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Apr 28, 2005 4:21 pm

This works on my machine:


SetFocus>Command Prompt*
MouseMoveRel>15,15
LClick
Wait>0.5
Press Down*7
Press Right
Press Enter
Wait>0.2
Press Shift
Press Right*80
Press Down*30
Release Shift
Press Enter


You will have to setfocus on the correct window name and you might have to adjust the wait times or even add a few and of course the number of press right and press down will depend upon your situation.

This example starts marking at the upper left corner of the text window, you could use "MouseMoveRel" then "LClick" to start at a different location.

Hope this helps,
Dick

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Script now parses data

Post by kpassaur » Thu Apr 28, 2005 10:13 pm

The finished script is below - it is useful to find the line number and location of data to be parsed. It can be used on a text file (you copy the text to the clipboard) or from a DOS Window

Dialog>Dialogbx1
Caption=Parse Data Utility
Top=298
Width=451
Left=286
Height=177
Label=Do you want to Parse Data from a Dos Window,24,40
Label=Do you want to Parse Data from the Clipboard,40,72
Label=Exit Utility,208,104
Button=Yes,288,32,75,25,1
Button=Yes,288,64,75,25,3
Button=Exit,288,96,75,25,2
EndDialog>Dialogbx1


Label>displayd1
Show>Dialogbx1,result
If>result=1,comwind
If>result=2,EOF
If>result=3,clipit
Goto>displayd1


Label>comwind
SetFocus>Command*
Wait>.5
MouseMoveRel>200,200
RClick
Press Down * 4
Press Enter * 2
Goto>donecapture
Label>clipit
Ask>Copy the data to the clipboard and then click on YES to continue or NO to exit utility,continue
If>%continue%=YES,donecapture,EOF

Label>donecapture
Getclipboard>capturedtext

Deletefile>c:\temp\test.txt
Deletefile>c:\temp\test2.txt
WriteLn>c:\temp\test.txt,result,%capturedtext%

Let>k=1
Label>start
ReadLn>c:\temp\test.txt,k,line
If>line=##EOF##,finish
If>linec:\temp\test2.txt,result,Line #%k%
WriteLn>c:\temp\test2.txt,result,%line%
WriteLn>c:\temp\test2.txt,result,12345678911111111112222222222333333333344444444445555555555666666666677777777777
WriteLn>c:\temp\test2.txt,result, 01234567890123456789012345678901234567890123456789012345678901234567890
WriteLn>c:\temp\test2.txt,result,%CRLF%
Label>skipwrite
Let>k=k+1
Goto>start
Label>finish
ExecuteFile>c:\temp\test2.txt

Input>ln,Please enter the Line Number
If>ln=,NoValue
Input>sp,Please enter the Start Position
If>sp=,NoValue
Input>ep,Please enter the End Position
If>sp=,NoValue

Let>z=1
Label>startparse
ReadLn>c:\temp\test.txt,z,linep
If>linep=##EOF##,finishparse
If>%z%=%ln%,writetest,skipwrite2
Label>writetest
MidStr>linep,%sp%,%ep%,pdata
MDL>%pdata%
GoTo>EOF
Label>skipwrite2
Let>z=z+1
Goto>startparse
Label>finishparse

SRT>NoValue
MDL>No Value was entered the Utility will Close
Goto>EOF
END>NoValue


Label>EOF

Thank you all for your help

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts