vladedoty Posted March 26, 2010 Share Posted March 26, 2010 (edited) Here's what i am trying to do is have this script search the script folder for all text files then open them up 1 by one and replace all occurrences of one word with the next and after the replaces, close the file and open the next and do the same thing til all have been edited. i need help plz if someone is kind enough here is the code #Include <File.au3> #Include <Array.au3> $textTitle = "[REGEXPTITLE:.*Notepad.*]" $search = FileFindFirstFile("*.*") If $search == -1 Then Exit While 1 $file = FileFindNextFile($search) If @error Then ExitLoop ConsoleWrite("File: " & $file) ShellExecute($file, "", @ScriptDir) WinActivate($textTitle) $textHwnd = WinGetHandle($textTitle) ConsoleWrite(WinGetTitle($textHwnd)) Sleep(2000) Send("!{E}") Send("{R}") Sleep(2000) ControlFocus($textHwnd, "", "[CLASS:Edit; INSTANCE:1]") ControlSend($textHwnd, "", "[CLASS:Edit; INSTANCE:1]", "chucknevermuck") Sleep(300) ControlFocus($textHwnd, "", "[CLASS:Edit; INSTANCE:2]") ControlSend($textHwnd, "", "[CLASS:Edit; INSTANCE:2]", "ckim111") Sleep(300) ControlFocus($textHwnd, "", "[CLASS:Button; INSTANCE:5]") ControlClick($textHwnd, "", "[CLASS:Button; INSTANCE:5]", "left", 1) WinClose($textHwnd) SendKeepActive("[REGEXPTITLE:\ANotepad\z]") Send("{Space}") WEnd Edited March 26, 2010 by vladedoty Link to comment Share on other sites More sharing options...
BrettF Posted March 26, 2010 Share Posted March 26, 2010 Hi vladedoty, What I would recommend for this project is to construct an array of files (using your own function, file list to array or what not), then do the read (FileRead), replace (StringReplace/StringRegExpReplace) and the save the modified text (FileOpen with mode 2 = Overwrite mode, FileWrite (with reference to the previously opened file handle)). So in pseudo code: Construct Array of Files For Each File: Read the contents StringReplace FileOpen FileWrite FileClose End Or something like that. Give it a go and if you have any problems you know where to go. The helpfile, then the search, then post back here Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now