Sign in to follow this  
Followers 0
smartsnake

How to get text from a command window?

7 posts in this topic

I want copy the text from a command window. I have tried some clauses below but failed to get it. (The .\text.log is empty) Can you help me to solve the problem? Thanks!

......

Run(@WindowsDir & "\system32\cmd.exe")

Sleep(1000)

WinActivate("C:\WINDOWS\system32\cmd.exe")

Send("cd c:\ {Enter}")

Sleep(5000)

$text = WinGetText("C:\WINDOWS\system32\cmd.exe")

FileWrite(".\text.Log", $text & @CRLF)

WinClose("")

......

Share this post


Link to post
Share on other sites




[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

Thanks for you answer. But what I want to do is get the text from a command window, like the process below.

we can click mouse right button on one command window, the select "Select All", then press "Enter" button at the keyboard. After that, we can open a text file and paste the whole command window text to this file.

Now I want to use AutoIt to realize the whole process. Can you help me ?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

write anything to command window and press 'a' button to start the program
HotKeySet("a","doit")

func doit()
mousemove(X,Y);make sure X and Y move your cursor to the comand window
mouseclick("right")
mousemove(X-"300",Y); when you have a right click, a context menu appear near the cursor, so use this to move the cursor down near the current position at the "Select All" text, this line of code won't do that for you, you must find the position yourself and change it but i think this way is possible
mouseclick("left");this press the "selectall" if the position is right
send("^c")
sleep(1000)
run("notepad.exe")
opt("winTitleMatchMode",2)
winwaitactive(" - Notepad")
send("^v")
endfunc

hope you can make it or there'll be some better solution

Edited by d4rk

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

1. You Can't Get Text From CMD.. Heres A Working Example :)

Example :

Run ("Notepad.exe")
Sleep ('200')
WinActivate ('Untitled - Notepad')
Send ('First Line Test Text...')
Send ('{Enter}')
Send ('Second Line Test Text')
Sleep ('200')
$Win_Text = WinGetText ('Untitled - Notepad')
MsgBox ('0','Msg Box Example', $Win_Text,'1')
FileWriteLine ('File Example.txt', $Win_Text)

Hope This Helps

~ John


Latest Projects :- New & Improved TCP Chat

Share this post


Link to post
Share on other sites

1. You Can't Get Text From CMD.. Heres A Working Example :)

Example :

Run ("Notepad.exe")
Sleep ('200')
WinActivate ('Untitled - Notepad')
Send ('First Line Test Text...')
Send ('{Enter}')
Send ('Second Line Test Text')
Sleep ('200')
$Win_Text = WinGetText ('Untitled - Notepad')
MsgBox ('0','Msg Box Example', $Win_Text,'1')
FileWriteLine ('File Example.txt', $Win_Text)

Hope This Helps

~ John

he asked for help with the text in CMD, it's P0ssible to do this with StdoutRead(), but in the last post, he ask to do this in a simple way (like manually) but you didn't ment it ?

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

Opps.. Sorry Heres A Simple Example...

#Include <ClipBoard.Au3>
$CMD = ('Cmd.Exe')
ShellExecute ($CMD)
Sleep ('200')
$Get_Title = WinGetTitle ('C:\WINDOWS\')
$Get_Pos = WinGetPos ($Get_Title)
MouseClick ('Right', $Get_Pos[0] + '50', $Get_Pos[1] + '50')
Sleep ('200')
_ClipBoard_Empty ()
For $Array = '1' To '4'
Send ('{Down}')
Next
Send ('{Enter}')
$Get_Text = ClipGet ()
FileWriteLine ('Cmd.txt', $Get_Text)

Now I Hope That Helps

~ John


Latest Projects :- New & Improved TCP Chat

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