Sign in to follow this  
Followers 0
Luciana

Copy (Mouse selection) & Paste (in Text File)

12 posts in this topic

Hello Everyone,

I started yesterday using the Autoit tool.

I need your help to finish a script. All I want it to do is to Copy a selection and past it in a text file.

That´s how I´m trying to do it.

Func CopyPastPrint()

MouseClickDrag("left", 7, 27, 643, 315) ; Select the text area I want to copy

Send("^c") ; Copy

FileWrite($file, Send("^v") & @CRLF) ; Paste the selection in a Text File

EndFunc

Can anyone tell me what I'm doing wrong here?

If this question is too easy, I have another thing I have to do beside this. I have to see if the last 3 characters of this selection is equal to "END".

Any clue will be very welcome!!!

Thanks to all!!!

Luciana Cantarelli

Share this post


Link to post
Share on other sites



What goes wrong? Does anything happen at all? Have you opened the file for write before writing to it? What triggers your function?

As for "END":

If StringRight($sText, 3) = "END" Then MsgBox(64, "End", "The End.")

Changing '=' to '==' would make it case sensitive.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

What is this?

FileWrite($file, Send("^v") & @CRLF)oÝ÷ Ù:òjëh×6FileWrite($file, ClipGet() & @CRLF)


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

This code is part of a very large program. I just made it simple to post here.

The code:

Send("^c") ; ^c should be Ctrl-C command

FileWrite($file, Send("^v") & @CRLF)

; ^v should be Ctrl-V command. The file is opening ok, there is no error regarding to the file. I tried to use the ClipGet() function instead of Send("^v") , but it does not return the selection obtained during the Send("^c") command --it puts in the file others things that I have in my clipboard.

I was thinking in use the ClipPut() instead of Send("^c") to copy the selection otained during the MouseClickDrag(), but it doesn't work (or I don't know how to make it work).

Thanks for the replies!!!!

Luciana Cantarelli

Share this post


Link to post
Share on other sites

I don't know why you are doing what you are doing... or what data you are trying to get... Personally, I would probably just use ControlGetText or WinGetText and parse the strings that way... but to each their own.

If your clipboard has data... then clear it before calling Send("^c").

ClipPut("")

Send("^c")

FileWrite($file, ClipGet() & @CRLF)

The way you have it now with Send("^v") and FileWrite absolutely will not work.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

What is the app window you are selecting stuff from? If it's an IE window, or a game, Flash window, or several other types of apps, that technique may never work.

If you manually highlight with the mouse, and then manually use ctrl-c/ctrl-v to copy/paste, does it work?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Hi!

The purpose of what I´m doing is that my boss asked me to extract 225 reports from cobol system that is accessed using telnet. This system is descentralized and any report development would cost a lot of money to us. I know this report is extracted following easy and the same steps. That's why I want to do it using the Autoit. I actually did all the steps until the selection of the text, I just need to copy the selected text (from telnet) into a text file. This if the final result is this text file with all 225 screen one below the other.

I did what you recommended but it still didn´t work. :)

Atc.,

Luciana Cantarelli

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

PsaltyDS,

That´s what i was doing right now. I notice that sometimes de Ctrl-C works - sometimes it doen´t. Sometimes the Ctrl-INS (same thing as Ctrl-C) works, sometimes it doesn't. I have no clue why it's been so instable.

The app is that black promt Widowns screen (like DOS but runing the telnet.exe). You can try... go in Start > Run > telnet.

Thanks!

Edited by Luciana

Share this post


Link to post
Share on other sites

Have you tried ControlSend("Window Title Or Handle", "", "", "^c") after the drag?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

PsaltyDS,

That´s what i was doing right now. I notice that sometimes de Ctrl-C works - sometimes it doen´t. Sometimes the Ctrl-INS (same thing as Ctrl-C) works, sometimes it doesn't. I have no clue why it's been so instable.

The app is that black promt Widowns screen (like DOS but runing the telnet.exe). You can try... go in Start > Run > telnet.

Thanks!

Console telnet client?! Egad!! :)

Any chance you could just turn on logging in the telnet client, and parse the resulting file after you display all the required data?

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

hummm A lot of new information!!! Thanks!!!

1) How do I turn on the telnet logging?

2) What´s Egad?

3) Once I finish it all I´ll post as Script Example.

4) I attached the report I want to copy and past on a text file. Sorry this in portugues but you can have a clue.

Thanks!!!

Luciana

post-27791-1191613515_thumb.jpg

Edited by Luciana

Share this post


Link to post
Share on other sites

hummm A lot of new information!!! Thanks!!!

1) How do I turn on the telnet logging?

Depends on the version of windows/telnet client you are using, but something like:

TELNET -f C:\Temp\Telnet.log telnet.server.com

2) What´s Egad?

You don't know? Egad! ;)

3) Once I finish it all I´ll post as Script Example.

4) I attached the report I want to copy and past on a text file. Sorry this in portugues but you can have a clue.

That looks very much like you might be able to parse the file after the fact. Perhaps much quicker and easier than trying to automate the telnet console window itself.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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