Jump to content
Sign in to follow this  

Complicated file transfer, unzipping, and editing automation problem

Recommended Posts

So I am new to coding outside of VBA / SQL, and have been trying to figure out a way to automate the following:

1. Transfer all files from a folder (folder1), to another folder (folder 2), AND be able to specify two constraints for the names of the files to be transferred.

For Example: I want to be able to specify to transfer all files containing both "MDXv3" and "_2012" in their file name, and I am thinking of something close to the LIKE '%abcd'; function from SQL

2. After the specified files have been transferred from folder1 to folder2, I need to unzip all the files in folder2 using 7zip (extraction location is folder2)

3. After extracting the files, I want to have it automatically delete all files ending in ".dec" and then edit part of the name out of all the files ending in ".txt"

for example: I would want to be able to specify that "145_" is to be deleted from the file name of every ".txt" file

My goal here is to automate the transferring, unzipping and editing of extracted files. I need to have a macro for this because I am only looking for specific files in folder 1, say 350 files, but there are some 10k+ files, and the files I am looking for are not named in an easily organized fashion (this is done out of necessity, not choice so I am unable to change the original archiving file names of the files I am working with)

So far I have been trying to use a macro recorder to do this but the task is a bit too complicated for a simple recording ;)

Thank you for the help ahead of time, I really have been struggling with this

Share this post

Link to post
Share on other sites


Welcome to the AutoIt forum. ;)

What you want to do sounds long, but it is not particularly difficult: :)

- 1. Use _FileListToArray to list the files in folder1 and then loop through them using StringInStr to determine whether they meet you naming criteria - if they do then FileMove them to folder2.

- 2. There is a 7-Zip UDF somewhere on the forum which should help you with the next part - or you could use Run to extract the files using the 7-Zip exectuable directly.

- 3. Use _FileListToArray on the extracted files, looping through the returned array to action as required (FileDelete or FileMove to rename) depending on the filename.

As I said, a longish process, but not overly difficult. Take a look at the functions I have mentioned and see what you can come up with - you know where we are if you run into difficulties. :)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

Hi Hgreanias

Search for [sOLVED]-Search for part of a line in text file and replace with new line.

It should be what you are looking for.

