Sign in to follow this  
Followers 0
Mutebox

Text file copy line

9 posts in this topic

Ok I have a little problem, I know this is a primitive way to do a copy and paste and couldnt find anything in the functions that would do this better. The problem is that when it goes through the sets it only copies 1 of 2 times running it which doesnt help when it needs to copy and paste everything in the first time for what i want it to do. If you guys have any Suggestions please let me know how i can do this better. Thanks in advance!

$clipboard = ClipGet()

WinActivate("textfile.txt - Notepad")
    Send("{DOWN}")
    Send("{SHIFTDOWN}" & "{END}")
    Send("{SHIFTUP}")
    Send("{CTRLDOWN}" & "{C}")
    Send("{CTRLUP}")
    Send("{HOME}")
    
MsgBox(0, "Clipboard contains:", $clipboard)

Share this post


Link to post
Share on other sites



Is there a reason that you couldn't read the file into an array?

#include <file.au3>

Global $aArray
Global $sTxtFile = "C:\textfile.txt"

If Not _FileReadToArray($sTxtFile, $aArray) Then
    MsgBox(4096, "Error", "Error reading file to Array     error:" & @error)
    Exit
EndIf

For $iLine = 1 To $aArray[0]
    MsgBox(0, "Line:" & $iLine, $aArray[$iLine])
Next
Hate to say it but I am a novice to arrays and do not know how to use all the functions yet. Arrays should be explained in the help file right?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Ok I have a little problem, I know this is a primitive way to do a copy and paste and couldnt find anything in the functions that would do this better. The problem is that when it goes through the sets it only copies 1 of 2 times running it which doesnt help when it needs to copy and paste everything in the first time for what i want it to do. If you guys have any Suggestions please let me know how i can do this better. Thanks in advance!

$clipboard = ClipGet()

WinActivate("textfile.txt - Notepad")
    Send("{DOWN}")
    Send("{SHIFTDOWN}" & "{END}")
    Send("{SHIFTUP}")
    Send("{CTRLDOWN}" & "{C}")
    Send("{CTRLUP}")
    Send("{HOME}")
    
MsgBox(0, "Clipboard contains:", $clipboard)
You can interact directly with Notepad's Edit1 control, for example:
Global $hNotepad = WinGetHandle("textfile.txt - Notepad", ""); Get handle to window
Global $clipboard = ClipGet(); Get clipboard contents
    
; Replace the contents
ControlSetText($hNotepad, "", "Edit1", $clipboard)

; Append the contents
$sCurrentText = ControlGetText($hNotepad, "", "Edit1")
ControlSetText($hNotepad, "", "Edit1", $sCurrentText & @CRLF & $clipboard)

Much more complicated operations are possible, with a little learning of the functions.

Send()'ing raw keystrokes is not required, and is much less reliable.

:unsure:

P.S. Or, you could ignore Notepad altogether and work directly on the file, as big_daddy demonstrated before I got my post typed!

:P

Edited by PsaltyDS

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

Hate to say it but I am a novice to arrays and do not know how to use all the functions yet. Arrays should be explained in the help file right?

We were all novices at some point. Here is a link that does a pretty good job of explaining arrays.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Both are very nice examples! Thanks, I will read up on the arrays and others.

Just one is there any other functions that would allow you to communicate with a website: example buttons, text boxes, etc.?

This isnt going to be a spammer or anything just trying to make a program that checks sites then posts them in a database, kind of like a crawler or something.

Edited by Mutebox

Share this post


Link to post
Share on other sites

In the help file look under: User Defined Funtions --> IE Management

Share this post


Link to post
Share on other sites

In the help file look under: User Defined Funtions --> IE Management

Thanks again Big_daddy you have helped me a bunch!

Share this post


Link to post
Share on other sites

Thanks again Big_daddy you have helped me a bunch!

You're welcome!

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