DeeCee Posted November 25, 2005 Share Posted November 25, 2005 Howdy all! I'm new around here and new to using AutoIt in general, so please be gentle. DeeCee--> After loading a text file into an edit control (no probs), is there a way to copy the contents of the edit control into memory for further processing? I'm hoping to do some heavy processing to the content in memory using StringReplace, then write that data back to a new file, without disturbing the original text. Then I'll start the process over again.. This seems so simple in theory, but after a couple of hours of reading the docs and trying different approaches, I guess I must resort to begging for help. I probably don't need any specific code, but something like: "Hey dummy, first you do this, then this, then..) Thx for any assistance you can offer, DeeCee Link to comment Share on other sites More sharing options...
jpm Posted November 25, 2005 Share Posted November 25, 2005 If you can do it WITHOUT AutoIt with the keyboard and mouse YOU should do it with AutoIT Post the first try you did because it is difficult to help you from a general stand point. At least post what you do without AutoIT and we will help you to write the AutoIt counterpart. Link to comment Share on other sites More sharing options...
DeeCee Posted November 25, 2005 Author Share Posted November 25, 2005 YOU should do it with AutoITOkay, that's encouraging.Since this is part of a much larger program, I'll separate the part that I need help with and post again.Thx,DeeCee Link to comment Share on other sites More sharing options...
DeeCee Posted November 25, 2005 Author Share Posted November 25, 2005 Got it finally! It may not be pretty, but it works so I thought I'd post it in case someone else run's into a jam. Here's the code: expandcollapse popup#include <GuiConstants.au3> If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GuiCreate("ReplaceString Sample", 750, 480,(@DesktopWidth-750)/2, (@DesktopHeight-600)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Button_1 = GuiCtrlCreateButton("Open Template File", 10, 10, 145, 25) $Edit_2 = GuiCtrlCreateEdit("", 10, 40, 730, 160) $Label_3 = GuiCtrlCreateLabel("This Is the sample output:", 10, 270, 550, 20) $Edit_4 = GuiCtrlCreateEdit("", 10, 290, 730, 180) $Button_5 = GuiCtrlCreateButton("Process Edit Control", 570, 210, 140, 40) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 GetTemplateFile() Case $msg = $Button_5 ProcessRecords() EndSelect WEnd Exit Func GetTemplateFile() $message = "Choose a file..." $myTemplate = FileOpenDialog($message, "C:\", "All Files (*.*)", 1 + 4 ) $TemplateTxt = FileRead($myTemplate, FileGetSize($myTemplate)) GUICtrlSetData ( $Edit_2, $TemplateTxt) EndFunc Func ProcessRecords() $NewText = GUICtrlRead($Edit_2) $NewText = StringReplace ($NewText,"[FIRSTSTRING]", "my new string!") $NewText = StringReplace ($NewText,"[SECONDSTRING]", "my 2nd new string!") GUICtrlSetData ( $Edit_4, $NewText) EndFunc Here's a sample file for testing purposes: This is [FIRSTSTRING] This is [SECONDSTRING] Thx, DeeCee 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