If it is you can thank Melba23.


Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By WilliamasKumeliukas
      I started this project alone in May 2020 as project in my spare time at work, I'm working for a IT company that started opening their services to residential customers few months ago and now my position in the company kinda drifted in the doom and gloom world of repetitive tasks like: Reinstallation of Windows 10.
      The procedure is very repetitive and I started feeling like being a robot which is the main reason I started this project.
      1. Q: Do you want this project to be accomplished with the usage of AutoIT ONLY or 3rd party tools / Scripts (BATCH / POWERSHELL / VB) ? A: No, if I cannot find a way using AutoIT to accomplish a task I will move to my Plan B which consist of automating an 3rd party tool to accomplish the affected task until a solution is found. 2. Q: What do I get from helping/collaborating in this project? A: I will personally take the responsability to mention you in the credits of this project. 3. Q: If I have more questions, can I ask? A: Certainly! feel free to ask any questions related to this project! 4. Q: What is the main goal of this project? A: Automating Windows 10 configuration without user interaction needed (as much as possible) ______________________________________________________________________________________________________________________________
      Current progression of the project (more will be added in future)
      « Blue = Info || Yellow = Unfinished/Untested || Purple = Could be better || Green = Done ||Red = Not Yet Started »
      ***Very early Stage ***
      Connect Network Attached Storage(NAS) (Tested & Working - AutoIT only)
      Download & Install up to 567 softwares with Auto prediction of text typed  (Tested & Working - using 3rd party tool)
      Change OEM Information (Tested & Working - contains both AutoIT version and CMD script)
      Disable ScreenSaver (Require testing AutoIT only)
      Change Computer Name (Require testing AutoIT only) 
      Show Computer Information and Smart status on GUI (Work - AutoIT Only)
      Change .pdf / .pdfxml from Edge to Adobe Reader DC (Work - using 3rd party tool)
      Change Edge to Google Chrome as Default Browser (Tested & Working - using 3rd party tool)
      Windows Updates (Working - AutoIT only)
      Install Office 
      Verify and Update softwares installed (Can be added if wanted (up to 567 softwares) - 3rd party tool)
      Activate Office (Tested on 2010 & Working - CMD Script)
      Pin to taskbar Excel, Outlook, Word, Chrome (Tested & Working - using 3rd party tool)
      GUI currently featuring the following options :
      - Checkboxes for desired tasks
      Inputs for : SupportUrl, Manufacturer, Model, SupportPhone, SupportHour, OEM Logo path
      -  Redirect ConsoleWrite with timestamped messages in richedit (errors shown separately in red text)
                 *** To Do ***
       - Read informations needed for tasks like: OEM, ComputerName, NAS user/password etc... from a file
       - ListView for Windows Updates
       - Probably more
      ***  If this project interest you, Reply here This will greatly help me to see if you'd like this project to become real  ***
      2020.09.21 Update: Since this topic reached over 200+ views without a single interest shown by community, pm me if you're willing to be part of the project and i'll share with you the GitHub project link  
      Best Regards,
    • By abberration
      Software Installer
      version 1.1 - 11/6/2020
      This new version (first in 8 years) is a total rewrite of the original. I was not getting notifications on this thread and missed people's questions and requests. I have incorporated some recent requests and will go back further in the posts and consider more upgrades.
      The overall look remains the same, but this version brings many changes. The only script breaking change is your old INI file is not compatible with this version. Some new features:
      When you add software to the Software folder (you need to create this folder in the same directory as your script), you will get prompted to configure the software. If you say yes, it will bring up a form where you can type up a display name for the software (instead of the installer name. Ex: 7z1900-x64.msi can be displayed as 7-Zip), the switch to use, software description and what category tab you want it to appear in. This feature creates and updates an INI file for you, so you don't have to do it manually. While configuring your software, there is a drop-down menu with installer types (Inno, NSIS, MSI, Installshield, Wise, etc). If you know the installer type, it narrows down the switches in the Switch drop-down menu to only show switches for that installer type. If none of the switches are what you need (ex: Firefox uses -ms), just manually type the needed switch in the Switch drop-down menu. By default, only unconfigured software shows up in the Configure Software menu. There is a checkbox to show all software, where you can double-click the software and modify it's data. There is an option to edit the order in which the software is installed. If selected, a form will pop up after you press the Install Selected Software button and before the installation begins. On this form, you can select software installers and move them up and down in the list. I will watch this thread more closely and continue to work on this project. This was one of my first "big" projects and one of my favorites. I'm surprised I haven't revisited sooner.
      #include <Array.au3> #include <File.au3> #include <GDIPlus.au3> #include <GUIConstants.au3> #include <GuiTab.au3> #include <GuiListView.au3> #include <GuiMenu.au3> #include <ProgressConstants.au3> Global $fIniConfig = @ScriptDir & "\Config.ini" Global $sSWDir = @ScriptDir & "\Software\" Global $sVersion = "1.1" ; Main GUI $Form1 = GUICreate("Software Installer", 633, 451) $Tab1 = GUICtrlCreateTab(16, 8, 601, 377) $TabSheet1 = GUICtrlCreateTabItem("Audio/Video/Photo") $ListView1 = GUICtrlCreateListView("Software Name|Description", 24, 40, 582, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet2 = GUICtrlCreateTabItem("System Tools") $ListView2 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView2, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet3 = GUICtrlCreateTabItem("Internet") $ListView3 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView3, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet4 = GUICtrlCreateTabItem("Games") $ListView4 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView4, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet5 = GUICtrlCreateTabItem("Miscellaneous") $ListView5 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView5, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet6 = GUICtrlCreateTabItem("Patches/Updates") $ListView6 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView6, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet7 = GUICtrlCreateTabItem("Productivity") $ListView7 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView7, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) GUICtrlCreateTabItem("") ; This ends the tab item creation $g1Checkbox1 = GUICtrlCreateCheckbox("Prompt to edit software installation order", 16, 400, 220, 17) ;~ GUICtrlSetState(-1, $GUI_CHECKED) ; Enable this if you want. $g1Button1 = GUICtrlCreateButton("Install Selected Software", 398, 395, 219, 25, 0) $MenuItem1 = GUICtrlCreateMenu("File") $MenuItem1a = GUICtrlCreateMenuItem("Select All", $MenuItem1) $MenuItem2 = GUICtrlCreateMenuItem("Unselect All", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1) $MenuItem4 = GUICtrlCreateMenu("Settings") $MenuItem5 = GUICtrlCreateMenuItem("Edit Software Configuration", $MenuItem4) $MenuItem6 = GUICtrlCreateMenu("Help") $MenuItem7 = GUICtrlCreateMenuItem("Help Topics", $MenuItem6) $MenuItem8 = GUICtrlCreateMenuItem("About", $MenuItem6) GUISetState(@SW_SHOW) $aSoftwareList = _FileListToArrayRec(@ScriptDir & "\Software", "*.exe;*.msi", 1) ; List all software in Software folder. If NOT IsArray ($aSoftwareList) Then ; Easy fix for program crashing if no software is in the Software folder. MsgBox(262144, "Error", "No software installers found in the Software folder." & @CRLF & "This program cannot function without any software installers." & @CRLF & "Add some to the folder and restart the program.") Exit EndIf For $i = 1 To 5 ; Add columns for other data. _ArrayColInsert($aSoftwareList, 1) Next Global $aUnconfiguredSW[$aSoftwareList[0][0]+1][5] $aUnconfiguredSW[0][0] = 0 _CheckForNewSoftware($aSoftwareList) If $aUnconfiguredSW[0][0] > 0 Then ; Get a list of all software that has not been configured. $iQueryUser = _QueryUser() If $iQueryUser = 1 Then _SWConfiguration() EndIf EndIf _Populate() ; Loads the software in the Software folder into the various lists. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $g1Button1 _InstallSelectedSoftware() Case $MenuItem1a _SelectAll(True) Case $MenuItem2 _SelectAll(False) Case $MenuItem3 Exit Case $MenuItem5 _SWConfiguration() Case $MenuItem7 _HelpTopics() Case $MenuItem8 _About() EndSwitch WEnd Func _Populate() ; Find all files in the Software folder and populate the tabs with the installers. For $i = 1 To 7 ; Fill out the master array with data _GUICtrlListView_DeleteAllItems(Eval("ListView" & $i)) Next For $i = 1 To $aSoftwareList[0][0] $sDisplayName = IniRead($fIniConfig, $aSoftwareList[$i][0], "DisplayName", $aSoftwareList[$i][0]) $sCategory = IniRead($fIniConfig, $aSoftwareList[$i][0], "Category", "") If $sCategory = "" Then $sCategory = 5 EndIf $sDescription = IniRead($fIniConfig, $aSoftwareList[$i][0], "Description", "") $checked = IniRead($fIniConfig,$aSoftwareList[$i][0],"IsDefault", "") $aSoftwareList[$i][1] = $sDisplayName $aSoftwareList[$i][2] = $sCategory $aSoftwareList[$i][3] = $sDescription $aSoftwareList[$i][4] = $checked Next For $i = 1 To $aSoftwareList[0][0] ; Populate the tabs with items $iCategory = IniRead($fIniConfig, $aSoftwareList[$i][0], "Category", 5) GUICtrlCreateListViewItem($aSoftwareList[$i][1] & "|" & $aSoftwareList[$i][3], (Eval("ListView" & $iCategory))) If $aSoftwareList[$i][4] = 1 Then $iI = _GUICtrlListView_FindText((Eval("ListView" & $iCategory)), $aSoftwareList[$i][1]) _GUICtrlListView_SetItemChecked((Eval("ListView" & $iCategory)), $iI, True) ;Set checked radiobox of last found control EndIf Next EndFunc ;==>_Populate Func _InstallSelectedSoftware() GUISetState(@SW_DISABLE, $Form1) Local $sExit = "" $Form4 = GUICreate("Installing Software", 443, 172) $g4Label1 = GUICtrlCreateLabel("Installing:", 16, 16, 148, 17) $g4Label2 = GUICtrlCreateLabel("", 16, 40, 418, 19) GUICtrlSetFont(-1, 10, 400, 0, "Arial Rounded MT Bold") GUICtrlSetColor(-1, 0x008080) $g4Label3 = GUICtrlCreateLabel("File Size:", 16, 64, 146, 17) $g4Label4 = GUICtrlCreateLabel("Total Progress:", 16, 112, 75, 17) $g4Progress1 = GUICtrlCreateProgress(16, 136, 414, 17) Local $aInstallList[$aSoftwareList[0][0] + 1][4] $iInstallListSize = 0 For $i = 1 To 7 $iItemCount = _GUICtrlListView_GetItemCount(Eval("ListView" & $i)) For $j = 1 To $iItemCount $vItemChecked = _GUICtrlListView_GetItemChecked(Eval("ListView" & $i), $j - 1) If $vItemChecked = TRUE Then $iInstallListSize += 1 $aInstallList[0][0] = $iInstallListSize $sItemName = _GUICtrlListView_GetItemText(Eval("ListView" & $i), $j - 1) $iArrayPos = _ArraySearch($aSoftwareList, $sItemName, Default, Default, Default, Default, Default, 1) $sSWInstaller = $aSoftwareList[$iArrayPos][0] $sSwitch = IniRead($fIniConfig, $sSWInstaller, "Switch", "") $aInstallList[$iInstallListSize][0] = $sSWDir & $sSWInstaller $aInstallList[$iInstallListSize][1] = $sSwitch $aInstallList[$iInstallListSize][2] = $sItemName $aInstallList[$iInstallListSize][3] = $sSWInstaller EndIf Next Next ReDim $aInstallList[$aInstallList[0][0] + 1][4] $iInstallOrder = GUICtrlRead($g1Checkbox1) If $iInstallOrder = 1 Then ; If the user wants to alter installation order, this pulls up the Gui. $aInstallList = _InstallOrder($aInstallList) EndIf GUISetState(@SW_SHOW, $Form4) ; The Installing Software screen has been hidden until now. For $i = 1 To $aInstallList[0][0] ; Set info into Gui and install the software. If FileExists($aInstallList[$i][0]) Then GUICtrlSetData($g4Label1, "Installing: " & $i & " of " & $aInstallList[0][0]) GUICtrlSetData($g4Label2, $aInstallList[$i][2]) ; Name of software GUICtrlSetData($g4Label3, "File Size: " & Round(FileGetSize($aInstallList[$i][0])/1024000, 1) & " MB") If StringRight($aInstallList[$i][0], 4) = ".msi" Then $sInstallString = '"' & $aInstallList[$i][0] & '" ' & $aInstallList[$i][1] Run("msiexec /i " & $sInstallString) Else RunWait('"' & $aInstallList[$i][0] & '" ' & $aInstallList[$i][1]) EndIf EndIf GUICtrlSetData($g4Progress1, $i/$aInstallList[0][0]*100) Next $sExit = "EXIT" Do Sleep(500) Until $sExit = "EXIT" GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form4) _SelectAll(False) EndFunc Func _SelectAll($TF) ; Sending TRUE or FALSE to select all or unselect all. For $i = 1 To 7 $iItemCount = _GUICtrlListView_GetItemCount(Eval("ListView" & $i)) For $j = 1 To $iItemCount _GUICtrlListView_SetItemChecked(Eval("ListView" & $i), $j - 1, $TF) Next Next EndFunc ;==>_SelectAll Func _HelpTopics() $Form2 = GUICreate("Help", 633, 447) $Label1 = GUICtrlCreateLabel("", 8, 16, 612, 425) GUICtrlSetData(-1, "This program uses silent switches to install software without user interaction. " & _ "To use this functionality, you can edit the Config.ini file to add software and their switches. Example: " & _ @CRLF & @CRLF & "[7z1900-x64.exe] ; <--- This is the actual file name" & _ @CRLF & "Description=YourDescripton" & @CRLF & "Switch=YourSwitcth" & @CRLF & "Category=YourCategory" & @CRLF & "etc... etc..." & _ @CRLF & @CRLF & "Here are some common switches for various installers: (more included in this program's features)" & @CRLF & @CRLF & "/silent used for Inno Setup installers" & @CRLF & _ "/verysilent used for Inno Setup installers" & @CRLF & "/S used for Nullsoft (aka NSIS) installers" & @CRLF & "/s used for Wise installers" & _ @CRLF & "-s used for Ghost installers" & @CRLF & "-ms used for Mozilla installers" & @CRLF & "/quiet used for Microsoft installers" & @CRLF & _ "/qb used for Microsoft installers" & @CRLF & "/qn used for Microsoft installers" & @CRLF & "/passive used for Microsoft installers" & @CRLF & _ "/Q used for Microsoft installers") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form2) ExitLoop EndSwitch WEnd EndFunc ;==>_HelpTopics Func _CheckForNewSoftware($aSoftwareList) Local $aConfigFileSW = IniReadSectionNames($fIniConfig) $iArrayPos = 1 For $i = 1 To $aSoftwareList[0][0] If _ArraySearch($aConfigFileSW, $aSoftwareList[$i][0]) < 1 Then $aUnconfiguredSW[$iArrayPos][0] = $aSoftwareList[$i][0] $aUnconfiguredSW[0][0] = $iArrayPos $iArrayPos += 1 EndIf Next EndFunc Func _SWConfiguration() GUISetState(@SW_DISABLE, $Form1) $Form2 = GUICreate("Configure Software", 620, 470) Global $g2List = GUICtrlCreateList("", 8, 24, 602, 218) $g2Checkbox1 = GUICtrlCreateCheckbox("Show All Software", 8, 240, 121, 17) $g2Label1 = GUICtrlCreateLabel("Display Name For Software:", 8, 264, 250, 17) $g2Input1 = GUICtrlCreateInput("", 8, 280, 250, 21) GUICtrlSetState(-1, $GUI_DISABLE) $g2Label2 = GUICtrlCreateLabel("Installer Type (optional):", 8, 320, 116, 17) $g2Combo1 = GUICtrlCreateCombo("", 8, 336, 250, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $g2Label3 = GUICtrlCreateLabel("Silent Switch To Be Used:", 8, 376, 128, 17) $g2Combo2 = GUICtrlCreateCombo("", 8, 392, 250, 25) GUICtrlSetState(-1, $GUI_DISABLE) $g2Label4 = GUICtrlCreateLabel("Software Description (optional):", 300, 264, 250, 17) $g2Input2 = GUICtrlCreateInput("", 300, 280, 250, 21) GUICtrlSetState(-1, $GUI_DISABLE) $g2Label5 = GUICtrlCreateLabel("Category:", 300, 320, 128, 17) $g2Combo3 = GUICtrlCreateCombo("", 300, 336, 250, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $g2Label6 = GUICtrlCreateLabel("Double-Click Each Software To Configure. When Finished, Click The Save Button", 8, 6, 391, 17) $g2Label7 = GUICtrlCreateLabel("Editing: ", 8, 240, 602, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) GUICtrlSetBkColor(-1, 0xC0DCC0) GUICtrlSetState(-1, $GUI_HIDE) $g2Checkbox2 = GUICtrlCreateCheckbox("This Software Defaults To Selected (Check Mark On)", 300, 392, 300, 17) GUICtrlSetState(-1, $GUI_DISABLE) $g2Button1 = GUICtrlCreateButton("Edit A Different Software", 300, 430, 160, 25, $WS_GROUP) GUICtrlSetState(-1, $GUI_DISABLE) $g2Button2 = GUICtrlCreateButton("Save Data", 480, 430, 100, 25, $WS_GROUP) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aUnconfiguredSW) Global $idDummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form2) _Populate() ExitLoop Case $idDummy _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aSoftwareList) GUICtrlSetData($g2Label7, "Editing: " & GUICtrlRead($idDummy)) $sDesc = IniRead($fIniConfig, GUICtrlRead($idDummy), "Description", "") $sFullSwitches = "-s|/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart|/S|/S /NCRC|/passive|/passive /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n|/S|/s" $sSwitch = IniRead($fIniConfig, GUICtrlRead($idDummy), "Switch", $sFullSwitches) Local $aCategories[8] = ["7","Audio/Video/Photo", "System Tools", "Internet", "Games", "Miscellaneous", "Patches/Updates", "Productivity"] $iCategory = IniRead($fIniConfig, GUICtrlRead($idDummy), "Category", "5") $sCategory = $aCategories[$iCategory] $sDisplayName = IniRead($fIniConfig, GUICtrlRead($idDummy), "DisplayName", "") $sIsDefault = IniRead($fIniConfig, GUICtrlRead($idDummy), "IsDefault", "") GUICtrlSetData($g2Input1, $sDisplayName) GUICtrlSetData($g2Combo2, $sSwitch) GUICtrlSetData($g2Input2, $sDesc) GUICtrlSetData($g2Combo3, $sCategory) If $sIsDefault = 1 Then GUICtrlSetState($g2Checkbox2, $GUI_CHECKED) EndIf _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Checkbox1, $g2Checkbox2, $g2Label7, $g2List, 1) ; enable Case $g2Button1 GUICtrlSetState($g2Checkbox1, $GUI_UNCHECKED) _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aUnconfiguredSW) _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Checkbox1, $g2Checkbox2, $g2Label7, $g2List, 0) Case $g2Combo1 _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3) Case $g2Checkbox1 $iCBRead = GUICtrlRead($g2Checkbox1) If $iCBRead = 1 Then _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aSoftwareList) Else _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aUnconfiguredSW) EndIf Case $g2Button2 $sCurrentSW = StringTrimLeft(GUICtrlRead($g2Label7), 9) $sDesc = IniWrite($fIniConfig, $sCurrentSW, "Description", GUICtrlRead($g2Input2)) $sSwitch = IniWrite($fIniConfig, $sCurrentSW, "Switch", GUICtrlRead($g2Combo2)) Local $aCategories[8] = ["7","Audio/Video/Photo", "System Tools", "Internet", "Games", "Miscellaneous", "Patches/Updates", "Productivity"] $sCategory = GUICtrlRead($g2Combo3) $iArrayPos = _ArraySearch($aCategories, $sCategory) IniWrite($fIniConfig, $sCurrentSW, "Category", $iArrayPos) $sDisplayName = IniWrite($fIniConfig, $sCurrentSW, "DisplayName", GUICtrlRead($g2Input1)) $sIsDefault = IniWrite($fIniConfig, $sCurrentSW, "IsDefault", GUICtrlRead($g2Checkbox2)) $iArrayPos = _ArraySearch($aUnconfiguredSW, $sCurrentSW) If $iArrayPos > 0 Then _ArrayDelete($aUnconfiguredSW, $iArrayPos) $aUnconfiguredSW[0][0] -= 1 EndIf _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aUnconfiguredSW) GUICtrlSetState($g2Checkbox1, $GUI_UNCHECKED) _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Checkbox1, $g2Checkbox2, $g2Label7, $g2List, 0) EndSwitch WEnd EndFunc Func _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3) $sInstaller = GUICtrlRead($g2Combo1) GUICtrlSetData($g2Combo2, "") If $sInstaller = "Ghost Installer" Then GUICtrlSetData($g2Combo2, "-s", "-s") ElseIf $sInstaller = "Inno Setup" Then GUICtrlSetData($g2Combo2, "/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart", "/silent") ElseIf $sInstaller = "Install Shield" Then GUICtrlSetData($g2Combo2, "/S|/S /NCRC", "/S") ElseIf $sInstaller = "Microsoft Hotfix Package" Then GUICtrlSetData($g2Combo2, "/passive|/passive /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n", "/passive /norestart") GUICtrlSetData($g2Combo3, "Patches/Updates") ElseIf $sInstaller = "MSI Package" Then GUICtrlSetData($g2Combo2, "/qb|/qn", "/qb") ElseIf $sInstaller = "Nullsoft (NSIS)" Then GUICtrlSetData($g2Combo2, "/S", "/S") ElseIf $sInstaller = "Wise Installer" Then GUICtrlSetData($g2Combo2, "/s", "/s") Else GUICtrlSetData($g2Combo2, "-s|/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart|/S|/S /NCRC|/passive|/passive /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n|/S|/s") EndIf EndFunc Func _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Checkbox1, $g2Checkbox2, $g2Label7, $g2List, $01) GUICtrlSetState($g2Input1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Combo1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Combo2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Combo3, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Input2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Checkbox1, ($01 = 1) ? $GUI_HIDE : $GUI_SHOW) GUICtrlSetState($g2Checkbox2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Button1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Button2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Label7, ($01 = 1) ? $GUI_SHOW : $GUI_HIDE) GUICtrlSetState($g2List, ($01 = 1) ? $GUI_DISABLE : $GUI_ENABLE) EndFunc Func _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aSW, $iSWList = 0) GUICtrlSetData($g2List, "") GUICtrlSetData($g2Input1, "") GUICtrlSetData($g2Input2, "") GUICtrlSetData($g2Combo1, "") GUICtrlSetData($g2Combo2, "") GUICtrlSetData($g2Combo3, "") GUICtrlSetData($g2Combo1, "Ghost Installer|Inno Setup|Install Shield|Microsoft Hotfix Package|MSI Package|Nullsoft (NSIS)|Wise Installer") _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3) GUICtrlSetData($g2Combo3, "Audio/Video/Photo|System Tools|Internet|Games|Miscellaneous|Patches/Updates|Productivity", "Miscellaneous") GUICtrlSetState ($g2Checkbox2, $GUI_UNCHECKED) GUICtrlSetData($g2List, "") $iIsChecked = GUICtrlRead($g2Checkbox1) If IsArray($aSW) Then For $i = 1 To $aSW[0][0] GUICtrlSetData($g2List, $aSW[$i][0]) Next EndIf EndFunc Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit $hWndFrom = $lParam $iIDFrom = _WinAPI_LoWord($wParam) $iCode = _WinAPI_HiWord($wParam) If $iCode = $LBN_DBLCLK AND $iIDFrom = $g2List Then $sClicked = GUICtrlRead($g2List) GUICtrlSendToDummy($idDummy, $sClicked) EndIf EndFunc Func _InstallOrder($aInstallList) GUISetState(@SW_DISABLE, $Form1) $Form5 = GUICreate("Installation Order", 423, 292) $g5Label1 = GUICtrlCreateLabel("Highlight software and click the up and down arrows to change order of installation", 16, 3, 393, 17) $g5List1 = GUICtrlCreateList("", 16, 24, 321, 253, $LBS_NOTIFY) $g5Button1 = GUICtrlCreateButton(ChrW(8593), 344, 112, 35, 25, $WS_GROUP) $g5Button2 = GUICtrlCreateButton(ChrW(8595), 344, 144, 35, 25, $WS_GROUP) $g5Button3 = GUICtrlCreateButton("Done", 351, 251, 59, 25, $WS_GROUP) GUISetState(@SW_SHOW) For $i = 1 To $aInstallList[0][0] GUICtrlSetData($g5List1, $aInstallList[$i][3]) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form5) Return $aInstallList ExitLoop Case $g5Button1 $sRead = GUICtrlRead($g5List1) If $sRead <> "" Then $iArrayPos = _ArraySearch($aInstallList, $sRead, Default, Default, Default,Default,Default, 3) If $iArrayPos > 1 Then _ArraySwap($aInstallList, $iArrayPos, $iArrayPos - 1) EndIf GUICtrlSetData($g5List1, "") For $i = 1 To $aInstallList[0][0] GUICtrlSetData($g5List1, $aInstallList[$i][3]) Next EndIf Case $g5Button2 $sRead = GUICtrlRead($g5List1) If $sRead <> "" Then $iArrayPos = _ArraySearch($aInstallList, $sRead, Default, Default, Default,Default,Default, 3) If $iArrayPos < $aInstallList[0][0] Then _ArraySwap($aInstallList, $iArrayPos, $iArrayPos + 1) EndIf GUICtrlSetData($g5List1, "") For $i = 1 To $aInstallList[0][0] GUICtrlSetData($g5List1, $aInstallList[$i][3]) Next EndIf Case $g5Button3 GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form5) Return $aInstallList ExitLoop EndSwitch WEnd EndFunc Func _QueryUser() $iShowConfigSWDiag = IniRead($fIniConfig, "Settings", "ShowConfigSWDiag", 4) If $iShowConfigSWDiag = 4 Then GUISetState(@SW_DISABLE, $Form1) $iStyle2 = BitOr( $WS_CAPTION, $WS_POPUP, $WS_SYSMENU) $Form6 = GUICreate("Attention", 423, 119, Default, Default, $iStyle2) $g6Label1 = GUICtrlCreateLabel("You have unconfigured software. Do you want to configure them now?", 32, 32, 338, 17) $g6Button1 = GUICtrlCreateButton("Yes", 184, 72, 99, 25, $WS_GROUP) $g6Button2 = GUICtrlCreateButton("No", 296, 72, 99, 25, $WS_GROUP) $g6Checkbox1 = GUICtrlCreateCheckbox("Do not ask again", 32, 80, 121, 17) GUISetState() $g6ExitButton = _GUICtrlMenu_GetSystemMenu($Form6) _GUICtrlMenu_EnableMenuItem($g6ExitButton, $SC_CLOSE, 1, False) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $g6Button1 $iCBRead = GUICtrlRead($g6Checkbox1) If $iCBRead = 1 Then IniWrite($fIniConfig, "Settings", "ShowConfigSWDiag", $iCBRead) EndIf GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form6) Return 1 ExitLoop Case $g6Button2 $iCBRead = GUICtrlRead($g6Checkbox1) If $iCBRead = 1 Then IniWrite($fIniConfig, "Settings", "ShowConfigSWDiag", $iCBRead) EndIf GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form6) Return 0 ExitLoop EndSwitch WEnd EndIf EndFunc Func _About() GUISetState(@SW_DISABLE, $Form1) Local $Form3, $hGraphic Local Const $iWidth = 400, $iHeight = 150, $iBgColor = 0x303030 $Form3 = GUICreate("About Software Installer", 400, 300) GUISetBkColor($iBgColor, $Form3) GUISetState(@SW_SHOW) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form3) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFEE88BB) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form3) _GDIPlus_GraphicsFillRect($hGraphic, 0, 150, 400, 300, $hBrush) $Label1 = GUICtrlCreateLabel("Software Installer", 48, 16, 304, 44) GUICtrlSetFont(-1, 26, 400, 0, "Arial Rounded MT Bold") GUICtrlSetColor(-1, 0xC0C0C0) $Label2 = GUICtrlCreateLabel("Version " & $sVersion, 48, 56, 84, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetColor(-1, 0xC0C0C0) $Label3 = GUICtrlCreateLabel("Click here to go to the home page for this software", 48, 240, 300, 21) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000080) GUICtrlSetBkColor(-1, 0x434E54) GUICtrlSetCursor (-1, 0) $Label4 = GUICtrlCreateLabel("Scripted with AutoIt", 48, 200, 115, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x808080) $Label5 = GUICtrlCreateLabel("This software is designed to help automate unattended and/or silent software installation.", 56, 96, 282, 40) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FFFF) While 1 $nmsg = GUIGetMsg() Switch $nMsg Case $Label3 ShellExecute ("https://www.autoitscript.com/forum/topic/143730-software-installer/") Case $GUI_EVENT_CLOSE _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form3) ExitLoop EndSwitch WEnd EndFunc Archive of version 1.0:
    • By WindIt
      I have a set of excel docs 1& 2
      1) In Excel 1 i have a fixed column called dimensionId that contains list of dimensionid's with in between empty cells.
      Here, For each dimesionId, i need to check corresponding columns of L,M,N ,O(senior, mid, junior, student) & check If they contain letter Y (Open excel 2) and if empty ignore,check next.
      I need to loop through the entire column of dimensionId one by one, please help me proceed with the logic.
      2) If letter Y exists, open excel 2 and check if same dimesionId exists in column A.
      New to autoit excel automation, Help me with logic to execute this.
      #include <Excel.au3>
      Global $oExcel = _Excel_Open()
      Global $oWorkbook = _Excel_BookOpen($oExcel, "D:\yta\Trial concept dimensions list.xlsx")
      Local $read1 = _Excel_RangeRead ($oWorkbook,Default,"C3")
      Attached exce 1 doc.
      exl1.xlsx exl2.xlsx
    • By Earthshine
      This is pretty useful to me at least, I hope to others. Whenever you need to poke a button or such on a GUI, you can just make calls to this UDF and instruct it how long to wait, 0 is forever, anyway, let the code to the explaining. Feel free to help expand this UDF. I plan to create new ones as I go along that support all the Win32 and .NET Controls. Ultimately, I would like to be able to fully control any type of control, this works well with most. Just an example of what you can do.
      NOTE: Logger Author(s) .....: Michael Mims (zorphnog)
      ;                    the logging script can be obtained here
      ;                   https://www.autoitscript.com/forum/topic/156196-log4a-a-logging-udf/
      WaitForControls.au3 log4a.au3
  • Create New...