
engjcowi
Active Members-
Posts
237 -
Joined
-
Last visited
Everything posted by engjcowi
-
USSU Unlimited 2.0.5.6 (Software Update Tool)
engjcowi replied to flappert87's topic in AutoIt Example Scripts
Hi flappert87 I like the prog. I wrote something which has the same purpose. There was a udf written by a member called storme. It downloads the latest stable (or beta whichever you set it too) selected program from file hippos site. The reason im menioning this is 2 fold. 1 even though the filename may change the udf still gets the most current and up to date version plus it has a flag to get just the version number so then you can compare to what you have found on the system. File hippo doesnt have every program you got listed in your app but it has the majority of common/popular ones at least. This should reuce the time you spend manually updating. Your app reminds me of a diff app called patch my pc. If you need any help let me know. Ill try to find the udfs link and post it Hope this helps -
Very nice indeed.
-
AutoIt Watermark Image v0.89 beta build 2014-08-25
engjcowi replied to UEZ's topic in AutoIt Example Scripts
Looks great- 76 replies
-
DVI-Remote (Remote Desktop entirely in AutoIt) - OpenSource!
engjcowi replied to JScript's topic in AutoIt Example Scripts
Hi jscript great program, amazing in fact. I think a good feature to add to this program would be the ability to have the program automatically log back onto the user and start up the connection again if the computer needed to be reset for any reason such as installing updates. -
Looks good Cant wait to try
-
Would anyone be willing to post some examples of what they have done with this? Im interested in creating a report and ive had a brief look at the current examples but was hoping more people woul dbe willing to showcase what they have done and how pls I have tried to create a simple table to show the software installed on my comp and so far not getting very far. I have 196 rows and its showing up very compressed as it doesnt spread over more than 1 page. If anyone has any examples with tables i would also be very grateful. Below is what i started playing with. I think i need ALOT more practice lol #include "..MPDF_UDF.au3" #include<array.au3> ;set the properties for the pdf _SetTitle("Report") _SetSubject("Report ") _SetKeywords("PDF Report") _OpenAfter(True);open after generation _SetUnit($PDF_UNIT_CM) _SetPaperSize("A4") _SetZoomMode($PDF_ZOOM_CUSTOM,90) _SetOrientation($PDF_ORIENTATION_PORTRAIT) _SetLayoutMode($PDF_LAYOUT_CONTINOUS) ;initialize the pdf _InitPDF(@ScriptDir & "Report.pdf") _LoadResImage("logo", @ScriptDir & "Imageslogo.jpg") _LoadFontTT("_Arial", $PDF_FONT_ARIAL) _LoadFontTT("_TimesT", $PDF_FONT_TIMES) _LoadFontTT("_Calibri", $PDF_FONT_CALIBRI) _LoadFontTT("_Garamond", $PDF_FONT_GARAMOND) ;start a page _BeginPage() ;put some graphics, text etc (see the rest) _InsertImage("logo", 2, 10, 7, 7) _SetColourFill(0xFF0000) _DrawText(3, 21, "Demo PDF Arial TT", "_Arial", 12, $PDF_ALIGN_LEFT, 0) _SetColourFill(0xFFFF00) _SetWordSpacing(50) _DrawText(3, 20, "Demo PDF Times TT", "_Times", 18, $PDF_ALIGN_LEFT, 0) _SetWordSpacing(0) _Insert3DPie(4, 18, 2.5, 200, 270, 0x996600) _SetTextRenderingMode(5) _InsertRenderedText(9, 23.5, "DEMO pdf", "_Times", 32, 100, $PDF_ALIGN_CENTER, 0xF00000, 0x202020) _SetTextRenderingMode(0) _EndPage() _BeginPage() _InsertTable(0, 0,0,15,5,15) $sTit = "Sample pdf table generated with AutoIt" _SetTextRenderingMode(5) _InsertRenderedText((_GetPageWidth()/_GetUnit())/2, _GetPageHeight()/_GetUnit()-1.5, $sTit, "_CalibriB", 32, 100, $PDF_ALIGN_CENTER, 0xbbbbbb, 0x202020) _SetTextRenderingMode(0) _EndPage() ;write the buffer to disk _ClosePDFFile() Func _InsertTable($iX, $iY, $iW=0, $iH=0, $iCols=0, $iRows=0,$lTxtColor = 0x000000, $lBorderColor = 0xdddddd) Dim $repserv _ComputerGetServices($repserv) _ArrayDisplay($repserv) Sleep(100) _ArraySort($repserv, 0, 1) Sleep(100) $iRows = 10;$repserv[0][0] Local $iPgW = Round(_GetPageWidth()/_GetUnit(),1) Local $iPgH = Round(_GetPageHeight()/_GetUnit(),1) If $iW = 0 Then $iW = $iPgW - $iX -2 If $iH = 0 Then $iH = $iPgH - $iY -2 _SetColourStroke($lBorderColor) _Draw_Rectangle($iX, $iY, $iW, $iH, $PDF_STYLE_STROKED, 0, 0xfefefe, 0.01) _SetColourStroke(0) Local $iColW = $iW/$iCols Local $iRowH = $iH/$iRows Local $lRGB For $i = 0 To $iRows-1 For $j = 0 To $iCols-1 If $i=0 Then $lRGB = 0xefefef Else $lRGB = 0xfefefe EndIf _SetColourStroke($lBorderColor) _Draw_Rectangle($iX+$j*$iColW, $iY+$iH-($i+1)*$iRowH, $iColW, $iRowH, $PDF_STYLE_STROKED, 0, $lRGB, 0.01) _SetColourStroke(0) if $i=0 Then Local $sText = $repserv[$i][0]&": Col "&$j Else Local $sText = "Row "&$i&": Col "&$j EndIf Local $sLength = Round(_GetTextLength($sText, "_Calibri", 10),1) $lScale = Ceiling(0.75*$iColW * 100/ $sLength) _SetColourFill($lTxtColor) _SetTextHorizontalScaling($lScale) _DrawText($iX+$j*$iColW+$iColW/10, $iY+$iH-($i+1)*$iRowH + ($iRowH-10/_GetUnit())/2, $sText, "_Calibri", 10, $PDF_ALIGN_LEFT, 0) _SetTextHorizontalScaling(100) _SetColourFill(0) Next Next EndFunc ;=============================================================================== ; Description: Returns the services information in an array. ; Parameter(s): $aServicesInfo - By Reference - Services Information array. ; $sState - OPTIONAL - Accepted values 'All' or 'Stopped' or ; 'Running' ; Requirement(s): None ; Return Value(s): On Success - Returns array of Services Information. ; $aServicesInfo[0][0] = Number of Services ; $aServicesInfo[$i][0] = Name ($i starts at 1) ; $aServicesInfo[$i][1] = Accept Pause ; $aServicesInfo[$i][2] = Accept Stop ; $aServicesInfo[$i][3] = Check Point ; $aServicesInfo[$i][4] = Description ; $aServicesInfo[$i][5] = Creation Class Name ; $aServicesInfo[$i][6] = Desktop Interact ; $aServicesInfo[$i][7] = Display Name ; $aServicesInfo[$i][8] = Error Control ; $aServicesInfo[$i][9] = Exit Code ; $aServicesInfo[$i][10] = Path Name ; $aServicesInfo[$i][11] = Process ID ; $aServicesInfo[$i][12] = Service Specific Exit Code ; $aServicesInfo[$i][13] = Service Type ; $aServicesInfo[$i][14] = Started ; $aServicesInfo[$i][15] = Start Mode ; $aServicesInfo[$i][16] = Start Name ; $aServicesInfo[$i][17] = State ; $aServicesInfo[$i][18] = Status ; $aServicesInfo[$i][19] = System Creation Class Name ; $aServicesInfo[$i][20] = System Name ; $aServicesInfo[$i][21] = Tag ID ; $aServicesInfo[$i][22] = Wait Hint ; ; On Failure - @error = 1 and Returns 0 ; @extended = 1 - Array contains no information ; 2 - $colItems isnt an object ; Author(s): Jarvis Stubblefield (support "at" vortexrevolutions "dot" com) ; Note(s): ;=============================================================================== Func _ComputerGetServices(ByRef $aServicesInfo, $sState = "All") Local $cI_Compname = @ComputerName, $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20 Local $colItems, $objWMIService, $objItem Dim $aServicesInfo[1][23], $i = 1 $objWMIService = ObjGet("winmgmts:" & $cI_Compname & "rootCIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Service", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $sState <> "All" Then If $sState = "Stopped" AND $objItem.State <> "Stopped" Then ContinueLoop If $sState = "Running" AND $objItem.State <> "Running" Then ContinueLoop EndIf ReDim $aServicesInfo[UBound($aServicesInfo) + 1][23] $aServicesInfo[$i][0] = $objItem.Name $aServicesInfo[$i][1] = $objItem.AcceptPause $aServicesInfo[$i][2] = $objItem.AcceptStop $aServicesInfo[$i][3] = $objItem.CheckPoint $aServicesInfo[$i][4] = $objItem.Description $aServicesInfo[$i][5] = $objItem.CreationClassName $aServicesInfo[$i][6] = $objItem.DesktopInteract $aServicesInfo[$i][7] = $objItem.DisplayName $aServicesInfo[$i][8] = $objItem.ErrorControl $aServicesInfo[$i][9] = $objItem.ExitCode $aServicesInfo[$i][10] = $objItem.PathName $aServicesInfo[$i][11] = $objItem.ProcessId $aServicesInfo[$i][12] = $objItem.ServiceSpecificExitCode $aServicesInfo[$i][13] = $objItem.ServiceType $aServicesInfo[$i][14] = $objItem.Started $aServicesInfo[$i][15] = $objItem.StartMode $aServicesInfo[$i][16] = $objItem.StartName $aServicesInfo[$i][17] = $objItem.State $aServicesInfo[$i][18] = $objItem.Status $aServicesInfo[$i][19] = $objItem.SystemCreationClassName $aServicesInfo[$i][20] = $objItem.SystemName $aServicesInfo[$i][21] = $objItem.TagId $aServicesInfo[$i][22] = $objItem.WaitHint $i += 1 Next $aServicesInfo[0][0] = UBound($aServicesInfo) - 1 If $aServicesInfo[0][0] < 1 Then SetError(1, 1, 0) EndIf Else SetError(1, 2, 0) EndIf EndFunc ;_ComputerGetServices
-
TinyAu3FilesSearch v 1.0.0.8 Update of 25 june 2013
engjcowi replied to wakillon's topic in AutoIt Example Scripts
Wow awesome ive been looking for something like this thanks -
Hi Chimera Heres the service change script i was working on. Credit goes to a few others too. Spud2k, ripdad, nerdfencer. If you see your code pls let me know and ill credit where appropriate. #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <CompInfo.au3> #include <excel.au3> #include <Array.au3> Dim $Software, $host = @ComputerName Global $colNeeded #region vars for startups Global $OSA = @OSArch, $OSV = @OSVersion, $OSA64 = 0, $Vista_7 = 0 Global $HKCR, $HKLM, $HKCU, $HKU, $nWMI = 0, $nTLvID = 0, $switch = 0, $state = 0 Switch $OSA Case 'X86' $HKCR = 'HKEY_CLASSES_ROOT' $HKCU = 'HKEY_CURRENT_USER' $HKLM = 'HKEY_LOCAL_MACHINE' $HKU = 'HKEY_USERS' Case 'X64' $HKCR = 'HKEY_CLASSES_ROOT64' $HKCU = 'HKEY_CURRENT_USER64' $HKLM = 'HKEY_LOCAL_MACHINE64' $HKU = 'HKEY_USERS64' $OSA64 = 1 Case Else EndSwitch Global $aENV[11][2] $aENV[0][0] = 10 $aENV[1][0] = '%ProgramFiles(x86)%' $aENV[1][1] = RegRead($HKLM & '\Software\Microsoft\Windows\CurrentVersion', 'ProgramFilesDir (x86)') $aENV[2][0] = '%ProgramFiles (x86)%' $aENV[2][1] = $aENV[1][1] $aENV[3][0] = '%ProgramFiles%' $aENV[3][1] = RegRead($HKLM & '\Software\Microsoft\Windows\CurrentVersion', 'ProgramFilesDir') $aENV[4][0] = '%ProgramFilesDir%' $aENV[4][1] = $aENV[3][1] $aENV[5][0] = '%HomeDrive%' $aENV[5][1] = @HomeDrive $aENV[6][0] = '%SystemDrive%' $aENV[6][1] = $aENV[5][1] $aENV[7][0] = '%SystemRoot%' $aENV[7][1] = @WindowsDir $aENV[8][0] = '%WinDir%' $aENV[8][1] = $aENV[7][1] $aENV[9][0] = '%SystemDir%' $aENV[9][1] = @SystemDir $aENV[10][0] = '%SystemDirectory%' $aENV[10][1] = $aENV[9][1] #endregion #region ### GUI $Form_AllSoft = GUICreate("All software, services, startups and updates ", 887, 575, 192, 124) $GroupAllSoft = GUICtrlCreateGroup("", 250, 8, 617, 49) $Radio_Services = GUICtrlCreateRadio("Services", 266, 25, 67, 20) GUICtrlSetState(-1, $GUI_CHECKED) $Radio_OnlySoft = GUICtrlCreateRadio("Software", 354, 25, 108, 20) $Radio_OnlyUpd = GUICtrlCreateRadio("Needed Win Updates", 469, 25, 131, 20) $Radio_Onlystartup = GUICtrlCreateRadio("Start Ups", 712, 25, 73, 17) $Radio_OnlyUpdhist = GUICtrlCreateRadio("Updates History", 600, 25, 105, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $ListView_Soft_Serv = GUICtrlCreateListView("The name of the Service|Current State|Start Mode|Status|Description", 25, 67, 841, 425,$LVS_SHOWSELALWAYS) GUICtrlSetTip(-1, "Hold down CTRL to multiple select. ONLY works on Updates") Local $ssMenu = GUICtrlCreateContextMenu($ListView_Soft_Serv) Local $ssMenuSERVICES = GUICtrlCreateMenu('Services Options', $ssMenu) Local $ssMenuCopI = GUICtrlCreateMenuItem('Stop Service', $ssMenuSERVICES) Local $ssMenuCopI2 = GUICtrlCreateMenuItem('Start Service', $ssMenuSERVICES) Local $ssMenuCopI5 = GUICtrlCreateMenu('Set Service Start Mode', $ssMenuSERVICES) Local $ssMenu2CopI5 = GUICtrlCreateMenuItem('Automatic', $ssMenuCopI5) Local $ssMenu3CopI5 = GUICtrlCreateMenuItem('Manual', $ssMenuCopI5) Local $ssMenu4CopI5 = GUICtrlCreateMenuItem('Disabled', $ssMenuCopI5) Local $ssMenuCopI3 = GUICtrlCreateMenuItem('', $ssMenu) ;Local $ssMenuUNINSTALL = GUICtrlCreateMenu('Uninstall Options', $ssMenu) Local $ssMenuCopI4 = GUICtrlCreateMenuItem('Uninstall Software Selection', $ssMenu) Local $ssMenuCopI6 = GUICtrlCreateMenuItem('', $ssMenu) ;Local $ssMenuUPDATES = GUICtrlCreateMenu('Update Options', $ssMenu) Local $ssMenuCopI7 = GUICtrlCreateMenuItem('Install Selected Windows Update', $ssMenu) Local $ssMenuCopI6 = GUICtrlCreateMenuItem('', $ssMenu) Local $ssMenuSTARTUP = GUICtrlCreateMenu('Startup Options', $ssMenu) Local $ssj2p = GUICtrlCreateMenuItem('Open Location...', $ssMenuSTARTUP) GUICtrlCreateMenuItem('', $ssMenuSTARTUP) Local $ssdel = GUICtrlCreateMenuItem('Delete Item', $ssMenuSTARTUP) GUICtrlCreateMenuItem('', $ssMenuSTARTUP) Local $SSexpprop = GUICtrlCreateMenuItem('Extended Properties', $ssMenuSTARTUP) Local $SSwinprop = GUICtrlCreateMenuItem('Window Properties', $ssMenuSTARTUP) $Label_CountItems = GUICtrlCreateLabel('Number', 26, 530, 46, 20) $Input_CountItems = GUICtrlCreateInput('', 69, 527, 39, 21) $Button_Softservices_Exit = GUICtrlCreateButton("Exit", 776, 536, 89, 33) $Button_Refresh = GUICtrlCreateButton("Refresh", 776, 496, 89, 33) $Form_Edit1 = GUICtrlCreateEdit("", 168, 496, 593, 73) GUICtrlSetData(-1, "") ;_ComputerGetSoftware($Software) ;_ComputerGetSystem($Software) ;_ArrayDisplay($Software) ;Exit ;_ArraySort($Software, 0, 1) _Services_list() GUISetState(@SW_SHOW) #endregion #region loop While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Button_Softservices_Exit Exit Case $ssMenuCopI4 _UninstallADJ() Case $ssMenuCopI _StopservC() Case $ssMenuCopI2 _StartservC() Case $ssMenu2CopI5 ; automatic _ServStartMode("Automatic") Case $ssMenu3CopI5 ; Manual _ServStartMode("Manual") Case $ssMenu4CopI5 ; Disabled _ServStartMode("Disabled") Case $ssMenuCopI7 ; updates _startwinup() Case $Radio_Services GUICtrlSetData($Input_CountItems, '') _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv)) Sleep(500) _Services_list() Case $Button_Refresh refreshitems() Case $Radio_OnlySoft GUICtrlSetData($Input_CountItems, '') _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv)) Sleep(500) _OnlySoft() Case $Radio_OnlyUpd GUICtrlSetData($Input_CountItems, '') _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv)) Sleep(500) _PopulateNeeded($host) ;fetchandupdate() Case $Radio_Onlystartup GUICtrlSetData($Input_CountItems, '') _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv)) Sleep(500) _StartupList() Case $ssj2p _Jump2Path() Case $ssdel _ItemDelete() Case $SSexpprop _FilePropertiesEx() Case $SSwinprop _WindowsProperties() EndSwitch WEnd #endregion Func _StartupList() GUICtrlSetData($ListView_Soft_Serv, "Common Startups|Company Name|Version|File Description|PTR_PID") _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 0, 200) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 1, 100) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 2, 100) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 3, 50) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 4, 535) Local $hLvi, $ListView_Soft_ServI, $sPath, $p = 0 Local $aItems = GetCommonStartups(1) $nTLvID = 0 For $i = 1 To $aItems[0] If StringInStr($aItems[$i], '<*', 0, 1, 1, 2) Then $aItems[$i] = StringReplace($aItems[$i], '<', '') $p = 1 EndIf If StringInStr($aItems[$i], 'HKEY', 0, 1, 1, 4) Then $hLvi = GUICtrlCreateListViewItem($aItems[$i], $ListView_Soft_Serv) If $nTLvID = 0 Then $nTLvID = $hLvi GUICtrlSetImage($hLvi, 'regedit.exe', 100) ElseIf Not StringInStr($aItems[$i], '*', 0, 1, 1, 1) Then $hLvi = GUICtrlCreateListViewItem($aItems[$i], $ListView_Soft_Serv) GUICtrlSetImage($hLvi, 'explorer.exe', 252) ElseIf StringInStr($aItems[$i], '*', 0, 1, 1, 1) Then $sPath = Reg_GetFriendlyPath($aItems[$i], 1) $ListView_Soft_ServI = Reg_GetFriendlyPath($aItems[$i]) & '|' $ListView_Soft_ServI &= _GetFileProperties($sPath) $ListView_Soft_ServI &= '' $hLvi = GUICtrlCreateListViewItem($ListView_Soft_ServI, $ListView_Soft_Serv) If StringInStr($aItems[$i], @UserProfileDir) Then GUICtrlSetBkColor($hLvi, 0xFF8080) Else GUICtrlSetBkColor($hLvi, 0x00ff00) EndIf If $p = 1 Then GUICtrlSetBkColor($hLvi, 0xFF8080) $p = 0 EndIf GUICtrlSetImage($hLvi, 'explorer.exe', 251) EndIf Next Lv_AutoSetWidth() $state = 1 EndFunc Func _Services_list() GUICtrlSetData($ListView_Soft_Serv, "The name of the Service|Current State|Start Mode|Status|Description") _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 0, 200) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 1, 100) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 2, 100) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 3, 50) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 4, 535) _ComputerGetServices($Software) For $i = 1 To UBound($Software) - 1 GUICtrlCreateListViewItem($Software[$i][0] & '|' & $Software[$i][17] & '|' & $Software[$i][15] & '|' & $Software[$i][18] & '|' & $Software[$i][4], $ListView_Soft_Serv) Next GUICtrlSetData($Input_CountItems, _GUICtrlListView_GetItemCount($ListView_Soft_Serv)) EndFunc ;==>_Services_list Func _OnlySoft() GUICtrlSetData($ListView_Soft_Serv, '#|Installed Software|Version|Publisher|Uninstall String') _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 0, 30) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 1, 100) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 2, 70) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 3, 180) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 4, 230) Local $i = 0 _ComputerGetSoftwareuninst($Software) For $i = 1 To UBound($Software) - 1 GUICtrlCreateListViewItem($i & '|' & $Software[$i][0] & '|' & $Software[$i][1] & '|' & $Software[$i][2] & '|' & $Software[$i][3], $ListView_Soft_Serv) Next GUICtrlSetData($Input_CountItems, _GUICtrlListView_GetItemCount($ListView_Soft_Serv)) EndFunc ;==>_OnlySoft Func _PopulateNeeded($host) ; needed updates list GUICtrlSetData($ListView_Soft_Serv, "Title|Description|Status|Blank|Blank") _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 0, 350) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 1, 350) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 2, 100) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 3, 0) _GUICtrlListView_SetColumnWidth($ListView_Soft_Serv, 4, 0) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv)) SplashTextOn("Please Wait.","Finding Needed Updates",200,30,-1,-1,32) $arrNeeded = _FetchNeededData($host) ;_arraydisplay($arrNeeded) SplashOff() If IsArray($arrNeeded) and $arrNeeded[0][0]<>"" Then For $i = 0 to UBound($arrNeeded) -1 _GUICtrlListView_AddItem($ListView_Soft_Serv,$arrNeeded[$i][0]) _GUICtrlListView_AddSubItem($ListView_Soft_Serv,$i,$arrNeeded[$i][1],1) Next Else _GUICtrlListView_AddItem($ListView_Soft_Serv,"No Needed Updates Found") EndIf ;_arraydisplay($arrNeeded) ;_arraydisplay($jambo) ;exit $objSearcher = 0 $arrNeeded = 0 EndFunc Func refreshitems() If BitAND(GUICtrlRead($Radio_Services), $GUI_CHECKED) = $GUI_CHECKED Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv)) GUICtrlSetData($Input_CountItems, '') Sleep(500) _Services_list() ElseIf BitAND(GUICtrlRead($Radio_OnlySoft), $GUI_CHECKED) = $GUI_CHECKED Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv)) GUICtrlSetData($Input_CountItems, '') Sleep(500) _OnlySoft() elseif BitAND(GUICtrlRead($Radio_Onlystartup), $GUI_CHECKED) = $GUI_CHECKED Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv)) GUICtrlSetData($Input_CountItems, '') Sleep(500) _StartupList() EndIf EndFunc ;==>refreshitems #cs #region software Func _UninstallADJ() If BitAND(GUICtrlRead($Radio_OnlySoft), $GUI_CHECKED) = $GUI_CHECKED Then Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), '|', 1) If $proc[1] == 0 Then Return -1 If $proc[5] Then RunWait($proc[5]);MsgBox(4096,"ww",$proc[4]); refreshitems() Return EndIf ; exit EndFunc ;==>_Uninstall Func _ComputerGetSoftwareuninst(ByRef $aSoftwareInfoUninstbasic) Local $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Local $i = 1 Dim $aSoftwareInfoUninstbasic[1][4] $input = "ALL";inputbox ("Which Software" , "You are running " & @OSVersion & " " & @OSARCH & @CRLF & @CRLF & "Which Software would you like to view?", 'ALL') If @error = 1 Then Exit For $j = 1 To 500 $AppKey = RegEnumKey($UnInstKey, $j) If @error <> 0 Then ExitLoop If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop ReDim $aSoftwareInfoUninstbasic[UBound($aSoftwareInfoUninstbasic) + 1][4] $aSoftwareInfoUninstbasic[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3) $aSoftwareInfoUninstbasic[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3) $aSoftwareInfoUninstbasic[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3) $aSoftwareInfoUninstbasic[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3) $i = $i + 1 Next Local $UnInstKey = "HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" For $j = 1 To 500 $AppKey = RegEnumKey($UnInstKey, $j) If @error <> 0 Then ExitLoop If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop ReDim $aSoftwareInfoUninstbasic[UBound($aSoftwareInfoUninstbasic) + 1][4] $aSoftwareInfoUninstbasic[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3) $aSoftwareInfoUninstbasic[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3) $aSoftwareInfoUninstbasic[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3) $aSoftwareInfoUninstbasic[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3) $i = $i + 1 Next Local $UnInstKey = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" For $j = 1 To 500 $AppKey = RegEnumKey($UnInstKey, $j) If @error <> 0 Then ExitLoop If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop ReDim $aSoftwareInfoUninstbasic[UBound($aSoftwareInfoUninstbasic) + 1][4] $aSoftwareInfoUninstbasic[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3) $aSoftwareInfoUninstbasic[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3) $aSoftwareInfoUninstbasic[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3) $aSoftwareInfoUninstbasic[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3) $i = $i + 1 Next #cs Local $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" For $j = 1 To 500 $AppKey = RegEnumKey($UnInstKey, $j) If @error <> 0 Then ExitLoop If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop ReDim $aSoftwareInfoUninstbasic[UBound($aSoftwareInfoUninstbasic) + 1][4] $aSoftwareInfoUninstbasic[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3) $aSoftwareInfoUninstbasic[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3) $aSoftwareInfoUninstbasic[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3) $aSoftwareInfoUninstbasic[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3) $i = $i + 1 Next #ce $aSoftwareInfoUninstbasic[0][0] = UBound($aSoftwareInfoUninstbasic, 1) - 1 If $aSoftwareInfoUninstbasic[0][0] < 1 Then SetError(1, 1, 0) ;Return _ArraySort($aSoftwareInfoUninstbasic) ; original code Return _ArraySort($aSoftwareInfoUninstbasic, 0, 1) EndFunc ;==>_ComputerGetSoftwareuninst #endregion #region services Func _StopservC() If BitAND(GUICtrlRead($Radio_Services), $GUI_CHECKED) = $GUI_CHECKED Then Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), '|', 1) ;MsgBox(4096,"ww",$proc[1]) If $proc[1] == "" Then Return -1 $jamtest = _SvcStop($proc[1]) refreshitems() ;MsgBox(4096,"ww",$jamtest) Else Return EndIf EndFunc ;==>_StopservC Func _StartservC() If BitAND(GUICtrlRead($Radio_Services), $GUI_CHECKED) = $GUI_CHECKED Then Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), '|', 1) ;MsgBox(4096,"ww",$proc[1]) If $proc[1] == "" Then Return -1 $jamtest = _SvcStart($proc[1]) refreshitems() ;MsgBox(4096,"ww",$jamtest) Else Return EndIf EndFunc ;==>_StartservC Func _ServStartMode($SVCStartstate) If BitAND(GUICtrlRead($Radio_Services), $GUI_CHECKED) = $GUI_CHECKED Then Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), '|', 1) ;MsgBox(4096,"ww",$proc[1]) If $proc[1] == "" Then Return -1 $jamtest = _SvcSetStartMode($proc[1], $SVCStartstate) refreshitems() ;MsgBox(4096,"ww",$jamtest) ;If $proc[5] Then RunWait($proc[5]);MsgBox(4096,"ww",$proc[4]); Else Return EndIf EndFunc ;==>_ServStartMode ; #FUNCTION# ==================================================================================================================== ; Name...........: _SvcSetStartMode ; Description ...: Sets the start mode of the system restore service ; Syntax.........: _SvcSetStartMode($sService, $sMode) ; Parameters ....: $sService - Name of the service (note: this differs from DisplayName) ; |$sMode - "Automatic", "Manual", or "Disabled" ; Return values .: Success - True ; Failure - False ; Author ........: Matthew McMullan (NerdFencer) ; Modified.......: ; Remarks .......: "Boot" and "System" are also valid, but do NOT use them unless you really know what you are doing ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _SvcSetStartMode($sService, $sMode) If StringLower($sMode) == "demand" Then $sMode = "Manual" ElseIf StringLower($sMode) == "auto" Then $sMode = "Automatic" ElseIf StringLower($sMode) == "disabled" Then $sMode = "Disabled" EndIf If Not ($sMode == "Automatic" Or $sMode == "Manual" Or $sMode == "Disabled" Or $sMode == "Boot" Or $sMode == "System") Then Return False EndIf Local $objRoot = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") Local $objServices = $objRoot.ExecQuery("SELECT * FROM Win32_Service") For $objService In $objServices If $objService.Name == $sService Then If $objService.StartMode == $sMode Then EndIf Local $iOutput = $objService.ChangeStartMode($sMode) Return ($iOutput == 0) EndIf Next Return False EndFunc ;==>_SvcSetStartMode ; #FUNCTION# ==================================================================================================================== ; Name...........: _SvcStart ; Description ...: Starts the System Restore Service ; Syntax.........: _SvcStart($sService, $bForce = True) ; Parameters ....: $sService - Name of the service (note: this differs from DisplayName) ; |$bForce - Forces the service to start even if it is disabled ; Return values .: Success - True ; Failure - False ; Author ........: Matthew McMullan (NerdFencer) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _SvcStart($sService, $bForce = True) Local $objRoot = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") Local $objServices = $objRoot.ExecQuery("SELECT * FROM Win32_Service") For $objService In $objServices If $objService.Name = $sService Then Local $iOutput = $objService.StartService() If $iOutput == 0 Or $iOutput == 10 Then Return True EndIf If $iOutput == 14 And $bForce == True Then $objService.ChangeStartMode("Manual") $iOutput = $objService.StartService() If $iOutput == 0 Or $iOutput == 10 Then Return True EndIf EndIf Return False EndIf Next Return False EndFunc ;==>_SvcStart ; #FUNCTION# ==================================================================================================================== ; Name...........: _SvcStop ; Description ...: Stops the Service ; Syntax.........: _SvcStop($sService) ; Parameters ....: $sService - Name of the service (note: this differs from DisplayName) ; Return values .: Success - True ; Failure - False ; Author ........: Matthew McMullan (NerdFencer) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _SvcStop($sService) Local $objRoot = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") Local $objServices = $objRoot.ExecQuery("SELECT * FROM Win32_Service") For $objService In $objServices If $objService.Name = $sService Then Local $iOutput = $objService.StopService() If $iOutput == 0 Or $iOutput == 6 Then Return True EndIf Return False EndIf Next Return False EndFunc ;==>_SvcStop #endregion #region windows updates func fetchandupdate() local $jambo SplashTextOn("Please Wait.","Finding Needed Updates",200,30,-1,-1,32) $arrNeeded = _FetchNeededDataauto($host) ;_arraydisplay($arrNeeded) SplashOff() If IsArray($arrNeeded) Then ; For $i = 0 to UBound($arrNeeded) -1 ; _GUICtrlListView_AddItem($ListView_Soft_Serv,$arrNeeded[$i][0]) ; _GUICtrlListView_AddSubItem($ListView_Soft_Serv,$i,$arrNeeded[$i][1],1) ;_ArrayAdd($jambo, $arrNeeded) ;$numDwnld += 1 ; Next msgbox(4096,"woohoo","its an array") Else msgbox(4096,"array error","No Needed Updates Found") EndIf _arraydisplay($arrNeeded) ;_arraydisplay($jambo) msgbox(4096,"fin 1st",$arrNeeded[0]) ;exit $objSearcher = _CreateMSUpdateSession($host) For $x = 1 To $arrNeeded[0] $item = $arrNeeded[$x] For $i = 0 To $colNeeded.Updates.Count-1 $update = $colNeeded.Updates.Item($i) If $item = $update.Title Then SplashTextOn("Please Wait.","Downloading... " & $item,200,30,-1,-1,32) $updatesToDownload = ObjCreate("Microsoft.Update.UpdateColl") $updatesToDownload.Add ($update) $DownloadSession = $objSearcher.CreateUpdateDownloader() $DownloadSession.Updates = $updatesToDownload $DownloadSession.Download SplashOff() SplashTextOn("Finished","Downloaded: " & $item,200,30,-1,-1,32) sleep(1000) EndIf Next Next $reboot= 0 For $x = 1 To $arrNeeded[0] $item = $arrNeeded[$x] For $i = 0 To $colNeeded.Updates.Count-1 $update = $colNeeded.Updates.Item($i) If $item = $update.Title And $update.IsDownloaded Then SplashTextOn("Please Wait.","Installing... " & $item,200,30,-1,-1,32) $InstallSession = $objSearcher.CreateUpdateInstaller() $updatesToInstall = ObjCreate("Microsoft.Update.UpdateColl") $updatesToInstall.Add($update) $InstallSession.Updates = $updatesToInstall $installresult = $InstallSession.Install If $installresult.RebootRequired Then $reboot = 1 SplashOff() SplashTextOn("Finished","Install Complete: " & $item,200,30,-1,-1,32) sleep(1000) EndIf Next Next If $reboot Then Msgbox(0,"Installation Complete","A Reboot is Required.") $DownloadSession = 0 $updatesToDownload = 0 ;Return 0 $objSearcher = 0 $arrNeeded = 0 EndFunc Func _FetchNeededDataauto($host) $objSearcher = _CreateSearcher(_CreateMSUpdateSession($host)) $colNeeded = _GetNeededUpdates($objSearcher) $objSearcher = 0 ;Dim $arrNeeded[1][2] dim $hahaha[1] For $i = 0 To $colNeeded.Updates.Count-1 ; If $i < $colNeeded.Updates.Count-1 Then ReDim $arrNeeded[$i+2][2] $update = $colNeeded.Updates.Item($i) ; $arrNeeded[$i][0] = $update.Title ;$arrNeeded[$i][1] = $update.Description _ArrayAdd($hahaha,$update.Title) Next If Not IsArray($hahaha) Then msgbox(16,"Failed to Fetch Needed Updates " & $host,"",5) Return 0 EndIf $hahaha[0] = UBound($hahaha) - 1 ; sort out array count ;_ArrayDisplay($hahaha) Return $hahaha EndFunc Func _FetchNeededData($host) $objSearcher = _CreateSearcher(_CreateMSUpdateSession($host)) $colNeeded = _GetNeededUpdates($objSearcher) $objSearcher = 0 Dim $arrNeeded[1][2] For $i = 0 To $colNeeded.Updates.Count-1 If $i < $colNeeded.Updates.Count-1 Then ReDim $arrNeeded[$i+2][2] $update = $colNeeded.Updates.Item($i) $arrNeeded[$i][0] = $update.Title $arrNeeded[$i][1] = $update.Description Next If Not IsArray($arrNeeded) Then msgbox(16,"Failed to Fetch Needed Updates " & $host,"",5) Return 0 EndIf Return $arrNeeded EndFunc Func _CreateMSUpdateSession($strHost = @ComputerName) $objSession = ObjCreate("Microsoft.Update.Session",$strHost) If Not IsObj($objSession) Then Return 0 Return $objSession EndFunc Func _CreateSearcher($objSession) If Not IsObj($objSession) Then Return -1 Return $objSession.CreateUpdateSearcher EndFunc Func _GetNeededUpdates($objSearcher) If Not IsObj($objSearcher) Then Return -5 $colNeeded = $objSearcher.Search("IsInstalled=0 and Type='Software'") ; IsAssigned=0 is updates not intended to be deployed by automatic updates. 1 is intended. Type='Driver' Return $colNeeded EndFunc Func _UpdatesDownloadAndInstall() HotKeySet("{enter}") $selected = _GUICtrlListView_GetSelectedIndices($ListView_Soft_Serv,True) ;MsgBox(4096,"selected1",$selected) If $selected[0] = 0 Then Return 0 EndIf $objSearcher = _CreateMSUpdateSession($host) For $x = 1 To $selected[0] MsgBox(4096,"selected num",$selected[$x]);42 $item = _GUICtrlListView_GetItemText($ListView_Soft_Serv,$selected[$x]) MsgBox(4096,"item1",$item); title text For $i = 0 To $colNeeded.Updates.Count-1 $update = $colNeeded.Updates.Item($i) If $item = $update.Title Then _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Downloading...",2) $updatesToDownload = ObjCreate("Microsoft.Update.UpdateColl") $updatesToDownload.Add ($update) $DownloadSession = $objSearcher.CreateUpdateDownloader() $DownloadSession.Updates = $updatesToDownload $DownloadSession.Download _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Downloaded",2) EndIf Next Next $reboot= 0 For $x = 1 To $selected[0] $item = _GUICtrlListView_GetItemText($ListView_Soft_Serv,$selected[$x]) For $i = 0 To $colNeeded.Updates.Count-1 $update = $colNeeded.Updates.Item($i) If $item = $update.Title And $update.IsDownloaded Then _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Installing...",2) $InstallSession = $objSearcher.CreateUpdateInstaller() $updatesToInstall = ObjCreate("Microsoft.Update.UpdateColl") $updatesToInstall.Add($update) $InstallSession.Updates = $updatesToInstall $installresult = $InstallSession.Install If $installresult.RebootRequired Then $reboot = 1 _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Complete",2) EndIf Next Next If $reboot Then Msgbox(0,"Installation Complete","A Reboot is Required.") $DownloadSession = 0 $updatesToDownload = 0 Return 0 EndFunc #cs Func _UpdatesDownloadAndInstall() ; HotKeySet("{enter}") $selected = _GUICtrlListView_GetSelectedIndices($ListView_Soft_Serv,True) MsgBox(4096,"selected1",$selected) If $selected[0] = 0 Then Return 0 EndIf $objSearcher = _CreateMSUpdateSession($host) For $x = 1 To $selected[0] MsgBox(4096,"selected num",$selected[$x]);42 $item = _GUICtrlListView_GetItemText($ListView_Soft_Serv,$selected[$x]) MsgBox(4096,"item1",$item); title text For $i = 0 To $colNeeded.Updates.Count-1 $update = $colNeeded.Updates.Item($i) If $item = $update.Title Then _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Downloading...",2) $updatesToDownload = ObjCreate("Microsoft.Update.UpdateColl") $updatesToDownload.Add ($update) $DownloadSession = $objSearcher.CreateUpdateDownloader() $DownloadSession.Updates = $updatesToDownload $DownloadSession.Download _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Downloaded",2) EndIf Next Next $reboot= 0 For $x = 1 To $selected[0] $item = _GUICtrlListView_GetItemText($ListView_Soft_Serv,$selected[$x]) For $i = 0 To $colNeeded.Updates.Count-1 $update = $colNeeded.Updates.Item($i) If $item = $update.Title And $update.IsDownloaded Then _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Installing...",2) $InstallSession = $objSearcher.CreateUpdateInstaller() $updatesToInstall = ObjCreate("Microsoft.Update.UpdateColl") $updatesToInstall.Add($update) $InstallSession.Updates = $updatesToInstall $installresult = $InstallSession.Install If $installresult.RebootRequired Then $reboot = 1 _GUICtrlListView_SetItemText($ListView_Soft_Serv,$i,"Complete",2) EndIf Next Next If $reboot Then Msgbox(0,"Installation Complete","A Reboot is Required.") $DownloadSession = 0 $updatesToDownload = 0 Return 0 EndFunc #ce func _startwinup() If BitAND(GUICtrlRead($Radio_OnlyUpd), $GUI_CHECKED) = $GUI_CHECKED Then ;MsgBox(4096,"","cool") _UpdatesDownloadAndInstall() EndIf EndFunc #cs Func _HighlightPatchResults() For $i = 0 to UBound($items)-1 $item = _GUICtrlListView_GetItemText($historylistview,$i,3) $find = _ArraySearch($items,$item,0,0,0,0,0,2) _GUICtrlListView_SetItemSelected($historylistview,$find,False) If $find <> $i And $find <> -1 Then For $x = 1 to 4 $tempval = $items[$i][$x] $items[$i][$x] = $items[$find][$x] $items[$find][$x] = $tempval _ArraySwap($items[$find][$x],$items[$i][$x]) Next msgbox(0,$item,$items[$find][3]) EndIf If _GUICtrlListView_GetItemText($historylistview,$i,3) = "Failed" Then GUICtrlSetBkColor($items[$i][0],0xFF0000) Else GUICtrlSetBkColor($items[$i][0],0xFFFFFF) EndIf Next EndFunc Func _PopulateHistory($host) $arrHistory = _FetchHistoryData($host) For $i = 0 to UBound($arrHistory) -1 $strItem = $arrHistory[$i][0] & "|" & $arrHistory[$i][1] & "|" & $arrHistory[$i][2] & "|" & $arrHistory[$i][3] $items[$i][0] = GUICtrlCreateListViewItem($strItem,$historylistview) For $x = 0 to 3 $items[$i][$x+1] = $arrHistory[$i][$x] Next If $i < UBound($arrHistory)-1 then ReDim $items[$i+2][5] Next _HighlightPatchResults() $objSearcher = 0 $arrHistory = 0 EndFunc Func _FetchHistoryData($host) $objSearcher = _CreateSearcher(_CreateMSUpdateSession($host)) $arrHistory = _GetHistory(_GetTotalHistoryCount($objSearcher),$objSearcher) $objSearcher = 0 If Not IsArray($arrHistory) Then msgbox(16,"Failed to Fetch History " & $host,"",5) Return 0 EndIf Return $arrHistory EndFunc Func _GetHistory($varTotalHistoryCount,$objSearcher) If Not $varTotalHistoryCount or Not IsObj($objSearcher) Then Return -3 Dim $arrHistory[1][4] $idx = 0 $colHistory = $objSearcher.QueryHistory(1, $varTotalHistoryCount) For $objEntry in $colHistory ReDim $arrHistory[$idx+1][4] $arrHistory[$idx][0] = _DateConv($objEntry.Date) $arrHistory[$idx][1] = $objEntry.Title $arrHistory[$idx][2] = $objEntry.Description If $objEntry.ResultCode = 2 Then $arrHistory[$idx][3] = "Successful" Else $arrHistory[$idx][3] = "Failed" EndIf $idx += 1 Next Return $arrHistory EndFunc Func _GetTotalHistoryCount($objSearcher) If Not IsObj($objSearcher) Then Return -2 Return $objSearcher.GetTotalHistoryCount EndFunc #ce #endregion #region startups ; ; ============================================================================================ ; Function: GetCommonStartups ; Release Date: April 12, 2011 ; Last Modified: June 25, 2011 ; Example: Yes ; ; Description: ; Returns an array of all Run Keys (including all SID Run Keys), UserInit and Startup Folders ; ; Options: ; $WarnOnUPD = 0 (Off by default) ; $WarnOnUPD = 1 (Warns if program is started under the UserProfileDir) ; ============================================================================================ Func GetCommonStartups($WarnOnUPD = 0) Local $sDir = StringLeft(@UserProfileDir, StringInStr(@UserProfileDir, '\', 0, -1) - 1) Local $HKWOW_WLN = $HKLM & '\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon' Local $HKWOW_AID = $HKLM & '\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Windows' Local $HKLM_AID = $HKLM & '\Software\Microsoft\Windows NT\CurrentVersion\Windows' Local $HKLM_WLN = $HKLM & '\Software\Microsoft\Windows NT\CurrentVersion\Winlogon' Local $HKCU_WLN = $HKCU & '\Software\Microsoft\Windows NT\CurrentVersion\Winlogon' Local $sPath, $str, $val, $vn Local $aKeys = Reg_GetRunKeys() ; For $i = 1 To $aKeys[0] $str &= $aKeys[$i] & '|' For $j = 1 To 1000 $vn = RegEnumVal($aKeys[$i], $j) If @error <> 0 Then ExitLoop $val = StringStripWS(StringReplace(RegRead($aKeys[$i], $vn), '"', ''), 3) $sPath = Reg_GetFriendlyPath($val, 1) If StringInStr($sPath, $sDir) And FileExists($sPath) And $WarnOnUPD Then MsgBox(8240, 'UserProfileDir Startup Warning', $aKeys[$i] & @CRLF & $val) EndIf $str &= '*' & $vn & '-->' & $val & '|' $val = '' Next Next ; ; Wow6432Node - 64 bit OS If $Vista_7 And $OSA64 Then $str &= $HKWOW_WLN & '|' $val = RegRead($HKWOW_WLN, 'Userinit') If $val <> 'userinit.exe' Then; <-- Win7 Default $str &= '<' EndIf $str &= '*Userinit-->' & $val & '|' ; $val = RegRead($HKWOW_WLN, 'Shell') If $val <> 'explorer.exe' Then; <-- Win7 Default $str &= '<' EndIf $str &= '*Shell-->' & $val & '|' ; $val = RegRead($HKWOW_WLN, 'UIHost'); ValueName does not exist by Win7 Default If $val Then $str &= '<*UIHost-->' & $val & '|' EndIf ; $str &= $HKWOW_AID & '|' $val = RegRead($HKWOW_AID, 'AppInit_DLLs'); Value is Blank by Win7 Default If $val Then $str &= '<*AppInit_DLLs-->' & $val & '|' EndIf EndIf ; ; All OS $str &= $HKCU_WLN & '|' $val = RegRead($HKCU_WLN, 'Shell'); ValueName does not exist by Default If $val Then $str &= '<*Shell-->' & $val & '|' EndIf ; $str &= $HKLM_AID & '|' $val = RegRead($HKLM_AID, 'AppInit_DLLs'); Value is Blank by Default If $val Then $str &= '<*AppInit_DLLs-->' & $val & '|' EndIf ; $str &= $HKLM_WLN & '|' $val = RegRead($HKLM_WLN, 'Userinit') If $val = 'userinit.exe' Then; <-- Good ElseIf $val = @WindowsDir & '\System32\userinit.exe' Then; <-- Good ElseIf $val = @WindowsDir & '\System32\userinit.exe,' Then; <-- Good (Default) Else; <-- Not Good $str &= '<' EndIf $str &= '*Userinit-->' & $val & '|' ; $val = RegRead($HKLM_WLN, 'UIHost'); Does not exist in Vista\7 (by Default) If $val Then If $val <> 'logonui.exe' Then; <-- XP Default $str &= '<' EndIf $str &= '*UIHost-->' & $val & '|' EndIf ; $val = RegRead($HKLM_WLN, 'Shell') If $val <> 'explorer.exe' Then; <-- Default $str &= '<' EndIf $str &= '*Shell-->' & $val & '|' ; $sPath = $sDir & '\' Local $Startup = '\' & StringTrimLeft(@StartupCommonDir, StringInStr(@StartupCommonDir, '\', 0, -3)) Local $aPath, $sFolder, $sFile, $string Local $hF = FileFindFirstFile($sPath & '*') If $hF = -1 Then MsgBox(8240, 'APHC', 'An error was encountered.' & @CRLF & 'Startup folders will not be processed.') Return StringSplit(StringTrimRight($str, 1), '|') EndIf While 1 $sFolder = FileFindNextFile($hF) If @error Then ExitLoop If Not @extended Then ContinueLoop $string &= $sPath & $sFolder & '|' WEnd FileClose($hF) ; If $Vista_7 Then $string &= StringLeft(@StartupCommonDir, StringInStr(@StartupCommonDir, '\', 0, -3) - 1) & '|' Local $aItems = StringSplit(StringTrimRight($string, 1), '|') ; For $i = 1 To $aItems[0] $sPath = $aItems[$i] & $Startup If Not FileExists($sPath) Then ContinueLoop $hF = FileFindFirstFile($sPath & '\*') If $hF = -1 Then ContinueLoop $str &= $sPath & '|' While 1 $sFile = FileFindNextFile($hF) If @error Then ExitLoop If @extended Then ContinueLoop If StringRight($sFile, 4) = '.ini' Then ContinueLoop If StringRight($sFile, 4) = '.lnk' Then $aPath = FileGetShortcut($sPath & '\' & $sFile) If StringInStr($aPath[0], $sDir) And FileExists($aPath[0]) And $WarnOnUPD Then MsgBox(8240, 'UserProfileDir Startup Warning', $sPath & '\' & $sFile & @CRLF & $aPath[0]) EndIf $str &= '*' & $sFile & '-->' & $aPath[0] & '|' Else If StringInStr($sPath & '\' & $sFile, $sDir) And $WarnOnUPD Then MsgBox(8240, 'UserProfileDir Startup Warning', $sPath & @CRLF & $sPath & '\' & $sFile) EndIf $str &= '*' & $sFile & '-->' & $sPath & '\' & $sFile & '|' EndIf WEnd FileClose($hF) Next Return StringSplit(StringTrimRight($str, 1), '|') EndFunc ; Func _GetFileProperties($sPath) If Not $sPath Then Return 'File Not Found|---|---|' Local $s = FileGetVersion($sPath, 'CompanyName') & '|' $s &= FileGetVersion($sPath) & '|' $s &= FileGetVersion($sPath, 'FileDescription') & '|' Return $s EndFunc ; ; ===================================================================================== ; Function: Reg_GetFriendlyPath() ; Released: July 05, 2011 by ripdad ; ; Version: 1.0.2 ; ; Description: Extracts a given string taken from the registry and transforms it to ; something more friendly for various uses - such as FileGetVersion() ; ; Dependency #1 - FileTool() ; Dependency #2 - The array $aENV ; ; Example: Yes ; ===================================================================================== Func Reg_GetFriendlyPath($string, $mode = 0) If Not StringInStr($string, '*', 0, 1, 1, 1) Then Return $string = StringStripWS(StringReplace($string, '\\??\', ''), 3) $string = StringStripWS(StringReplace($string, '\??\', ''), 3) $string = StringStripWS(StringReplace($string, '"', ''), 3) ; For $i = 1 To $aENV[0][0]; convert environment path strings $string = StringStripWS(StringReplace($string, $aENV[$i][0], $aENV[$i][1]), 3) Next If $mode = 0 Then Return $string; includes switches, keywords, etc ; ; The sections below, attempts to make the path proper for (File Properties) and (Jump to...) functions. ; Works when $mode is not 0. ; ; [Setup] Local $sFile, $sPath, $sResult, $nExts, $GetNumberOfExtensions = 1, $GetPrimaryPath = 3 $string = StringStripWS(StringTrimLeft($string, StringInStr($string, '-->', 0, -1) + 2), 3) ; If StringInStr(StringLeft($string, 4), ':\') Then StringReplace($string, ':\', ''); example: c:\folder\somefile.exe c:\folder\anotherfile.exe If @extended > 1 Then; remove multiple paths from string - extract from 2nd occurrence $string = StringStripWS(StringLeft($string, StringInStr($string, ':\', 0, 2) - 2), 3) EndIf; out = c:\folder\somefile.exe Else StringReplace($string, ':\', ''); example: regedit c:\folder\somefile.reg If @extended Then; remove multiple paths from string - extract from 1st occurrence $string = StringStripWS(StringLeft($string, StringInStr($string, ':\', 0, 1) - 2), 3) EndIf; out = regedit EndIf ; If StringInStr($string, '\') Then; separate file from path $sFile = StringTrimLeft($string, StringInStr($string, '\', 0, -1)) $sPath = StringLeft($string, StringInStr($string, '\', 0, -1) - 1) & '\' Else $sFile = $string $sPath = '' EndIf $sFile = StringRegExpReplace($sFile, '(/|,)', '|'); tag '/' switches and commas in $sFile If StringInStr($sFile, '|') Then; extract from 1st occurrence of a pipe $sFile = StringStripWS(StringLeft($sFile, StringInStr($sFile, '|', 0, 1) - 1), 3) EndIf $nExts = FileTool($sFile, $GetNumberOfExtensions); get number extensions, if exist $string = $sPath & $sFile; reassemble path and file ; [/Setup] ; If $sPath And Not $nExts Then If StringInStr(StringRight($string, 4), '.', 0, 1, 1, 1) Then Return $string EndIf ; ; Attempt to extract path from $string in order of risk ; ; [Attempt 1] If $nExts Then; this file has at least one known extension $sResult = FileTool($string, $GetPrimaryPath); extract path from string If $sResult Then Return $sResult Return SetError(-1, 0, ''); file not found EndIf ; ; [Attempt 2] $sFile = StringReplace($sFile, ' -', '|'); tag '-' switches in $sFile If StringInStr($sFile, '|') Then; extract string from 1st occurrence $sFile = StringStripWS(StringLeft($sFile, StringInStr($sFile, '|', 0, 1) - 1), 3) EndIf $string = $sPath & $sFile & '.exe' ; $sResult = FileTool($string, $GetPrimaryPath) If $sResult Then Return $sResult ; ; [Attempt 3] $string = '(?i)( auto| delay| hide| hidden| max| min| run| wait| -)' $sFile = StringRegExpReplace($sFile, $string, '|'); tag keywords If StringInStr($sFile, '|') Then; extract string from 1st occurrence $sFile = StringStripWS(StringLeft($sFile, StringInStr($sFile, '|', 0, 1) - 1), 3) EndIf $string = $sPath & $sFile & '.exe' ; $sResult = FileTool($string, $GetPrimaryPath) If $sResult Then Return $sResult Return SetError(-2, 0, ''); file not found EndFunc Func Reg_GetRunKeys() Local $str = $HKU & '|' $str &= $HKCU & '\Software\Microsoft\Windows\CurrentVersion|' $str &= $HKLM & '\Software\Microsoft\Windows\CurrentVersion|' If $OSA64 Then $str &= $HKLM & '\Software\Wow6432Node\Microsoft\Windows\CurrentVersion|' Local $aKeys = StringSplit(StringTrimRight($str, 1), '|') Local $key, $sub, $n = 1 $str = '' ; For $i = 1 To $aKeys[0] If $i = 1 Then $sub = RegEnumKey($aKeys[$i], $n) If @error <> 0 Then ContinueLoop $key = $aKeys[$i] & '\' & $sub & '\Software\Microsoft\Windows\CurrentVersion' $n += 1 $i = 0 Else $key = $aKeys[$i] EndIf ; For $j = 1 To 1000 $sub = RegEnumKey($key, $j) If @error <> 0 Then ExitLoop If StringInStr($sub, 'Run') Then $str &= $key & '\' & $sub & '|' Next Next ; Return StringSplit(StringTrimRight($str, 1), '|') EndFunc ; ; ===================================================================================== ; Function: FileTool() ; Released: July 04, 2011 by ripdad ; ; Version: 1.0.0 ; ; Description: Has several abilities working with files and extensions. ; ; $nMode values: ; 1 = (Returns a number) of all "Defined Extensions" found in a string (Default) ; 2 = (Returns an array) of all "Defined Extensions" found in a string ; 3 = (Returns a string) of the first path found in a string ; ; Dependencies: None ; ; Example: Yes ; ===================================================================================== Func FileTool($sInput, $nMode = 1) Local $sPath, $sFile If StringInStr($sInput, '\') Then $sFile = StringTrimLeft($sInput, StringInStr($sInput, '\', 0, -1)) $sPath = StringLeft($sInput, StringInStr($sInput, '\', 0, -1) - 1) & '\' Else $sFile = $sInput $sPath = '' EndIf Local $aExt = StringRegExp($sFile, '(?i)(\.exe|\.bat|\.cmd|\.com|\.msi|\.scr)', 3) If Not IsArray($aExt) Then Return SetError(-1, 0, 0); no matched extension found Local $nExt = UBound($aExt) If $nMode = 1 Then Return SetError(0, 0, $nExt); number of extensions If $nMode = 2 Then Return SetError(0, 0, $aExt); array of extensions Local $sDrvPath, $sSysPath, $sWinPath, $sExt, $nOS If $nMode = 3 Then; extracts the path and checks if it exist $sExt = $aExt[$nExt - 1]; get the last extension in string StringReplace($sFile, $sExt, ''); count occurrences of last extension in string $nOS = @extended; number of occurrences $sFile = StringStripWS(StringLeft($sFile, StringInStr($sFile, $sExt, 0, $nOS) + 3), 3); extract filename If StringInStr($sPath, '\') Then; string has a path $sPath &= $sFile; reassemble path and file If FileExists($sPath) Then Return SetError(0, 0, $sPath); file found Return SetError(-2, 0, 0); file not found Else; <-- this string has no path, so try system paths below $sDrvPath = @HomeDrive & '\' & $sFile $sSysPath = @SystemDir & '\' & $sFile $sWinPath = @WindowsDir & '\' & $sFile If FileExists($sWinPath) Then If FileExists($sSysPath) Or FileExists($sDrvPath) Then Return SetError(-3, 0, 0); multi-path Return SetError(0, 0, $sWinPath) ElseIf FileExists($sSysPath) Then If FileExists($sDrvPath) Then Return SetError(-4, 0, 0); multi-path Return SetError(0, 0, $sSysPath) EndIf If FileExists($sDrvPath) Then Return SetError(0, 0, $sDrvPath) Return SetError(-5, 0, 0); file not found EndIf EndIf Return SetError(-6, 0, 0); invalid mode EndFunc Func _Jump2Path() Local $aItems = StringSplit(StringTrimRight(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), 1), '|') If $aItems[0] <> 5 Then Return Local $sKey, $sItem = $aItems[1] If StringInStr($sItem, 'HKEY', 0, 1, 1, 4) Then ;==================================================================================== ; modified tidbit from GEOSoft --> "[url="http://www.autoitscript.com/forum/topic/91906-open-regedit-at-a-particular-key/page__p__661225__hl__%22open+regedit%22__fromsearch__1#entry661225"]http://www.autoitscript.com/forum/topic/91906-open-regedit-at-a-particular-key/page__p__661225__hl__%22open+regedit%22__fromsearch__1#entry661225[/url]" $sKey = $HKCU & '\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit' If $OSA64 Then $sItem = StringReplace($sItem, '64\', '\'); Won't work if RootKey64 is in "LastKey" value. If RegWrite($sKey, 'LastKey', 'Reg_SZ', 'Computer\' & $sItem) Then; "My Computer" won't work on Win7 ("Computer" or "Machine" works on XP & Win7) If ProcessExists('regedit.exe') Then ProcessClose('regedit.exe') ShellExecute('regedit.exe') EndIf;=============================================================================== Return EndIf If StringInStr($sItem, '*', 0, 1, 1, 1) Then $sItem = Reg_GetFriendlyPath($sItem, 1) If Not FileExists($sItem) Then Return Local $sMsg, $dir = 0, $attrib = FileGetAttrib($sItem); get original attributes If StringInStr($attrib, 'D') Then $dir = 1; if a folder If StringInStr($attrib, 'H') Then; if hidden $sMsg = $sItem & ' [' & $attrib & ']' & @CRLF & @CRLF & 'Remove Hidden Attribute?' If MsgBox(8228, 'This Item is Hidden', $sMsg) = 6 Then; permission to remove Hidden Attribute $attrib = StringRegExpReplace($attrib, 'D|H', ''); cannot set "D", so remove with "H" also FileSetAttrib($sItem, '+' & $attrib & '-H'); set original attributes, minus Hidden EndIf EndIf If $dir Then; item is a folder Run(@WindowsDir & '\Explorer.exe /e,"' & $sItem & '"') Else; item is a file Run(@WindowsDir & '\Explorer.exe /e,/select,"' & $sItem & '"') EndIf EndFunc ; Func _ItemDelete() Local $IdCtrl = GUICtrlRead($ListView_Soft_Serv) Local $sItem = GUICtrlRead($IdCtrl) If Not StringInStr($sItem, '*', 0, 1, 1, 1) Then Return $sItem = StringStripWS(StringTrimLeft(StringLeft($sItem, StringInStr($sItem, '-->', 0, 1) - 1), 1), 3) Local $Winlogon, $sPath ; For $i = $IdCtrl To $nTLvID Step -1 $sPath = StringTrimRight(GUICtrlRead($i), 1) If StringInStr($sPath, '*') Then ContinueLoop If StringIsDigit($sPath) Then Return $sPath = StringStripWS(StringLeft($sPath, StringInStr($sPath, '|', 0, 1) - 1), 3) ExitLoop Next ; If StringInStr($sPath, 'HKEY', 0, 1, 1, 4) Then If StringInStr($sPath, 'Microsoft\Windows NT\CurrentVersion\Winlogon') Then $Winlogon = $sPath ; ; If registry entry is system critical... the section below will automatically make it right If $Winlogon Then If MsgBox(8228, 'Restore the Default Registry Entry?', $Winlogon & '-->' & $sItem) <> 6 Then Return If $sItem = 'Userinit' Then If StringInStr($Winlogon, 'Wow6432Node') And StringInStr($Winlogon, $HKLM) Then RegWrite($Winlogon, 'Userinit', 'REG_SZ', 'userinit.exe') ElseIf StringInStr($Winlogon, $HKCU) Then RegDelete($Winlogon, 'Userinit') ElseIf StringInStr($Winlogon, $HKLM) Then RegWrite($Winlogon, 'Userinit', 'REG_SZ', @WindowsDir & '\System32\userinit.exe,') EndIf ElseIf $sItem = 'Shell' Then If StringInStr($Winlogon, 'Wow6432Node') And StringInStr($Winlogon, $HKLM) Then RegWrite($Winlogon, 'Shell', 'REG_SZ', 'explorer.exe') ElseIf StringInStr($Winlogon, $HKCU) Then RegDelete($Winlogon, 'Shell') ElseIf StringInStr($Winlogon, $HKLM) Then RegWrite($Winlogon, 'Shell', 'REG_SZ', 'explorer.exe') EndIf ElseIf $sItem = 'UIHost' Then If StringInStr($Winlogon, 'Wow6432Node') And StringInStr($Winlogon, $HKLM) Then RegDelete($Winlogon, 'UIHost') ElseIf StringInStr($Winlogon, $HKCU) Then RegDelete($Winlogon, 'UIHost') ElseIf $Vista_7 And StringInStr($Winlogon, $HKLM) Then RegDelete($Winlogon, 'UIHost') ElseIf (Not $Vista_7) And StringInStr($Winlogon, $HKLM) Then RegWrite($Winlogon, 'UIHost', 'REG_EXPAND_SZ', 'logonui.exe') EndIf EndIf Else; hopefully, below is not system critcal, so be careful! If MsgBox(8228, 'Delete Registry Entry?', $sPath & '-->' & $sItem) <> 6 Then Return RegDelete($sPath, $sItem) EndIf Else $sPath &= '\' & $sItem If FileExists($sPath) Then If MsgBox(8228, 'Delete File or Shortcut?', $sPath) <> 6 Then Return FileSetAttrib($sPath, '-RASHNOT') If Not FileDelete($sPath) Then MsgBox(8240, 'APHC', 'Cannot Delete File or Shortcut:' & @CRLF & $sPath) EndIf EndIf Sleep(250) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView_Soft_Serv)) _StartupList() EndFunc ; Func _FilePropertiesEx() Local $aItems = StringSplit(StringTrimRight(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), 1), '|') If $aItems[0] <> 5 Then Return Local $sPath = $aItems[1] If StringInStr($sPath, 'HKEY', 0, 1, 1, 4) Then Return If StringInStr($sPath, '*', 0, 1, 1, 1) Then $sPath = Reg_GetFriendlyPath($sPath, 1) If Not $sPath Then Return MsgBox(8256, 'APHC - Extended Properties', 'File Not Found') Local $t, $s = $sPath & @CRLF & @CRLF $t = FileGetVersion($sPath, 'CompanyName') If $t Then $s &= 'CompanyName: ' & $t & @CRLF $t = FileGetVersion($sPath, 'FileDescription') If $t Then $s &= 'Description: ' & $t & @CRLF $t = FileGetVersion($sPath, 'ProductName') If $t Then $s &= 'ProductName: ' & $t & @CRLF $t = FileGetVersion($sPath, 'LegalCopyright') If $t Then $s &= 'Copyright: ' & $t & @CRLF Local $attrib = FileGetAttrib($sPath) $t = FileGetVersion($sPath) If Not StringInStr($t, '0.0.0.0') Then $s &= 'Version: ' & $t & @CRLF Local $fgt = FileGetTime($sPath, 1) If Not IsArray($fgt) Then Return MsgBox(8256, 'APHC - Extended Properties', $s) $s &= 'Date Created: ' & $fgt[1] & '/' & $fgt[2] & '/' & $fgt[0] & @CRLF $s &= 'Attributes: ' & $attrib & @CRLF $t = Round(FileGetSize($sPath) / 1024, 2) If $t Then $s &= 'File Size: ' & $t & ' kb' & @CRLF Return MsgBox(8256, 'APHC - Extended Properties', $s) EndFunc ; Func Lv_AutoSetWidth() GUICtrlSendMsg($ListView_Soft_Serv, $LVM_SETCOLUMNWIDTH, 0, $LVSCW_AUTOSIZE) GUICtrlSendMsg($ListView_Soft_Serv, $LVM_SETCOLUMNWIDTH, 1, $LVSCW_AUTOSIZE) GUICtrlSendMsg($ListView_Soft_Serv, $LVM_SETCOLUMNWIDTH, 2, $LVSCW_AUTOSIZE) GUICtrlSendMsg($ListView_Soft_Serv, $LVM_SETCOLUMNWIDTH, 3, $LVSCW_AUTOSIZE) GUICtrlSendMsg($ListView_Soft_Serv, $LVM_SETCOLUMNWIDTH, 4, $LVSCW_AUTOSIZE) EndFunc ; ; Func _WindowsProperties() Local $aItems = StringSplit(StringTrimRight(GUICtrlRead(GUICtrlRead($ListView_Soft_Serv)), 1), '|') If $aItems[0] <> 5 Then Return Local $sPath = $aItems[1] If StringInStr($sPath, 'HKEY', 0, 1, 1, 4) Then Return If StringInStr($sPath, '*', 0, 1, 1, 1) Then $sPath = Reg_GetFriendlyPath($sPath, 1) If Not $sPath Then Return MsgBox(8256, 'APHC - Windows Properties', 'File Not Found') ;<== "[url="http://msdn.microsoft.com/en-us/library/bb762231(VS.85).aspx"]http://msdn.microsoft.com/en-us/library/bb762231(VS.85).aspx[/url]" ==========================================# DllCall('shell32.dll', 'bool', 'SHObjectProperties', 'hwnd', 0, 'dword', 0x00000002, 'wstr', $sPath, 'wstr', 0) ;<============================================================================================================# If @error Then Return MsgBox(8256, 'APHC - Windows Properties', 'oops, something went wrong!') EndFunc Func FILEIESEARCH($FILE, $SE = "Google") Local $URL If $SE = "Google" Then $URL = "[url="http://google.com/search?q"]http://google.com/search?q[/url]=" & $FILE If $SE = "Other" Then $URL = "[url="http://www.runscanner.net/lib/"]http://www.runscanner.net/lib/[/url]" & $FILE & ".html" ShellExecute($URL) EndFunc #endregion p.s its not finished yet lol
-
Thanks, much appreciated. Check your other links too as i tried another project of yours direct from your site and had same issue. Jamie
-
Link to download doesnt work
-
works well thanks
-
Hi Chimaera looks good. Ive been working on a services script myself too. ill post tomo if i get time as its getting late now and i got an early start
-
FileHippo Download and retrieve version V2.13
engjcowi replied to storme's topic in AutoIt Example Scripts
Thanks storme works like a charm -
FileHippo Download and retrieve version V2.13
engjcowi replied to storme's topic in AutoIt Example Scripts
Hey Is anyone having an issue with filehippo at the moment. everytime i use this at the moment it keeps throwing up error code 2. jamie -
Hey I like it so far. Working in windows 7 64bit Feature request, as well as list the services, list their current state also to assist me with deciding whether to alter the state or not. Looking v good though. I like the graph
- 25 replies
-
- Task manager
- taskmgr
-
(and 2 more)
Tagged with:
-
Looks good testing shortly
- 25 replies
-
- Task manager
- taskmgr
-
(and 2 more)
Tagged with:
-
Hi ian Cheers for that. Ill update my ver of ppk and some other scripts where its relevant Any new goodies we can expect with ppk4? @chimera Its just an example. Look for the continue loops in ppk
-
This is awesome. Defo gonna look into this further Thanks
- 17 replies
-
- GUI
- User Interface
-
(and 2 more)
Tagged with:
-
I dont think you will receive any help from anyone here regarding this. I guess you have probably read the forum rules from the title of your post and i think this is certainly not going to go down well with the moderators.
-
Phew. I beleive ive now solved the error. I removed this line: _RecFileListToArray("C:UsersAlisonDesktopdesktop", "*.doc;*.txt;*.xlsx;*.jpg;*.bmp", 1, 1, 0, 2, "", "") and added this line if Not IsArray($Array) Then continueloop under this line $Array = _RecFileListToArray($avArray[$s], '*.pdf; *.xls; *.doc; *.mdb', 1, 1, 1, 2) and now it all seems to work as it should.
-
Thanks for the info. I have a minor problem that im trying to overcome. Ive taken the advice and info from above and ran with it and added to my script and im quite happy except for 1 thing. My script is designed to look through folders and check for the user if there is any word or excel etc.. files and copy them to save them for him. it works great on folders with those files in. On folders where there is nothing then the program stops or closes. I beleive its down to this line - If Not IsArray($Array) Then Return and ive tried some different options (as seen below) including commenting the line out. Does anyone know how i can have the script comment that there is no files in that particular directory and then move on to the next directory. Im eternally greatful for all and any help. Been playing with this for hours now! Jamie #NoTrayIcon #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\..\..\healthcheck source code 24 2 2011\Files\Hardware-HardDrive.ico #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiEdit.au3> #include <Array.au3> local $Destination, $seladdfol, $numfound = 0 Local $avArray[1], $Arraycheck, $coperr , $coperrmsg #cs ; percentage $perc = 100 * ($i+1) / $count GUICtrlSetData($pr_files, $perc) $perc_str = Round($perc) & "% [" & String($i+1) & " of " & $count & "]" GUICtrlSetData($lab_prog1, $perc_str) #ce $Form1 = GUICreate("Backup", 622, 450, 193, 125) $Label1 = GUICtrlCreateLabel("Backup Destination:", 4, 12, 175, 19, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Input1 = GUICtrlCreateInput("", 184, 11, 353, 23) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Button1 = GUICtrlCreateButton("Browse", 540, 10, 75, 25, 0) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Edit1 = GUICtrlCreateEdit("", 4, 40, 613, 369, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetLimit(-1, 9999999) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetBkColor(-1, 0x000000) _GUICtrlEdit_SetReadOnly($Edit1, True) $BACKUP = GUICtrlCreateButton("Backup", 460, 416, 75, 25, 0) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Addfol = GUICtrlCreateButton("Add Folder", 360, 416, 85, 25, 0) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Exit = GUICtrlCreateButton("Exit", 540, 416, 75, 25, 0) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Checkbox1 = GUICtrlCreateCheckbox("Compress Backup", 8, 420, 157, 17) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Checkbox2 = GUICtrlCreateCheckbox("Verbose Log", 200, 420, 157, 17) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exitcode() Case $Exit _Exitcode() Case $Button1 _BackupDestination() Case $Addfol _Addfolder() Case $BACKUP ;MsgBox(4096,"",$Destination) ;_ArrayDisplay($avArray, "$avArray AFTER _ArrayAdd()") GUICtrlSetData($Edit1, @CRLF & @CRLF & "****************** Copying now Started ************************: " & @CRLF & @CRLF, 1) smeg() GuiCtrlSetData($Edit1,@CRLF & @CRLF, 1) GuiCtrlSetData($Edit1, "Completed" & @CRLF, 1) EndSwitch WEnd Func _Exitcode() GUIDelete() Exit EndFunc Func _BackupDestination() $Destination = FileSelectFolder("Select backup destination", "" , 7) GUICtrlSetData($Input1 , $Destination) GuiCtrlSetData($Edit1, $Destination & @CRLF, 1) EndFunc func smeg() ;GUICtrlSetData($Edit1, ''); reset edit control ;_ArrayDisplay($avArray, "$avArray ") If Not IsArray($avArray) Then Return If Not $avArray[0] Then Return Local $n = 0 For $s = 1 To $avArray[0] GUICtrlSetData($Edit1, "Working on Folder: " & $avArray[$s] & @CRLF, 1) GUICtrlSetData($Edit1, "Searching for files " & @CRLF, 1) $Array = _RecFileListToArray($avArray[$s], '*.pdf; *.xls; *.doc; *.mdb', 1, 1, 1, 2) _RecFileListToArray("C:\Users\Alison\Desktop\desktop", "*.doc;*.txt;*.xlsx;*.jpg;*.bmp", 1, 1, 0, 2, "", "") ProgressOn("Copy Files Progress", "No. of files left to copy = " & $array[0], "0 percent done") ;_ArrayDisplay($Array, "$avArray ") ;_ArrayDisplay($Array, "after ") ;exit ;If Not IsArray($Array) Then Return If $array = 9 then MsgBox(4096,"error","") ;ConsoleWrite("Error: " & @error & " - " & " Extended: " & @extended & @CRLF) GuiCtrlSetData($Edit1, "Number of files found " & $Array[0] & @CRLF & @CRLF, 1) $numfound += $Array[0] GuiCtrlSetData($Edit1, "Now Copying Files" & @CRLF & @CRLF, 1) ;MsgBox(4096,"num files found",$Array[0]) For $i = 1 To $Array[0] ; $n += 1 ;If $n > 500 Then ; GUICtrlSetData($Edit1, ''); reset edit control ; $n = 0 ; EndIf ;if verbose is checked If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then GUICtrlSetData($Edit1, "Copying file: " & $Array[$i] & " to " & $Destination & @CRLF, 1) ;GuiCtrlSetData($Edit1, "Attrib is:" & FileGetAttrib($Array[$i]) & @CRLF & @CRLF, 1) ;copy the files ;sleep(10) ;$smeg = StringTrimLeft ($array[$i],2) ;MsgBox(4096,"",$Destination & $smeg) ;Exit $coperr = FileCopy($Array[$i], $Destination) if $coperr = 0 then GUICtrlSetData($Edit1,"ERROR copying over : " & $Array[$i] & @CRLF, 1) ;MsgBox(4096,"Error Copying File", $Array[$i]); ;Run(@ComSpec & " /c " & "xcopy " & $Array[$i] & " " & $Destination & " /e /y /c /h", "", @SW_HIDE) ProgressSet(Round(100 - ($i / $array[0] * 100), 1), _ StringFormat("%4.1f percent done", Round($i / $array[0] * 100, 1)), _ "No. of files left to copy = " & $array[0] - $i) Next Next ProgressOff ( ) GUICtrlSetData($Edit1, @CRLF & @CRLF & "****************** Copying now Completed ************************: " & @CRLF, 1) $Arraycheck = _RecFileListToArray($Destination, '*.pdf; *.xls; *.doc; *.mdb', 1, 1, 1, 2) GUICtrlSetData($Edit1, @CRLF & @CRLF & "Total number of files found during search: " & $numfound & @CRLF, 1) GUICtrlSetData($Edit1, @CRLF & "Total Number of files in backup directory: " & $Arraycheck[0] & @CRLF, 1) GUICtrlSetData($Edit1,"Anomalies could be files that havent copied over or files already in backup folder" & @CRLF, 1) ;GUICtrlSetData($Edit1, @CRLF & @CRLF & "****************** Errors - If any ************************: " & @CRLF, 1) ;GUICtrlSetData($Edit1, @CRLF & $coperrmsg, 1) ;GUICtrlSetData($Edit1, @CRLF & @CRLF & "****************** End of Erros ************************: " & @CRLF, 1) ReDim $avArray[1] $avArray[0] = 0 $numfound = 0 EndFunc func _Addfolder() Local $seladdfol = FileSelectFolder("Choose a folder.", "") If @error Or Not $seladdfol Then Return If Not FileExists($seladdfol) Then Return GUICtrlSetData($Edit1, "Folder Added: " & $seladdfol & @CRLF, 1) _ArrayAdd($avArray, $seladdfol) $avArray[0] = UBound($avArray) - 1 #cs _ArrayDisplay($avArray, "$avArray BEFORE _ArrayAdd()") $seladdfol = FileSelectFolder("Choose a folder.", "") ;MsgBox(4096,"seladdfolder",$seladdfol) _ArrayAdd($avArray, $seladdfol) GuiCtrlSetData($Edit1, "Folder Added: " & $seladdfol & @CRLF, 1) #ce EndFunc ;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #INDEX# ======================================================================================================================= ; Title .........: _RecFileListToArray ; AutoIt Version : v3.3.1.1 or higher ; Language ......: English ; Description ...: Lists files and\or folders in specified path with optional recursion to defined level and result sorting ; Note ..........: ; Author(s) .....: Melba23 ; Remarks .......: - Modified Array.au3 functions - credit: Jos van der Zande, LazyCoder, Tylo, Ultima, SolidSnake and gcriaco ; - SRE patterns - credit: various forum members and Spiff59 in particular ; - Despite the name, this UDF is iterative, not recursive ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _RecFileListToArray: Lists files and\or folders in a specified path with optional recursion to defined level and result sorting ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; _RFLTA_ListToMask ......; Convert include/exclude lists to SRE format ; _RFLTA_AddToList .......; Add element to list which is resized if necessary ; _RFLTA_AddFileLists ....; Add internal lists after resizing and optional sorting ; _RFLTA_FileListSearch ..; Search file match list for files associated with a folder ; _RFLTA_ArraySort .......; Wrapper for QuickSort function ; _RFLTA_QuickSort .......: Recursive array sort ; _RFLTA_ArrayConcatenate : Join 2 arrays ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _RecFileListToArray ; Description ...: Lists files and\or folders in a specified path with optional recursion to defined level and result sorting ; Syntax.........: _RecFileListToArray($sPath[, $sInclude_List = "*"[, $iReturn = 0[, $iRecur = 0[, $iSort = 0[, $iReturnPath = 1[, $sExclude_List = ""[, $sExclude_List_Folder]]]]]]]) ; Parameters ....: $sPath - Initial path used to generate filelist. If path ends in \ then folders will be returned with an ending \ ; $sInclude_List - Optional: filter for included results (default "*"). Multiple filters must be separated by ";" ; $iReturn - Optional: specifies whether to return files, folders or both ; |$iReturn = 0 - Return both files and folders (Default) ; If non-recursive Include/Exclude_List applies to files and folders ; If recursive Include/Exclude_List applies to files only, all folders are searched unless excluded using $sExclude_List_Folder ; |$iReturn = 1 - Return files only - Include/Exclude_List applies to files only, all folders searched if recursive ; |$iReturn = 2 - Return folders only - Include/Exclude_List applies to folders only for searching and return ; $iRecur - Optional: specifies whether to search recursively in subfolders and to what level ; |$iRecur = 1 - Search in all subfolders (unlimited recursion) ; |$iRecur = 0 - Do not search in subfolders (Default) ; |$iRecur = Negative integer - Search in subfolders to specified depth ; $iSort - Optional: sort ordered in alphabetical and depth order ; |$iSort = 0 - Not sorted (Default) ; |$iSort = 1 - Sorted ; |$iSort = 2 - Sorted with faster algorithm (assumes files sorted within each folder - requires NTFS drive) ; $iReturnPath - Optional: specifies displayed path of results ; |$iReturnPath = 0 - File/folder name only ; |$iReturnPath = 1 - Relative to initial path (Default) ; |$iReturnPath = 2 - Full path included ; $sExclude_List - Optional: filter for excluded results (default ""). Multiple filters must be separated by ";" ; $sExclude_List_Folder - Optional: only used if $iReturn = 0 AND $iRecur = 1 to exclude folders matching the filter ; Requirement(s).: v3.3.1.1 or higher ; Return values .: Success: One-dimensional array made up as follows: ; |$array[0] = Number of Files\Folders returned ; |$array[1] = 1st File\Folder ; |$array[2] = 2nd File\Folder ; |... ; |$array[n] = nth File\Folder ; Failure: Null string and @error = 1 with @extended set as follows: ; |1 = Path not found or invalid ; |2 = Invalid $sInclude_List ; |3 = Invalid $iReturn ; |4 = Invalid $iRecur ; |5 = Invalid $iSort ; |6 = Invalid $iReturnPath ; |7 = Invalid $sExclude_List ; |8 = Invalid $sExclude_List_Folder ; |9 = No files/folders found ; Author ........: Melba23 ; Remarks .......: Compatible with existing _FileListToArray syntax ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _RecFileListToArray($sInitialPath, $sInclude_List = "*", $iReturn = 0, $iRecur = 0, $iSort = 0, $iReturnPath = 1, $sExclude_List = "", $sExclude_List_Folder = "") Local $asReturnList[100] = [0], $asFileMatchList[100] = [0], $asRootFileMatchList[100] = [0], $asFolderMatchList[100] = [0], $asFolderSearchList[100] = [1] Local $sFolderSlash = "", $iMaxLevel, $sInclude_File_Mask, $sExclude_File_Mask, $sInclude_Folder_Mask = ".+", $sExclude_Folder_Mask = ":" Local $hSearch, $fFolder, $sRetPath = "", $sCurrentPath, $sName Local $asFolderFileSectionList[100][2] = [[0, 0]], $sFolderToFind, $iFileSectionStartIndex, $iFileSectionEndIndex ; Check for valid path If Not FileExists($sInitialPath) Then Return SetError(1, 1, "") ; Check if folders should have trailing \ and ensure that initial path does have one If StringRight($sInitialPath, 1) = "\" Then $sFolderSlash = "\" Else $sInitialPath = $sInitialPath & "\" EndIf ; Add path to folder search list $asFolderSearchList[1] = $sInitialPath ; Check for valid recur value If $iRecur > 1 Or Not IsInt($iRecur) Then Return SetError(1, 4, "") ; If required, determine \ count for max recursive level setting If $iRecur < 0 Then StringReplace($sInitialPath, "\", "", 2) $iMaxLevel = @extended - $iRecur EndIf ; Create Include mask for files If $sInclude_List = "*" Then $sInclude_File_Mask = ".+" Else If Not _RFLTA_ListToMask($sInclude_File_Mask, $sInclude_List) Then Return SetError(1, 2, "") EndIf ; Set Include mask for folders Switch $iReturn Case 0 ; Folders affected by mask if not recursive Switch $iRecur Case 0 ; Folders match mask for compatibility $sInclude_Folder_Mask = $sInclude_File_Mask ;Case Else ; All folders match EndSwitch ;Case 1 ; All folders match Case 2 ; Folders affected by mask $sInclude_Folder_Mask = $sInclude_File_Mask EndSwitch ; Create Exclude List mask for files If $sExclude_List = "" Then $sExclude_File_Mask = ":" ; Set unmatchable mask Else If Not _RFLTA_ListToMask($sExclude_File_Mask, $sExclude_List) Then Return SetError(1, 7, "") EndIf ; Set Exclude mask for folders Switch $iReturn Case 0 ; Folders affected by mask if not recursive Switch $iRecur Case 0 ; Folders match mask for compatibility $sExclude_Folder_Mask = $sExclude_File_Mask Case Else ; Exclude defined folders as set in extended If $sExclude_List_Folder <> "" Then If Not _RFLTA_ListToMask($sExclude_Folder_Mask, $sExclude_List_Folder) Then Return SetError(1, 8, "") EndIf EndSwitch ;Case 1 ; All folders match Case 2 ; Folders affected by normal mask $sExclude_Folder_Mask = $sExclude_File_Mask EndSwitch ; Verify other parameters If Not ($iReturn = 0 Or $iReturn = 1 Or $iReturn = 2) Then Return SetError(1, 3, "") If Not ($iSort = 0 Or $iSort = 1 Or $iSort = 2) Then Return SetError(1, 5, "") If Not ($iReturnPath = 0 Or $iReturnPath = 1 Or $iReturnPath = 2) Then Return SetError(1, 6, "") ; Search within listed folders While $asFolderSearchList[0] > 0 ; Set path to search $sCurrentPath = $asFolderSearchList[$asFolderSearchList[0]] ; Reduce folder search list count $asFolderSearchList[0] -= 1 ; Determine return path to add to file/folder name Switch $iReturnPath ; Case 0 ; Name only ; Leave as "" Case 1 ;Relative to initial path $sRetPath = StringReplace($sCurrentPath, $sInitialPath, "") Case 2 ; Full path $sRetPath = $sCurrentPath EndSwitch ; Get search handle $hSearch = FileFindFirstFile($sCurrentPath & "*") ; If sorting files and folders with paths then store folder name and position of associated files in list If $iReturn = 0 And $iSort And $iReturnPath Then _RFLTA_AddToList($asFolderFileSectionList, $sRetPath, $asFileMatchList[0] + 1) EndIf ; If folder empty move to next in list If $hSearch = -1 Then ContinueLoop EndIf ; Search folder While 1 $sName = FileFindNextFile($hSearch) ; Check for end of folder If @error Then ExitLoop EndIf ; Set subfolder flag - @extended set in 3.3.1.1 + $fFolder = @extended ; If folder then check whether to add to search list If $fFolder Then Select Case $iRecur < 0 ; Check recur depth StringReplace($sCurrentPath, "\", "", 0, 2) If @extended < $iMaxLevel Then ContinueCase ; Check if matched to masks EndIf Case $iRecur = 1 ; Full recur If Not StringRegExp($sName, $sExclude_Folder_Mask) Then ; Add folder unless excluded _RFLTA_AddToList($asFolderSearchList, $sCurrentPath & $sName & "\") EndIf ; Case $iRecur = 0 ; Never add ; Do nothing EndSelect EndIf If $iSort Then ; Save in relevant folders for later sorting If $fFolder Then If StringRegExp($sName, $sInclude_Folder_Mask) And Not StringRegExp($sName, $sExclude_Folder_Mask) Then _RFLTA_AddToList($asFolderMatchList, $sRetPath & $sName & $sFolderSlash) EndIf Else If StringRegExp($sName, $sInclude_File_Mask) And Not StringRegExp($sName, $sExclude_File_Mask) Then ; Select required list for files If $sCurrentPath = $sInitialPath Then _RFLTA_AddToList($asRootFileMatchList, $sRetPath & $sName) Else _RFLTA_AddToList($asFileMatchList, $sRetPath & $sName) EndIf EndIf EndIf Else ; Save directly in return list If $fFolder Then If $iReturn <> 1 And StringRegExp($sName, $sInclude_Folder_Mask) And Not StringRegExp($sName, $sExclude_Folder_Mask) Then _RFLTA_AddToList($asReturnList, $sRetPath & $sName & $sFolderSlash) EndIf Else If $iReturn <> 2 And StringRegExp($sName, $sInclude_File_Mask) And Not StringRegExp($sName, $sExclude_File_Mask) Then _RFLTA_AddToList($asReturnList, $sRetPath & $sName) EndIf EndIf EndIf WEnd ; Close current search FileClose($hSearch) WEnd If $iSort Then ; Check if any file/folders have been added depending on required return Switch $iReturn Case 0 ; If no folders then number of files is immaterial If $asRootFileMatchList[0] = 0 And $asFolderMatchList[0] = 0 Then Return SetError(1, 9, "") Case 1 If $asRootFileMatchList[0] = 0 And $asFileMatchList[0] = 0 Then Return SetError(1, 9, "") Case 2 If $asFolderMatchList[0] = 0 Then Return SetError(1, 9, "") EndSwitch Switch $iReturn Case 2 ; Folders only ; Correctly size folder match list ReDim $asFolderMatchList[$asFolderMatchList[0] + 1] ; Copy size folder match array $asReturnList = $asFolderMatchList ; Simple sort list _RFLTA_ArraySort($asReturnList) Case 1 ; Files only If $iReturnPath = 0 Then ; names only so simple sort suffices ; Combine file match lists _RFLTA_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList) ; Simple sort combined file list _RFLTA_ArraySort($asReturnList) Else ; Combine sorted file match lists _RFLTA_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList, 1) EndIf Case 0 ; Both files and folders If $iReturnPath = 0 Then ; names only so simple sort suffices ; Combine file match lists _RFLTA_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList) ; Set correct count for folder add $asReturnList[0] += $asFolderMatchList[0] ; Resize and add file match array ReDim $asFolderMatchList[$asFolderMatchList[0] + 1] _RFLTA_ArrayConcatenate($asReturnList, $asFolderMatchList) ; Simple sort final list _RFLTA_ArraySort($asReturnList) Else ; Size return list Local $asReturnList[$asFileMatchList[0] + $asRootFileMatchList[0] + $asFolderMatchList[0] + 1] $asReturnList[0] = $asFileMatchList[0] + $asRootFileMatchList[0] + $asFolderMatchList[0] ; Sort root file list _RFLTA_ArraySort($asRootFileMatchList, 1, $asRootFileMatchList[0]) ; Add the sorted root files at the top For $i = 1 To $asRootFileMatchList[0] $asReturnList[$i] = $asRootFileMatchList[$i] Next ; Set next insertion index Local $iNextInsertionIndex = $asRootFileMatchList[0] + 1 ; Sort folder list _RFLTA_ArraySort($asFolderMatchList, 1, $asFolderMatchList[0]) ; Work through folder list For $i = 1 To $asFolderMatchList[0] ; Format folder name for search If $sFolderSlash Then $sFolderToFind = $asFolderMatchList[$i] Else $sFolderToFind = $asFolderMatchList[$i] & "\" EndIf ; Find folder in FolderFileSectionList For $j = 1 To $asFolderFileSectionList[0][0] If $sFolderToFind = $asFolderFileSectionList[$j][0] Then ExitLoop Next ; Set file list indexes $iFileSectionStartIndex = $asFolderFileSectionList[$j][1] If $j = $asFolderFileSectionList[0][0] Then $iFileSectionEndIndex = $asFileMatchList[0] Else $iFileSectionEndIndex = $asFolderFileSectionList[$j + 1][1] - 1 EndIf ; Sort files if required If $iSort = 1 Then _RFLTA_ArraySort($asFileMatchList, $iFileSectionStartIndex, $iFileSectionEndIndex) EndIf ; Add folder to return list $asReturnList[$iNextInsertionIndex] = $asFolderMatchList[$i] $iNextInsertionIndex += 1 ; Add files to return list For $j = $iFileSectionStartIndex To $iFileSectionEndIndex $asReturnList[$iNextInsertionIndex] = $asFileMatchList[$j] $iNextInsertionIndex += 1 Next Next EndIf EndSwitch Else ; No sort ; Check if any file/folders have been added If $asReturnList[0] = 0 Then Return SetError(1, 9, "") ; Remove any unused return list elements from last ReDim ReDim $asReturnList[$asReturnList[0] + 1] EndIf Return $asReturnList EndFunc ;==>_RecFileListToArray ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_ListToMask ; Description ...: Convert include/exclude lists to SRE format ; Syntax ........: _RFLTA_ListToMask(ByRef $sMask, $sList) ; Parameters ....: $asMask - Include/Exclude mask to create ; $asList - Include/Exclude list to convert ; Return values .: Success: 1 ; Failure: 0 ; Author ........: SRE patterns developed from those posted by various forum members and Spiff59 in particular ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_ListToMask(ByRef $sMask, $sList) ; Check for invalid characters within list If StringRegExp($sList, "[url="file://\\|/|:|\<|\>|\"]\\|/|:|\<|\>|\[/url]|") Then Return 0 ; Strip WS and insert | for ; $sList = StringReplace(StringStripWS(StringRegExpReplace($sList, "\s*;\s*", ";"), 3), ";", "|") ; Convert to SRE pattern $sList = StringReplace(StringReplace(StringRegExpReplace($sList, "[][$^.{}()+\-]", "[url="file://\\$0"]\\$0[/url]"), "?", "."), "*", ".*?") ; Add prefix and suffix $sMask = "(?i)^(" & $sList & ")\z" Return 1 EndFunc ;==>_RFLTA_ListToMask ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_AddToList ; Description ...: Add element to [?] or [?][2] list which is resized if necessary ; Syntax ........: _RFLTA_AddToList(ByRef $asList, $vValue_0, [$vValue_1]) ; Parameters ....: $aList - List to be added to ; $vValue_0 - Value to add (to [0] element in [?][2] array if $vValue_1 exists) ; $vValue_1 - Value to add to [1] element in [?][2] array (optional) ; Return values .: None - array modified ByRef ; Author ........: Melba23 ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_AddToList(ByRef $aList, $vValue_0, $vValue_1 = -1) If $vValue_1 = -1 Then ; [?] array ; Increase list count $aList[0] += 1 ; Double list size if too small (fewer ReDim needed) If UBound($aList) <= $aList[0] Then ReDim $aList[UBound($aList) * 2] ; Add value $aList[$aList[0]] = $vValue_0 Else ; [?][2] array $aList[0][0] += 1 If UBound($aList) <= $aList[0][0] Then ReDim $aList[UBound($aList) * 2][2] $aList[$aList[0][0]][0] = $vValue_0 $aList[$aList[0][0]][1] = $vValue_1 EndIf EndFunc ;==>_RFLTA_AddToList ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_AddFileLists ; Description ...: Add internal lists after resizing and optional sorting ; Syntax ........: _RFLTA_AddFileLists(ByRef $asTarget, $asSource_1, $asSource_2[, $iSort = 0]) ; Parameters ....: $asReturnList - Base list ; $asRootFileMatchList - First list to add ; $asFileMatchList - Second list to add ; $iSort - (Optional) Whether to sort lists before adding ; |$iSort = 0 (Default) No sort ; |$iSort = 1 Sort in descending alphabetical order ; Return values .: None - array modified ByRef ; Author ........: Melba23 ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_AddFileLists(ByRef $asTarget, $asSource_1, $asSource_2, $iSort = 0) ; Correctly size root file match array ReDim $asSource_1[$asSource_1[0] + 1] ; Simple sort root file match array if required If $iSort = 1 Then _RFLTA_ArraySort($asSource_1) ; Copy root file match array $asTarget = $asSource_1 ; Add file match count $asTarget[0] += $asSource_2[0] ; Correctly size file match array ReDim $asSource_2[$asSource_2[0] + 1] ; Simple sort file match array if required If $iSort = 1 Then _RFLTA_ArraySort($asSource_2) ; Add file match array _RFLTA_ArrayConcatenate($asTarget, $asSource_2) EndFunc ;==>_RFLTA_AddFileLists ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_FileListSearch ; Description ...: Search file array for beginning and end indices of folder associated files ; Syntax ........: _RFLTA_FileListSearch(Const ByRef $avArray, $vValue) ; Parameters ....: $avArray - Array to search ($asFileMatchList) ; $vValue - Value to search for (Folder name from $asFolderMatchList) ; $iIndex - Index to begin search (search down from here - and then from here to top if not found) ; $sSlash - \ if folder names end in \ - else empty string ; Return values .: Success: Array holding top and bottom indices of folder associated files ; Failure: Returns -1 ; Author ........: Melba23 ; Modified.......: ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_FileListSearch(Const ByRef $avArray, $vValue, $iIndex, $sSlash) Local $aRet[2] ; Add final \ if required If Not $sSlash Then $vValue &= "\" ; Start by getting top match - search down from start index For $i = $iIndex To $avArray[0] ; SRE gives path less filename If StringRegExpReplace($avArray[$i], "(^.*\\)(.*)", "\1") = $vValue Then ExitLoop Next If $i > $avArray[0] Then ; No match found so look from start index upwards If $iIndex = $avArray[0] Then $iIndex -= 1 For $i = $iIndex + 1 To 1 Step -1 If StringRegExpReplace($avArray[$i], "(^.*\\)(.*)", "\1") = $vValue Then ExitLoop Next ; If still no match - return " nothing found" for empty folder If $i = 0 Then Return SetError(1, 0, "") ; Set index of bottom file $aRet[1] = $i ; Now look for top match For $i = $aRet[1] To 1 Step -1 If StringRegExpReplace($avArray[$i], "(^.*\\)(.*)", "\1") <> $vValue Then ExitLoop Next ; Set top match $aRet[0] = $i + 1 Else ; Set index of top associated file $aRet[0] = $i ; Now look for bottom match - find first file which does not match For $i = $aRet[0] To $avArray[0] If StringRegExpReplace($avArray[$i], "(^.*\\)(.*)", "\1") <> $vValue Then ExitLoop Next ; Set bottom match $aRet[1] = $i - 1 EndIf Return $aRet EndFunc ;==>_RFLTA_FileListSearch ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_ArraySort ; Description ...: Wrapper for QuickSort function ; Syntax ........: _RFLTA_ArraySort(ByRef $avArray) ; Parameters ....: $avArray - Array to sort ; $iStart - Index to start sort ; $iEnd - Index to end sort ; Return values .: None - array modified ByRef ; Author ........: Jos van der Zande, LazyCoder, Tylo, Ultima ; Modified.......: Melba23 ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_ArraySort(ByRef $avArray, $iStart = 1, $iEnd = -99) If $iEnd = -99 Then $iEnd = UBound($avArray) - 1 _RFLTA_QuickSort($avArray, $iStart, $iEnd) EndFunc ;==>_RFLTA_ArraySort ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_QuickSort ; Description ...: Recursive array sort ; Syntax ........: _RFLTA_QuickSort(ByRef $avArray, ByRef $iStart, ByRef $iEnd) ; Parameters ....: $avArray - Array to sort in descending alphabetical order ; $iStart - Start index ; $iEnd - End index ; Return values .: None - array modified ByRef ; Author ........: Jos van der Zande, LazyCoder, Tylo, Ultima ; Modified.......: Melba23 ; Remarks .......: This function is used internally by _RFLTA_ArraySort ; =============================================================================================================================== Func _RFLTA_QuickSort(ByRef $avArray, ByRef $iStart, ByRef $iEnd) Local $vTmp If ($iEnd - $iStart) < 15 Then Local $i, $j, $vCur For $i = $iStart + 1 To $iEnd $vTmp = $avArray[$i] If IsNumber($vTmp) Then For $j = $i - 1 To $iStart Step -1 $vCur = $avArray[$j] If ($vTmp >= $vCur And IsNumber($vCur)) Or (Not IsNumber($vCur) And StringCompare($vTmp, $vCur) >= 0) Then ExitLoop $avArray[$j + 1] = $vCur Next Else For $j = $i - 1 To $iStart Step -1 If (StringCompare($vTmp, $avArray[$j]) >= 0) Then ExitLoop $avArray[$j + 1] = $avArray[$j] Next EndIf $avArray[$j + 1] = $vTmp Next Return EndIf Local $L = $iStart, $R = $iEnd, $vPivot = $avArray[Int(($iStart + $iEnd) / 2)], $fNum = IsNumber($vPivot) Do If $fNum Then While ($avArray[$L] < $vPivot And IsNumber($avArray[$L])) Or (Not IsNumber($avArray[$L]) And StringCompare($avArray[$L], $vPivot) < 0) $L += 1 WEnd While ($avArray[$R] > $vPivot And IsNumber($avArray[$R])) Or (Not IsNumber($avArray[$R]) And StringCompare($avArray[$R], $vPivot) > 0) $R -= 1 WEnd Else While (StringCompare($avArray[$L], $vPivot) < 0) $L += 1 WEnd While (StringCompare($avArray[$R], $vPivot) > 0) $R -= 1 WEnd EndIf If $L <= $R Then $vTmp = $avArray[$L] $avArray[$L] = $avArray[$R] $avArray[$R] = $vTmp $L += 1 $R -= 1 EndIf Until $L > $R _RFLTA_QuickSort($avArray, $iStart, $R) _RFLTA_QuickSort($avArray, $L, $iEnd) EndFunc ;==>_RFLTA_QuickSort ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_ArrayConcatenate ; Description ...: Joins 2 arrays ; Syntax ........: _RFLTA_ArrayConcatenate(ByRef $avArrayTarget, Const ByRef $avArraySource) ; Parameters ....: $avArrayTarget - Base array ; $avArraySource - Array to add from element 1 onwards ; Return values .: None - array modified ByRef ; Author ........: Ultima ; Modified.......: Melba23 ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_ArrayConcatenate(ByRef $avArrayTarget, Const ByRef $avArraySource) Local $iUBoundTarget = UBound($avArrayTarget) - 1, $iUBoundSource = UBound($avArraySource) ReDim $avArrayTarget[$iUBoundTarget + $iUBoundSource] For $i = 1 To $iUBoundSource - 1 $avArrayTarget[$iUBoundTarget + $i] = $avArraySource[$i] Next EndFunc ;==>_RFLTA_ArrayConcatenate
-
Hi Thanks For the help of everyone who replied. Got it sorted now. ripdad amendments worked like a charm Thanks once again jamie
-
Separating numeric from everything else
engjcowi replied to jbwhite's topic in AutoIt General Help and Support
have a look at isnumber() and possibly use with an if statement -
Hi guys Im trying to create a file backup program. This will backup the documents directory and others automatically. I would like to give the option of selecting additional folders and have the program search for specific file types. Ive created a basic gui with an edit box to show whats going on. but im having an issue. I think this line is the issue For $s = 1 To Ubound($avArray) - 1 in the smeg function (lol sorry) Whenever i run the prog itcopies the files over with no problem however the gui freezes at a certain point and only a certain amount of the files copied get listed. I tried using only a small amount of files to copy so i could have a completed message but again the gui seems to freeze. i tried changing the line above to For $s = 1 To $avArray and For $s = 1 To $avArray[1] and to For $s = 1 To 100 but i just cant seem to get it right. could someone please take a look at my array and see if im doing something wrong or missing something please. thank you jamie #RequireAdmin #NoTrayIcon #include <GUIConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiEdit.au3> #include <Array.au3> local $Destination, $seladdfol Local $avArray[1] $Form1 = GUICreate("Backup", 622, 450, 193, 125) $Label1 = GUICtrlCreateLabel("Backup Destination:", 4, 12, 175, 19, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Input1 = GUICtrlCreateInput("", 184, 11, 353, 23) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Button1 = GUICtrlCreateButton("Browse", 540, 10, 75, 25, 0) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Edit1 = GUICtrlCreateEdit("", 4, 40, 613, 369, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetBkColor(-1, 0x000000) _GUICtrlEdit_SetReadOnly($Edit1, True) $BACKUP = GUICtrlCreateButton("Backup", 460, 416, 75, 25, 0) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Addfol = GUICtrlCreateButton("Add Folder", 360, 416, 85, 25, 0) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Exit = GUICtrlCreateButton("Exit", 540, 416, 75, 25, 0) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $Checkbox1 = GUICtrlCreateCheckbox("Compress Backup", 8, 420, 157, 17) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exitcode() Case $Exit _Exitcode() Case $Button1 _BackupDestination() Case $Addfol _Addfolder() Case $BACKUP ;MsgBox(4096,"",$Destination) ;_ArrayDisplay($avArray, "$avArray AFTER _ArrayAdd()") smeg() GuiCtrlSetData($Edit1,@CRLF & @CRLF, 1) GuiCtrlSetData($Edit1, "Completed" & @CRLF, 1) EndSwitch WEnd Func _Exitcode() GUIDelete() Exit EndFunc Func _BackupDestination() $Destination = FileSelectFolder("Select backup destination", "" , 7) GUICtrlSetData($Input1 , $Destination) EndFunc func smeg() ;_ArrayDisplay($avArray, "$avArray ") For $s = 1 To Ubound($avArray) - 1 GuiCtrlSetData($Edit1, "Working on Folder: " & $avArray[$s] & @CRLF, 1) $Array = _RecFileListToArray($avArray[$s], '*.pdf; *.xls; *.doc; *.mdb', 1, 1, 1, 2) ;If Not @error Then _ArrayDisplay($Array, 'Matching Files in ' & $avArray[$s]) For $i = 1 To $Array[0] GuiCtrlSetData($Edit1, "Copying file: " & $Array[$i] & " to " & $Destination & @CRLF, 1) FileCopy($Array[$i], $Destination) Next Next EndFunc func _Addfolder() ;_ArrayDisplay($avArray, "$avArray BEFORE _ArrayAdd()") $seladdfol = FileSelectFolder("Choose a folder.", "") ;MsgBox(4096,"seladdfolder",$seladdfol) _ArrayAdd($avArray, $seladdfol) GuiCtrlSetData($Edit1, "Folder Added: " & $seladdfol & @CRLF, 1) EndFunc ; #INDEX# ======================================================================================================================= ; Title .........: _RecFileListToArray ; AutoIt Version : v3.3.1.1 or higher ; Language ......: English ; Description ...: Lists files and\or folders in a specified path with optional recursion and sort. ; Remarks .......: ; Note ..........: ; Author(s) .....: Melba23 ; Remark ........: Modified Array.au3 functions - credit: Jos van der Zande, LazyCoder, Tylo, Ultima, SolidSnake and gcriaco ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _RecFileListToArray: Lists files and\or folders in a specified path with optional recursion and sort. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; _RFLTA_AddFileLists ....; Add element to list which is resized if necessary ; _RFLTA_AddToList .......; Add internal arrays after resizing and optional sorting ; _RFLTA_ArraySearch .....; Search array for partial match ; _RFLTA_ArraySort .......; Wrapper for QuickSort function ; _RFLTA_QuickSort .......: Recursive array sort ; _RFLTA_ArrayConcatenate : Join 2 arrays ; _RFLTA_ArrayInsert .....: Insert element into array ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _RecFileListToArray ; Description ...: Lists files and\or folders in a specified path with optional recursion and sort. Compatible with existing _FileListToArray syntax ; Syntax.........: _RecFileListToArray($sPath[, $sInclude_List = "*"[, $iReturn = 0[, $fRecur = 0[, $fSort = 0[, $sReturnPath = 1[, $sExclude_List = ""]]]]]]) ; Parameters ....: $sPath - Initial path used to generate filelist. If path ends in \ then folders will be returned with an ending \ ; $sInclude_List - Optional: the filter for included results (default is "*"). Multiple filters must be separated by ";" ; $iReturn - Optional: specifies whether to return files, folders or both ; |$iReturn = 0 (Default) Return both files and folders ; |$iReturn = 1 Return files only ; |$iReturn = 2 Return folders only ; $fRecur - Optional: specifies whether to search recursively in subfolders ; |$fRecur = 0 (Default) Do not search in subfolders ; |$fRecur = 1 Search in subfolders ; $fSort - Optional: sort ordered in alphabetical and depth order ; |$fSort = 0 (Default) Not sorted ; |$fSort = 1 Sorted ; $sReturnPath - Optional: specifies displayed path of results ; |$sReturnPath = 0 File/folder name only ; |$sReturnPath = 1 (Default) Initial path not included ; |$sReturnPath = 2 Initial path included ; $sExclude_List - Optional: the filter for excluded results (default is ""). Multiple filters must be separated by ";" ; Requirement(s).: v3.3.1.1 or higher ; Return values .: Success: One-dimensional array made up as follows: ; |$array[0] = Number of Files\Folders returned ; |$array[1] = 1st File\Folder ; |$array[2] = 2nd File\Folder ; |... ; |$array[n] = nth File\Folder ; Failure: Null string and @error = 1 with @extended set as follows: ; |1 = Path not found or invalid ; |2 = Invalid $sInclude_List ; |3 = Invalid $iReturn ; |4 = Invalid $fRecur ; |5 = Invalid $fSort ; |6 = Invalid $iFullPath ; |7 = Invalid $sExclude_List ; |8 = No files/folders found ; Author ........: Melba23 using SRE code from forums ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _RecFileListToArray($sInitialPath, $sInclude_List = "*", $iReturn = 0, $fRecur = 0, $fSort = 0, $sReturnPath = 1, $sExclude_List = "") Local $asReturnList[100] = [0], $asFileMatchList[100] = [0], $asRootFileMatchList[100] = [0], $asFolderMatchList[100] = [0], $asFolderList[100] = [1] Local $sFolderSlash = "", $sInclude_List_Mask, $sExclude_List_Mask, $hSearch, $fFolder, $sRetPath = "", $sCurrentPath, $sName ; Check valid path If Not FileExists($sInitialPath) Then Return SetError(1, 1, "") ; Check if folders should have trailing \ and ensure that $sInitialPath does have one If StringRight($sInitialPath, 1) = "\" Then $sFolderSlash = "\" Else $sInitialPath = $sInitialPath & "\" EndIf ; Add path to folder list $asFolderList[1] = $sInitialPath ; Determine Filter mask for SRE check If $sInclude_List = "*" Then $sInclude_List_Mask = ".+" ; Set mask to exclude base folder with NULL name Else If StringRegExp($sInclude_List, "\\|/|:|\<|\>|\|") Then Return SetError(1, 2, "") ; Check For invalid characters within $sInclude_List $sInclude_List = StringReplace(StringStripWS(StringRegExpReplace($sInclude_List, "\s*;\s*", ";"), 3), ";", "|") ; Strip WS and insert | for ; $sInclude_List_Mask = "(?i)^" & StringReplace(StringReplace(StringReplace($sInclude_List, ".", "\."), "*", ".*"), "?", ".") & "\z" ; Convert SRE pattern EndIf ; Determine Exclude mask for SRE check If $sExclude_List = "" Then $sExclude_List_Mask = ":" ; Set unmatchable mask Else If StringRegExp($sExclude_List, "\\|/|:|\<|\>|\|") Then Return SetError(1, 7, "") ; Check For invalid characters within $sInclude_List $sExclude_List = StringReplace(StringStripWS(StringRegExpReplace($sExclude_List, "\s*;\s*", ";"), 3), ";", "|") ; Strip WS and insert | for ; $sExclude_List_Mask = "(?i)^" & StringReplace(StringReplace(StringReplace($sExclude_List, ".", "\."), "*", ".*"), "?", ".") & "\z" ; Convert $sExclude_List to SRE pattern EndIf ; Verify other parameter values If Not ($iReturn = 0 Or $iReturn = 1 Or $iReturn = 2) Then Return SetError(1, 3, "") If Not ($fRecur = 0 Or $fRecur = 1) Then Return SetError(1, 4, "") If Not ($fSort = 0 Or $fSort = 1) Then Return SetError(1, 5, "") If Not ($sReturnPath = 0 Or $sReturnPath = 1 Or $sReturnPath = 2) Then Return SetError(1, 6, "") ; Search in listed folders While $asFolderList[0] > 0 ; Set path to search $sCurrentPath = $asFolderList[$asFolderList[0]] ; Reduce folder array count $asFolderList[0] -= 1 ; Determine return path to add to file/folder name Switch $sReturnPath ; Case 0 ; Name only ; Leave as "" Case 1 ; Initial path not included $sRetPath = StringReplace($sCurrentPath, $sInitialPath, "") Case 2 ; Initial path included $sRetPath = $sCurrentPath EndSwitch If $fSort Then ; Get folder name $sName = StringRegExpReplace(StringReplace($sCurrentPath, $sInitialPath, ""), "(.+?\\)*(.+?)(\\.*?(?!\\))", "$2") ; Get search handle $hSearch = FileFindFirstFile($sCurrentPath & "*") ; If folder empty move to next in list If $hSearch = -1 Then ContinueLoop ; Search folder While 1 $sName = FileFindNextFile($hSearch) ; Check for end of folder If @error Then ExitLoop ; Check for file - @extended set for subfolder in 3.3.1.1 + If @extended Then ; If recursive search, add subfolder to folder list If $fRecur Then _RFLTA_AddToList($asFolderList, $sCurrentPath & $sName & "\") ; Add folder name if matched against Include/Exclude masks If StringRegExp($sName, $sInclude_List_Mask) And Not StringRegExp($sName, $sExclude_List_Mask) Then _ _RFLTA_AddToList($asFolderMatchList, $sRetPath & $sName & $sFolderSlash) Else ; Add file name if matched against Include/Exclude masks If StringRegExp($sName, $sInclude_List_Mask) And Not StringRegExp($sName, $sExclude_List_Mask) Then If $sCurrentPath = $sInitialPath Then _RFLTA_AddToList($asRootFileMatchList, $sRetPath & $sName) Else _RFLTA_AddToList($asFileMatchList, $sRetPath & $sName) EndIf EndIf EndIf WEnd ; Close current search FileClose($hSearch) Else ; No sorting required ; Get search handle $hSearch = FileFindFirstFile($sCurrentPath & "*") ; If folder empty move to next in list If $hSearch = -1 Then ContinueLoop ; Search folder While 1 $sName = FileFindNextFile($hSearch) ; Check for end of folder If @error Then ExitLoop ; Check for subfolder - @extended set in 3.3.1.1 + $fFolder = @extended ; If recursive search, add subfolder to folder list If $fRecur And $fFolder Then _RFLTA_AddToList($asFolderList, $sCurrentPath & $sName & "\") ; Check file/folder type against required return value and file/folder name against Include/Exclude masks If $fFolder + $iReturn <> 2 And StringRegExp($sName, $sInclude_List_Mask) And Not StringRegExp($sName, $sExclude_List_Mask) Then ; Add final "\" to folders If $fFolder Then $sName &= $sFolderSlash _RFLTA_AddToList($asReturnList, $sRetPath & $sName) EndIf WEnd ; Close current search FileClose($hSearch) EndIf WEnd If $fSort Then ; Check if any file/folders have been added If $asRootFileMatchList[0] = 0 And $asFileMatchList[0] = 0 And $asFolderMatchList[0] = 0 Then Return SetError(1, 8, "") Switch $iReturn Case 2 ; Folders only ; Correctly size folder match list ReDim $asFolderMatchList[$asFolderMatchList[0] + 1] ; Copy size folder match array $asReturnList = $asFolderMatchList ; Simple sort list _RFLTA_ArraySort($asReturnList) Case 1 ; Files only If $sReturnPath = 0 Then ; names only so simple sort suffices ; Combine file match lists _RFLTA_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList) ; Simple sort combined file list _RFLTA_ArraySort($asReturnList) Else ; Combine sorted file match lists _RFLTA_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList, 1) EndIf Case 0 ; Both files and folders If $sReturnPath = 0 Then ; names only so simple sort suffices ; Combine file match lists _RFLTA_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList) ; Set correct count for folder add $asReturnList[0] += $asFolderMatchList[0] ; Resize and add file match array ReDim $asFolderMatchList[$asFolderMatchList[0] + 1] _RFLTA_ArrayConcatenate($asReturnList, $asFolderMatchList) ; Simple sort final list _RFLTA_ArraySort($asReturnList) Else ; Combine sorted file match lists _RFLTA_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList, 1) ; Add folder count $asReturnList[0] += $asFolderMatchList[0] ; Sort folder match list ReDim $asFolderMatchList[$asFolderMatchList[0] + 1] _RFLTA_ArraySort($asFolderMatchList) ; Now add folders in correct place Local $iLastIndex = $asReturnList[0] For $i = $asFolderMatchList[0] To 1 Step -1 ; Find first filename containing folder name Local $iIndex = _RFLTA_ArraySearch($asReturnList, $asFolderMatchList[$i]) If $iIndex = -1 Then ; Empty folder so insert immediately above previous _RFLTA_ArrayInsert($asReturnList, $iLastIndex, $asFolderMatchList[$i]) Else ; Insert folder at correct point above files _RFLTA_ArrayInsert($asReturnList, $iIndex, $asFolderMatchList[$i]) $iLastIndex = $iIndex EndIf Next EndIf EndSwitch Else ; No sort ; Check if any file/folders have been added If $asReturnList[0] = 0 Then Return SetError(1, 8, "") ; Remove any unused return list elements from last ReDim ReDim $asReturnList[$asReturnList[0] + 1] EndIf Return $asReturnList EndFunc ;==>_RecFileListToArray ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_AddToList ; Description ...: Add element to list which is resized if necessary ; Syntax ........: _RFLTA_AddToList(ByRef $asList, $sValue) ; Parameters ....: $asList - List to be added to ; $sValue - Value to add ; Return values .: None - array modified ByRef ; Author ........: Melba23 ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_AddToList(ByRef $asList, $sValue) ; Increase list count $asList[0] += 1 ; Double list size if too small (fewer ReDim needed) If UBound($asList) <= $asList[0] Then ReDim $asList[UBound($asList) * 2] ; Add value $asList[$asList[0]] = $sValue EndFunc ;==>_RFLTA_AddToList ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_AddFileLists ; Description ...: Add internal arrays after resizing and optional sorting ; Syntax ........: _RFLTA_AddFileLists(ByRef $asReturnList, $asRootFileMatchList, $asFileMatchList[, $iSort = 0]) ; Parameters ....: $asReturnList - Base list ; $asRootFileMatchList - First list to add ; $asFileMatchList - Second list to add ; $iSort - (Optional) Whether to sort lists before adding ; |$iSort = 0 (Default) No sort ; |$iSort = 1 Sort in descending alphabetical order ; Return values .: None - array modified ByRef ; Author ........: Melba23 ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_AddFileLists(ByRef $asReturnList, $asRootFileMatchList, $asFileMatchList, $iSort = 0) ; Correctly size root file match array ReDim $asRootFileMatchList[$asRootFileMatchList[0] + 1] ; Simple sort root file match array if required If $iSort = 1 Then _RFLTA_ArraySort($asRootFileMatchList) ; Copy root file match array $asReturnList = $asRootFileMatchList ; Add file match count $asReturnList[0] += $asFileMatchList[0] ; Correctly size file match array ReDim $asFileMatchList[$asFileMatchList[0] + 1] ; Simple sort file match array if required If $iSort = 1 Then _RFLTA_ArraySort($asFileMatchList) ; Add file match array _RFLTA_ArrayConcatenate($asReturnList, $asFileMatchList) EndFunc ;==>_RFLTA_AddFileLists ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_ArraySearch ; Description ...: Search array downwards for partial match ; Syntax ........: _RFLTA_ArraySearch(Const ByRef $avArray, $vValue) ; Parameters ....: $avArray - Array to search ; $vValue - PValue to search for ; Return values .: Success: Index of array in which element was found ; Failure: returns -1 ; Author ........: SolidSnake, gcriaco, Ultima ; Modified.......: Melba23 ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_ArraySearch(Const ByRef $avArray, $vValue) For $i = 1 To UBound($avArray) - 1 If StringInStr($avArray[$i], $vValue) > 0 Then Return $i Next Return -1 EndFunc ;==>_RFLTA_ArraySearch ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_ArraySort ; Description ...: Wrapper for QuickSort function ; Syntax ........: _RFLTA_ArraySort(ByRef $avArray) ; Parameters ....: $avArray - Array to sort ; $pNew_WindowProc - Pointer to new WindowProc ; Return values .: None - array modified ByRef ; Author ........: Jos van der Zande, LazyCoder, Tylo, Ultima ; Modified.......: Melba23 ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_ArraySort(ByRef $avArray) Local $iStart = 1, $iEnd = UBound($avArray) - 1 _RFLTA_QuickSort($avArray, $iStart, $iEnd) EndFunc ;==>_RFLTA_ArraySort ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_QuickSort ; Description ...: Recursive array sort ; Syntax ........: _RFLTA_QuickSort(ByRef $avArray, ByRef $iStart, ByRef $iEnd) ; Parameters ....: $avArray - Array to sort in descending alphabetical order ; $iStart - Start index ; $iEnd - End index ; Return values .: None - array modified ByRef ; Author ........: Jos van der Zande, LazyCoder, Tylo, Ultima ; Modified.......: Melba23 ; Remarks .......: This function is used internally by _RFLTA_ArraySort ; =============================================================================================================================== Func _RFLTA_QuickSort(ByRef $avArray, ByRef $iStart, ByRef $iEnd) Local $vTmp If ($iEnd - $iStart) < 15 Then Local $i, $j, $vCur For $i = $iStart + 1 To $iEnd $vTmp = $avArray[$i] If IsNumber($vTmp) Then For $j = $i - 1 To $iStart Step -1 $vCur = $avArray[$j] If ($vTmp >= $vCur And IsNumber($vCur)) Or (Not IsNumber($vCur) And StringCompare($vTmp, $vCur) >= 0) Then ExitLoop $avArray[$j + 1] = $vCur Next Else For $j = $i - 1 To $iStart Step -1 If (StringCompare($vTmp, $avArray[$j]) >= 0) Then ExitLoop $avArray[$j + 1] = $avArray[$j] Next EndIf $avArray[$j + 1] = $vTmp Next Return EndIf Local $L = $iStart, $R = $iEnd, $vPivot = $avArray[Int(($iStart + $iEnd) / 2)], $fNum = IsNumber($vPivot) Do If $fNum Then While ($avArray[$L] < $vPivot And IsNumber($avArray[$L])) Or (Not IsNumber($avArray[$L]) And StringCompare($avArray[$L], $vPivot) < 0) $L += 1 WEnd While ($avArray[$R] > $vPivot And IsNumber($avArray[$R])) Or (Not IsNumber($avArray[$R]) And StringCompare($avArray[$R], $vPivot) > 0) $R -= 1 WEnd Else While (StringCompare($avArray[$L], $vPivot) < 0) $L += 1 WEnd While (StringCompare($avArray[$R], $vPivot) > 0) $R -= 1 WEnd EndIf If $L <= $R Then $vTmp = $avArray[$L] $avArray[$L] = $avArray[$R] $avArray[$R] = $vTmp $L += 1 $R -= 1 EndIf Until $L > $R _RFLTA_QuickSort($avArray, $iStart, $R) _RFLTA_QuickSort($avArray, $L, $iEnd) EndFunc ;==>_RFLTA_QuickSort ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_ArrayConcatenate ; Description ...: Joins 2 arrays ; Syntax ........: _RFLTA_ArrayConcatenate(ByRef $avArrayTarget, Const ByRef $avArraySource) ; Parameters ....: $avArrayTarget - Base array ; $avArraySource - Array to add from element 1 onwards ; Return values .: None - array modified ByRef ; Author ........: Ultima ; Modified.......: Melba23 ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_ArrayConcatenate(ByRef $avArrayTarget, Const ByRef $avArraySource) Local $iUBoundTarget = UBound($avArrayTarget) - 1, $iUBoundSource = UBound($avArraySource) ReDim $avArrayTarget[$iUBoundTarget + $iUBoundSource] For $i = 1 To $iUBoundSource - 1 $avArrayTarget[$iUBoundTarget + $i] = $avArraySource[$i] Next EndFunc ;==>_RFLTA_ArrayConcatenate ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _RFLTA_ArrayInsert ; Description ...: Insert element into array ; Syntax ........: _RFLTA_ArrayInsert(ByRef $avArray, $iElement, $vValue = "") ; Parameters ....: $avArray - Array to modify ; $iElement - Index position for insertion ; $vValue - Value to insert ; Return values .: None - array modified ByRef ; Author ........: Jos van der Zande, Ultima ; Modified.......: Melba23 ; Remarks .......: This function is used internally by _RecFileListToArray ; =============================================================================================================================== Func _RFLTA_ArrayInsert(ByRef $avArray, $iElement, $vValue = "") Local $iUBound = UBound($avArray) + 1 ReDim $avArray[$iUBound] For $i = $iUBound - 1 To $iElement + 1 Step -1 $avArray[$i] = $avArray[$i - 1] Next $avArray[$iElement] = $vValue EndFunc ;==>_RFLTA_ArrayInsert