Jump to content

Replace a line in an edit box


Go to solution Solved by donnyh13,

Recommended Posts

Hello.
I am new to autoit, 2-3 months of dealing with it. I bump on it looking for making a bot for making meanless clicks on a game :P, and stuck on it.
I made a lot of small scripts for different jobs since then.
I 've made a script now that do various jobs, p.e. kill programs that don't want to run anymore, clean junks, boost memory, play music , etc
I choose every time the jobs i want in a list in an edit box, i don't want everything all the time.
Everything works fine. The script read each line, do the job and go to the next. If a job isn't available, it go to the next one (p.e. the programs i want to killl are not loaded yet).
I want when it go to end, come back and start over to do what's left.
I was thinking replace the line of the edit box that was done with  the word DONE, so the script bypass that line and go to the next
I don't want to erase the line so i can looking it and know what has be done or not.


That's the problem.
I can replace only the first line, when start for the second, third, etc, it loosing it, replacing half worlds, place DONE on the same line twice etc...
You can see the pics that it loses it after the first replace.

I search the forum and i find a lot about replacing lines in txt files, but my problem is that it is not a file.
I tried using stringinstring too, but no luck (i haven't understand strings very well yet).
Maybe edit boxes couldn't replaced, i don't know.

That's my code for the replace:
 

Local Static $line = 0 ;the line of the edit box
Local Static $start = 0 

$linelength = _GUICtrlEdit_LineLength($g_idMemo, $line)
_GUICtrlEdit_SetSel($g_idMemo, $start, $linelength+1)
_GUICtrlEdit_ReplaceSel($g_idMemo,"Done"&@CRLF, False)
$line +=1 ;go to next line in each pass
$start += 6 ;start with a DONE more

Any help is appreciated, or any other ideas how to make the script avoid the already done jobs
Thank you

Jobs1.png

Jobs2.png

Jobs3.png

Jobs4.png

Link to comment
Share on other sites

  • Solution
Posted (edited)

I think

_GUICtrlEdit_SetSel($g_idMemo, $start, $linelength+1)

needs to be

_GUICtrlEdit_SetSel($g_idMemo, $start, $start + $linelength+1)
Edited by donnyh13

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

Spoiler

"Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."

 

Link to comment
Share on other sites

You are most welcome

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

Spoiler

"Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...