Hello everyone, I've been making a very basic AutoIt script to read a .txt file and paste it, page by page, into a certain Java application.
The files contain simple pages of text, several lines long. I made the script scan every single text line: If it contains only the characters "@np", which I use as a 'line break', it will turn the page, and if not, it will copy and then paste the line.
The code below has worked for me so far, but since the script pastes the text line by line, it's somewhat slow for long texts... I'm sure there must be a way to paste per whole page, but I haven't been able to figure it out. Any help?
Edit: Here is an example of a file that I use with the program, to clear up any confusion:
The files contain simple pages of text, several lines long. I made the script scan every single text line: If it contains only the characters "@np", which I use as a 'line break', it will turn the page, and if not, it will copy and then paste the line.
The code below has worked for me so far, but since the script pastes the text line by line, it's somewhat slow for long texts... I'm sure there must be a way to paste per whole page, but I haven't been able to figure it out. Any help?
#include <File.au3> $file = FileOpen("C:\Myfile.txt", 0) Sleep (3000) ; Gives me three seconds to switch to the app before starting. Should probably use a hotkey, but it works well enough for me! While 1 $line = FileReadLine($file) If @error Then ExitLoop If $line=='@np' Then ; "@np" means a pagebreak, the script will click the "next page" button and continue. MouseClick('left') ; Since "next page" button can vary in placement, I simply place my cursor on it when running the script. Else ClipPut($line) Send("^v{ENTER}") ; If the line is not "@np", it will be pasted, line by line. EndIf Sleep (50) ; Although the script itself works fine without this sleep time, the app starts acting up if I don't wait 50 miliseconds between paste... WEnd FileClose($file)
Edit: Here is an example of a file that I use with the program, to clear up any confusion:
I do not like green eggs and ham. @np I do not like them, Sam-I-am.