Jump to content
Sign in to follow this  
Traciatim

DOS Window - Copy

Recommended Posts

Traciatim

I'm using a key sequence (ALT-SPACE - Then E - Then S - Then Enter) to copy ifrom a DOS window. I then you ClipGet() to get the contents of the clipvoard, but when I display them it only displays a 1 (As in an error).

I can follow the same key sequence and get the text and paste it in to notepad, so I'm wondering what I'm doing wrong with my AutoIt Script

Traciatim

Share this post


Link to post
Share on other sites
Alterego

here's a program i wrote that (while very shoddy) can work as a replacement for cmd.exe and will log everything.

see also microsoft's webpage on command redirection operators.

basically, say you wanted to ping someone and log the output, your autoit code would look like this

RunWait(@ComSpec & ' /c ping 127.0.0.1>C:\cmd.log.txt')

Or if you want it to append to a log file you use two >>

RunWait(@ComSpec & ' /c ping 127.0.0.1>>C:\cmd.log.txt')

you can do other stuff with the output. read the ms page. gl

Share this post


Link to post
Share on other sites
Blue_Drache

I'm using a key sequence (ALT-SPACE - Then E - Then S - Then Enter) to copy ifrom a DOS window. I then you ClipGet() to get the contents of the clipvoard, but when I display them it only displays a 1 (As in an error).

I can follow the same key sequence and get the text and paste it in to notepad, so I'm wondering what I'm doing wrong with my AutoIt Script

Traciatim

<{POST_SNAPBACK}>

Opt("WinTitleMatchMode",2)
Run(@comspec)
WinWait("cmd.exe")
WinActivate("cmd.exe")
Send("dir{enter}")
Sleep(1500)
Send("!{space}ES{enter}")
MsgBox(0,"ClipBoard Contents",ClipGet())

Displays the contents of the clipboard just fine for me.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
DaveF

Console redirection is probably the best way to do this, more options for doing so should be avaiable soon.

N.B. that the full-on Unix-like redirection abilities aren't available on all Windows versions.


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites
Blue_Drache

can you explain this in more detail? are we going to be able to specify our autoit prog as a handle?

<{POST_SNAPBACK}>

He's talking about COM functions currently in Alpha testing phase. There's a thread in the Dev section about it.... 3.1.0++ I believe...

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
DaveF

yeah i figured as much, but i don't understand how that is going to help with this.  do you have a link to a good "com for someone who has no idea what com is a.k.a dummies" website?

Actually I was talking about console I/O redirection, lets you provide the console input and output for command line apps that you call with Run().

Thread about it here with a link to download.


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites
Traciatim

Sleep(1500)

Send("!{space}ES{enter}")

MsgBox(0,"ClipBoard Contents",ClipGet())

. . .

this is almost exatly what I have, except I use $clipstuff = ClipGet() and then the MsgBox displays $clipstuff, which is always 1, no matter the contents of the DOS window... since I'm on a remote desktop connection, I have it pause slightly between the ALT+SPACE, then wait and hit E, then wait and hit S, then wait and hit ENTER.

Still nothing yet, any other ideas?

Share this post


Link to post
Share on other sites
Alterego

im not sure what you mean by still nothing yet...it's really easy to get the text. just use the > redirection operator and put it to a text file. then do _FileReadToArray, and then do _ArrayToString, and then do StringReplace for the delimiter you use in _ArrayToString. for example, you might use % as a delimiter, and then replace it with @CRLF so you have a regularly formatted file. then use ClipPut() to put your string, which is the cmd.exe text, on the clipboard. the program i linked to above does this.

Share this post


Link to post
Share on other sites
Traciatim

I can't just take it out of a file because the file is 2 machines away, I connect to a server which then connects to a remote machine. I have to use the screen scrape to see what's on the screen since I can't get any window information from inside my original remote desktop connection.

I can connect manually, and hit ALT-SPACE, E, S, ENTER, then open notepad and paste but if I do it like this:

Sleep(1500)

Send("!{space}ES{enter}")

MsgBox(0,"ClipBoard Contents",ClipGet())

I get a message box that says 1

Share this post


Link to post
Share on other sites
Blue_Drache

I can't just take it out of a file because the file is 2 machines away, I connect to a server which then connects to a remote machine. I have to use the screen scrape to see what's on the screen since I can't get any window information from inside my original remote desktop connection.

I can connect manually, and hit ALT-SPACE, E, S, ENTER, then open notepad and paste but if I do it like this:

Sleep(1500)

Send("!{space}ES{enter}")

MsgBox(0,"ClipBoard Contents",ClipGet())

I get a message box that says 1

<{POST_SNAPBACK}>

Try the redirection commands as posted previously.

#Include <array.au3>
Dim $file,$aFileArray
Send("dir > c:\dir.txt{enter}")
$file FileOpen(C:\dir.txt,0); open in read mode
   If $file = -1 then MsgBox(0x13,"Error","Unable to open file")
_FileReadToArray($file,$aFileArray)
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
Traciatim

Here is where the problem lies with that:

Send("dir > c:\dir.txt{enter}") *** Can't write to drive, the machine that the DOS window is on is a server where we can't write or read to the drive.

The connection goes:

Local Machine (Remote Desktop) -> Win2K Server (Kermit) -> Linux Box at a Client

I need to download a file on to the Linux machine from our FTP site and then know when it is complete to continue with extraction and installation. I was trying tu use a screen scrape to get when the FTP> prompt returns, but I keep getting 1 as the contents of the clip board.

Share this post


Link to post
Share on other sites
Traciatim

Actually, I found it. I think it was caused by the lag between me and the server was it. I had to send it like:

send("!{SPACE}")

sleep(250)

send("e")

sleep(250)

send("s")

sleep(250)

send("{ENTER}")

sleep(250)

and then it worked...

Thanks for all the help.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.