Sign in to follow this  
Followers 0
rorororo

Trying to learn AutoIt and appreciate help making this script.

8 posts in this topic

I just started learning AutoIt and love it so far. However, I'm not exactly sure how to create a script that would do the following.

I was wondering if someone could write a simple AutoIt script that would open a text document (let's call it milk.txt) and also open another notepad (Untitled - Notepad) then write everything from milk.txt to the new, untitled document. It should press enter whenever there is a new line.

I don't want it to just copy and paste since that wouldn't really work with what I plan on changing the script into. It needs to actually read each letter from milk.txt and send that keystroke to the new document.

Any help would be greatly appreciated, thanks.

Share this post


Link to post
Share on other sites



How about a simple use of the FileCopy (http://www.autoitscript.com/autoit3/docs/functions/FileCopy.htm) function?


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

How about a simple use of the FileCopy (http://www.autoitscript.com/autoit3/docs/functions/FileCopy.htm) function?

I didn't know about that before so thank you for showing me it. However, I was using copying from one text document to another as an example. I actually want to be able to read text from a text document and type it into any other window, whether it be Firefox, AIM, etc. Sorry for not just saying that in the original post. I wanted to get an example script from someone else then be able to edit it to my own liking in order to get the hang of scripting with AutoIt.

Share this post


Link to post
Share on other sites

Look at any of File functions in the Help file, and also the Send and ControlSend functions. The links in my sig are helpful and/or contain links to other helpfulsome things..


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Here's an example where each character from milk.txt is sent to a new notepad with a keystroke. I would use the example in the previous post, it's more efficient.

dim $sendChar
dim $readFile = ".\milk.txt"
dim $dataInfo = FileRead($readfile)
dim $dataCount = @extended
dim $dataArray = StringSplit($dataInfo, "", 0)
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
For $x=1 To $dataCount Step 1
    $sendChar = $dataArray[$x]
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sendChar)
Next
Exit

Share this post


Link to post
Share on other sites

I just started learning AutoIt and love it so far. However, I'm not exactly sure how to create a script that would do the following.

I was wondering if someone could write a simple AutoIt script that would open a text document (let's call it milk.txt) and also open another notepad (Untitled - Notepad) then write everything from milk.txt to the new, untitled document. It should press enter whenever there is a new line.

I don't want it to just copy and paste since that wouldn't really work with what I plan on changing the script into. It needs to actually read each letter from milk.txt and send that keystroke to the new document.

Any help would be greatly appreciated, thanks.

You'll need to read the help file as I'm only giving you pseudo code and you will have to turn it into AutoIT:

Open up milk.txt in input mode
Open up notepad.exe 
Do the following until end of file is reached
  Read a line from the input file
  Write it to the notepad screen
  Write a end-of-line @CRLF to the notepad screen
Loop until the end of file is reached
Close the input file
Do whatever you want to in the notepad screen

This is a simple exercise that is taught early on in programming classes. It involves loops, file manipulation, and string manipulation.

You will probably find the autoit 123 tutorial of significant assistance also. I suggest you spend some time there and then return with any remaining questions.

Share this post


Link to post
Share on other sites

Thank you all very much for the replies! It was only three lines. I am very impressed with how great this language is. :mellow:

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