cyberlogs Posted July 4, 2010 Share Posted July 4, 2010 Hey autoit users im kinda stuck in my project at the moment, cause i simply just cant figure out how to solve the following problem.... I have a GUI with some checkbox's on and a button. then i have a text file which look like this -- a bunch of random code -- Encryption = True Set Style = 3 //can be 1,2,3,4 & 5 Password = xxxx -- a bunch of random code -- my question is now, how can i locate the string "Encryption = " and then overwrite the "True" with a "False" i want it so that if i check the checkbox in my GUI and then press the button it should open the file, find the string Encryption and change it to True/false wether the checkbox is checked or not Sorry for my poor english just post here if you need more information thanks in advance CL Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 4, 2010 Moderators Share Posted July 4, 2010 cyberlogs,Welcome to the AutoIt forum. One way to do what you asked:- Use FileRead to read the contents of the file.- Use StringReplace to replace your target string with the new one. I would replace the whole "Encryption = True/False" string.- Open the file with FileOpen - using mode 2 to overwrite the exisitng version - then FileWrite the new contents and finally FileClose to tidy up. Do not forget that you will need to use the handle returned by FileOpen with FileWrite and FileClose. - All done. have you looked at the Ini file commands? They might provide an easier way to save your values. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
cyberlogs Posted July 4, 2010 Author Share Posted July 4, 2010 cyberlogs,Welcome to the AutoIt forum. One way to do what you asked:- Use FileRead to read the contents of the file.- Use StringReplace to replace your target string with the new one. I would replace the whole "Encryption = True/False" string.- Open the file with FileOpen - using mode 2 to overwrite the exisitng version - then FileWrite the new contents and finally FileClose to tidy up. Do not forget that you will need to use the handle returned by FileOpen with FileWrite and FileClose. - All done. have you looked at the Ini file commands? They might provide an easier way to save your values. M23Thanks for the warm welcome as im pretty known in the ini i cant understand why i didnt thought of this, but anyway i got it working now thanks you very much, see you sometime in another topic CL 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