AasimPathan Posted April 26, 2019 Share Posted April 26, 2019 (edited) Hi, I have multiple autoit scripts stored inside my C:\ I would like to create a script that finds all the *.au3 scripts inside C:\ and subfolders and then somehow compile them to .exe Can someone help me create such a script? one method i thought of doing was running Powershell Get-ChildItem -Recurse -ErrorAction SilentlyContinue -Path C:\U_C | Select-Object FullName | ft -AutoSize | out-string -Width 600 *> C:\U_A\U_W\C_NonFiledFiles\U_Temp\AllAutoItScriptPath.txt How do i make AutoIT read that file using FileOpen or FileRead or FileReadLine functions, when there maybe 1 line or more than 20 lines, currently there are 15 and some of them are blank spaces for some reason, so i need a way to tell autoit if the path in the text file ends in .au3 to only copy that line. Once that is done i think the next part is much simpler to just run the autoit command line interface C:\Program Files (x86)\AutoIt3\Aut2Exe\Aut2exe_x64.exe /in [Path of the script] Edited April 26, 2019 by AasimPathan Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 26, 2019 Moderators Share Posted April 26, 2019 AasimPathan, Use _FileListToArrayRec to get the list of specified files into an array - makes it much simpler to deal with the listing later on in your script. 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...
AasimPathan Posted April 26, 2019 Author Share Posted April 26, 2019 (edited) 28 minutes ago, Melba23 said: AasimPathan, Use _FileListToArrayRec to get the list of specified files into an array - makes it much simpler to deal with the listing later on in your script. M23 Yeah that is what i tried as well but couldn't get it to work #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Test() Func Test() Local $RootDirectory = "C:\U_C" Local $RootOfU_C = StringLeft($RootDirectory, StringInStr($RootDirectory, "\", Default, -1)) If StringRight($RootOfU_C, 5) = "beta\" Then $RootOfU_C = StringTrimRight($RootOfU_C, 5) EndIf ConsoleWrite($RootOfU_C & @CRLF) $aArray = _FileListToArrayRec($RootOfU_C, "*.au3", $FLTAR_FILES) _ArrayDisplay($aArray, ".AU3 Files") EndFunc The Output is C:\ Edited April 26, 2019 by AasimPathan Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 26, 2019 Moderators Share Posted April 26, 2019 AasimPathan, You have not set the $iRecur parameter - which defaults to $FLTAR_NORECUR. 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...
AasimPathan Posted April 26, 2019 Author Share Posted April 26, 2019 (edited) 19 minutes ago, Melba23 said: AasimPathan, You have not set the $iRecur parameter - which defaults to $FLTAR_NORECUR. M23 Ok that worked, so now that i have the file list displayed how do I copy them to be placed in compile. Remember that his list will either increase or decrease over time. so it needs to work regardless of the number of Rows. Also I don't see the entire path here? it starts from the folder instead of C:\U_C\ Edited April 26, 2019 by AasimPathan Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 26, 2019 Moderators Share Posted April 26, 2019 AasimPathan, Dog eaten your help file? Check the $iReturnPath parameter to the function which adjusts what is returned. As you get a count in the [0] element of the array, you have a ready-made value to use in a loop regardless of the number of elements. And you do not need to "copy" the elements, you can just pass the elements to the compile command within that loop. M23 Zag8888 1 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...
AasimPathan Posted April 26, 2019 Author Share Posted April 26, 2019 19 minutes ago, Melba23 said: AasimPathan, Dog eaten your help file? Check the $iReturnPath parameter to the function which adjusts what is returned. As you get a count in the [0] element of the array, you have a ready-made value to use in a loop regardless of the number of elements. And you do not need to "copy" the elements, you can just pass the elements to the compile command within that loop. M23 Got the $iReturnPath working. Now how do I use the _ArrayDisplay to copy each of the rows in the 2nd Column, paste it in the another function in the same file that will compile the exe? If there are examples, i can work from that but just saying stuff doesn't make any sense to me. Sorry Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 26, 2019 Moderators Share Posted April 26, 2019 AasimPathan, You do not need to copy anything - the array is internal to the script and so you can loop through it directly. Here is some pseudo-code to show what I mean: Test() Func Test() ; Get the array of files to compile $aArray = _FileListToArrayRec("your parameters here") ; Now loop through them For $aArray[0] To UBound($aArray) - 1 ; ; Code to compile each element - use $aArray[$i] to get the specific file Next EndFunc M23 AasimPathan 1 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...
AasimPathan Posted April 26, 2019 Author Share Posted April 26, 2019 (edited) This is as far as i got, didn't work #include <AutoItConstants.au3> #include <Array.au3> #include <Crypt.au3> #include <File.au3> #include <FileConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <WinAPIFiles.au3> ;#RequireAdmin Opt("MustDeclareVars", 1) #Region "Fields" Global $M_V_Scalar_Object_DebuggingModeIsOn = 1 ;Global $M_V_Scalar_Object_Powershell = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" Global $M_V_Scalar_Object_AutoItCompilerPath = "C:\Program Files (x86)\AutoIt3\Aut2Exe" Global $M_V_Scalar_Object_CodeRootDirectory = "C:\U_C\" Global $M_V_Scalar_Object_AutoItCompiledRootDirectory = "A:\U_A\U_W\U_Dpts\U_IT\U_Soft" Global $M_V_Scalar_Object_CompileAu3ToExe = "C:\Program Files (x86)\AutoIt3\Aut2Exe\Aut2exe_x64.exe" #EndRegion #Region "Methods" M_S_Main() Func M_S_Main() Local $L_V_Scalar_Object_SearchRootDirectory = StringLeft($M_V_Scalar_Object_CodeRootDirectory, StringInStr($M_V_Scalar_Object_CodeRootDirectory, "\", Default, -1)) If StringRight($L_V_Scalar_Object_SearchRootDirectory, 5) = "beta\" Then $L_V_Scalar_Object_SearchRootDirectory = StringTrimRight($L_V_Scalar_Object_SearchRootDirectory, 5) EndIf Local $L_V_Scalar_Object_Array = _FileListToArrayRec($L_V_Scalar_Object_SearchRootDirectory, "*.au3", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) For $L_V_Scalar_Object_Array[0] To UBound($L_V_Scalar_Object_Array) -1 Run($M_V_Scalar_Object_CompileAu3ToExe & "/in" & $L_V_Scalar_Object_Array) Next EndFunc #EndRegion Edited April 26, 2019 by AasimPathan Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 26, 2019 Share Posted April 26, 2019 (edited) @AasimPathan $L_V_Scalar_Object_Array is an array (you'd never said that?), so you have to use square brackets with an index in order to access to the array elements. In your case, you are not using the array correctly, because you are using the first element of the array as index, and you never use it in the For. Maybe a little read about arrays before digging in your script? Edited April 26, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
AasimPathan Posted April 26, 2019 Author Share Posted April 26, 2019 14 minutes ago, FrancescoDiMuro said: @AasimPathan $L_V_Scalar_Object_Array is an array (you'd never said that?), so you have to use square brackets with an index in order to access to the array elements. In your case, you are not using the array correctly, because you are using the first element of the array as index, and you never use it in the For. Maybe a little read about arrays before digging in your script? Can you help me differentiate between the two? Test() Func Test() $aArray = _FileListToArrayRec("your parameters here") For $aArray[0] To UBound($aArray) - 1 Next EndFunc Test() Func Test() Local $L_V_Scalar_Object_Array = _FileListToArrayRec($L_V_Scalar_Object_SearchRootDirectory, "*.au3", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) For $L_V_Scalar_Object_Array[0] To UBound($L_V_Scalar_Object_Array) -1 ;Run($M_V_Scalar_Object_CompileAu3ToExe & "/in" & $L_V_Scalar_Object_Array) Next EndFunc Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 26, 2019 Share Posted April 26, 2019 (edited) @AasimPathan Both of the scripts use the number of files as index, which is returned in the first (0th) element of the array. You should use something like: ; $intIndex starts from 1 because the function _FileListToArray(Rec) returns the number of the files found in the first element of the array (element 0) For $intIndex = 1 To $arrArray[0] Step 1 ConsoleWrite("File " & $arrArray[$intIndex] & @CRLF) Next Index is the "cursor" of the array thanks to which you can loop through the array. You can find more about arrays in this topic Edited April 26, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
AasimPathan Posted May 1, 2019 Author Share Posted May 1, 2019 (edited) On 4/26/2019 at 8:06 PM, FrancescoDiMuro said: @AasimPathan Both of the scripts use the number of files as index, which is returned in the first (0th) element of the array. You should use something like: ; $intIndex starts from 1 because the function _FileListToArray(Rec) returns the number of the files found in the first element of the array (element 0) For $intIndex = 1 To $arrArray[0] Step 1 ConsoleWrite("File " & $arrArray[$intIndex] & @CRLF) Next Index is the "cursor" of the array thanks to which you can loop through the array. You can find more about arrays in this topic This just pastes everything into the Console, which i guess is the intended function but how do I copy or extract each field from that into another code. Update: Fixed it, Will add the final code soon. Edited May 1, 2019 by AasimPathan Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted May 1, 2019 Share Posted May 1, 2019 (edited) 3 hours ago, AasimPathan said: nto another code. Where, exactly? What do you have to do with those paths? Edited May 1, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
AasimPathan Posted May 2, 2019 Author Share Posted May 2, 2019 17 hours ago, FrancescoDiMuro said: Where, exactly? What do you have to do with those paths? Well the end game was to Compile all AU3 scripts to EXE's so the ConsoleWrite command needs to be output to Powershell or CMD. Below code is what I came up with, Thanks to all of you who responded.But its still not complete. I now want to copy the Compiled files to a folder path and i am unable to get that to work. expandcollapse popup;<Comment Type='LastReview' Contact='PathA00' Date='2019-05-01'\> ;This script will compile all AutoIt Sripts with extention .au3 in C:\U_C folder and copy them to A:\U_A\U_W\U_Dpts\U_IT\U_Soft ;#[8:HowRK00: Test with me this scrip is now complete] #include <AutoItConstants.au3> #include <Array.au3> #include <Crypt.au3> #include <File.au3> #include <FileConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <WinAPIFiles.au3> #RequireAdmin Opt("MustDeclareVars", 1) #Region "Bayonet - Fields" Global $M_V_Scalar_Object_DebuggingModeIsOn = 1 Global $M_V_Scalar_Object_Powershell = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" Global $M_V_Scalar_Object_CodeRootDirectory = "C:\U_C\" Global $M_V_Scalar_Object_AutoItCompiledRootDirectory = "A:\U_A\U_W\U_Dpts\U_IT\U_Soft\" Global $M_V_Scalar_Object_Array = "" Global $M_V_Scalar_Object_ArrayToInteger = "" Run($M_V_Scalar_Object_Powershell, "C:\Program Files (x86)\AutoIt3\Aut2Exe") #EndRegion #Region "Bayonet - Methods" M_S_Main() Func M_S_Main() Local $L_V_Scalar_Object_SearchRootDirectory = StringLeft($M_V_Scalar_Object_CodeRootDirectory, StringInStr($M_V_Scalar_Object_CodeRootDirectory, "\", Default, -1)) If StringRight($L_V_Scalar_Object_SearchRootDirectory, 5) = "beta\" Then $L_V_Scalar_Object_SearchRootDirectory = StringTrimRight($L_V_Scalar_Object_SearchRootDirectory, 5) EndIf $M_V_Scalar_Object_Array = _FileListToArrayRec($L_V_Scalar_Object_SearchRootDirectory, "*.au3", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) If $M_V_Scalar_Object_DebuggingModeIsOn Then _ArrayDisplay($M_V_Scalar_Object_Array, "AutoIt Scripts") For $M_V_Scalar_Object_ArrayToInteger = 1 To $M_V_Scalar_Object_Array[0] ClipPut($M_V_Scalar_Object_Array[$M_V_Scalar_Object_ArrayToInteger]& @CRLF) Sleep(1000) WinActivate("Administrator: Windows PowerShell") Sleep(100) Send("attrib -r ") Send("^v") Sleep(100) Send("{ENTER}") Sleep(100) Send("{ENTER}") Sleep(100) Send(".\Aut2exe_x64.exe /in ") Sleep(100) Send("^v") Sleep(100) Send("{ENTER}") Sleep(2000) Send("attrib +r ", $SEND_RAW) Send("^v") Sleep(100) Send("{ENTER}") Sleep(2000) Next WinClose("Administrator: Windows PowerShell") M_S_ReleaseCompiledScripts() EndFunc Func M_S_ReleaseCompiledScripts() Local $L_V_Scalar_Object_SearchRootDirectory = StringLeft($M_V_Scalar_Object_CodeRootDirectory, StringInStr($M_V_Scalar_Object_CodeRootDirectory, "\", Default, -1)) If StringRight($L_V_Scalar_Object_SearchRootDirectory, 5) = "beta\" Then $L_V_Scalar_Object_SearchRootDirectory = StringTrimRight($L_V_Scalar_Object_SearchRootDirectory, 5) EndIf $M_V_Scalar_Object_Array = _FileListToArrayRec($L_V_Scalar_Object_SearchRootDirectory, "U_A_*.exe", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) If $M_V_Scalar_Object_DebuggingModeIsOn Then _ArrayDisplay($M_V_Scalar_Object_Array, "Executable Files") For $M_V_Scalar_Object_ArrayToInteger = 1 To $M_V_Scalar_Object_Array[0] FileCopy($M_V_Scalar_Object_Array[$M_V_Scalar_Object_ArrayToInteger], $M_V_Scalar_Object_AutoItCompiledRootDirectory, $FC_OVERWRITE, $FC_CREATEPATH) ;this is not working for me, any ideas? Next EndFunc #EndRegion Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted May 2, 2019 Share Posted May 2, 2019 @AasimPathan Change this line of code FileCopy($M_V_Scalar_Object_Array[$M_V_Scalar_Object_ArrayToInteger], $M_V_Scalar_Object_AutoItCompiledRootDirectory, $FC_OVERWRITE, $FC_CREATEPATH) to FileCopy($M_V_Scalar_Object_Array[$M_V_Scalar_Object_ArrayToInteger], $M_V_Scalar_Object_AutoItCompiledRootDirectory, BitOr($FC_OVERWRITE, $FC_CREATEPATH)) AasimPathan 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette 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