Jump to content

Reading the text in the command prompt


Recommended Posts

Dont say stdout nor piping it to a file, nor to clip.  I need to read the text that is in the window cmd.exe, is there any of the win* or _WinAPI_* stuff that might assist in reading the already populated console so i can capture that text?  WinActivate works, WinWaitActive works, but read does not capture anything.

I am running a bash command, and it returns data to the console, but this stream is unavailable via any of those mechanisms.  This has been verified by a guy at MS who is developing this stuff.

 

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

There has to be a better way:

#include <WinAPIFiles.au3>
#include <array.au3>
opt("WinTitleMatchMode" , 2)
_WinAPI_Wow64EnableWow64FsRedirection (False)

$filename = "lstest.txt"
If FileExists($filename) Then FileDelete($filename)

$sCommand = "ls //bin/"
filewrite($filename , $sCommand)

$hCmd = run("cmd /k bash lstest.txt")

sleep(10000)

send("^a")
send("^c")

ProcessClose($hCmd)

$aArray = stringsplit(StringRegExpReplace(ClipGet() , "\s\s+" , @LF) , @LF , 2)

_ArrayDelete($aArray , ubound($aArray) - 1)

_ArrayDisplay($aArray)

 

Edited by iamtheky
changed wait to a sleep since ^c kills scripts

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...