DocTorCoder Posted March 13, 2015 Share Posted March 13, 2015 (edited) Hi Guys. I wrote a lot of autoit scripts in last year and I saw something very annoying. For example when I search some words in a big file. For example in this little function who can rename variables from a .au3 file. Func testme($m) Local $file = FileRead($m),$newfile = $file Local $arfile = 0, $i = 0, $line = 0,$variables = 0, $j = 0, $test = 0 _FileReadToArray($m, $arfile) If $arfile[0] = "" Then Return 0 EndIf For $i = 1 To $arfile[0] Step +1 $line = StringSplit($arfile[$i], " =,()[]") If Not @error Then For $j = 1 To $line[0] Step +1 $test = StringSplit($line[$j], "$") If Not @error Then _ReplaceStringInFile($newcopy, $line[$j], $varsign & FORMULAVARIABLES()) EndIf Next EndIf Next Return 1 Endfunc Func FORMULAVARIABLES() Local $v1 = Chr(Random(Asc("A"), Asc("Z"), 1)) & Chr(Random(Asc("A"), Asc("Z"), 1)) & Random(1000, 100000, 1) & Chr(Random(Asc("A"), Asc("Z"), 1)) & Random(1000, 100000, 1) Return $v1 EndFunc All works good but if I apply this on a big file with 20k lines for example and it took like 1 minute (too much time) Now my question. Is any method to make jobs with autoit to run in background like a backgroundworker,without makeing the form to freeze? If exist already a topic with this and i didnt found it then please excuse me and post a link to there. I am new here and I wasn't so patient to read all stuffs PS: Why my name is not remain as I put it? It always changing to this default one! - " Solved" Edited March 13, 2015 by DocTorCoder DocTorCoder Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2015 Moderators Share Posted March 13, 2015 ChooseAnotherName, Why my name is not remain as I put it?I have sent you a PM to explain why - read it and then choose a sensible name. 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...
DocTorCoder Posted March 13, 2015 Author Share Posted March 13, 2015 ChooseAnotherName, I have sent you a PM to explain why - read it and then choose a sensible name. M23 Done with name. All are solved. But now my question about background. There is any way to put functions to work in background,without freezing my form? I want to avoid adlibregister too DocTorCoder Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2015 Moderators Share Posted March 13, 2015 DocTorCoder,As AutoIt is single-threaded there is no way to do "work in the background". But you seem to be taking a very roundabout way to replace variable names in a file - why not just use StringRegExpReplace directly on the file? That will almost certainly be quicker than looping through arrays. 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...
DocTorCoder Posted March 13, 2015 Author Share Posted March 13, 2015 (edited) DocTorCoder, As AutoIt is single-threaded there is no way to do "work in the background". But you seem to be taking a very roundabout way to replace variable names in a file - why not just use StringRegExpReplace directly on the file? That will almost certainly be quicker than looping through arrays. M23 Quicker maybe. But for a file with over 100k lines , it will still freeze the form . I think this can be done if I will pause the execution for a few miliseconds then again and again .... Anyway that stuffs with words seaarching is just an example.I want to have posibility to run 2 loops in same time,on 2 core's ... And as you said is impossible with autoit Edited March 13, 2015 by DocTorCoder DocTorCoder Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted March 13, 2015 Moderators Solution Share Posted March 13, 2015 DocTorCoder,You could always run the "replace" script as a separate process using /AutoIt3ExecuteScript - look in the Help file under <Using AutoIt - Running Scripts> to see how it is done. And you could also compile the script into .a3x format to make it as small as possible. 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...
DocTorCoder Posted March 13, 2015 Author Share Posted March 13, 2015 DocTorCoder, You could always run the "replace" script as a separate process using /AutoIt3ExecuteScript - look in the Help file under <Using AutoIt - Running Scripts> to see how it is done. And you could also compile the script into .a3x format to make it as small as possible. M23 /AutoIt3ExecuteScript ? I will search about that ... thanks DocTorCoder 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