#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=BSM.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Fileversion=0.7.0.4
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GuiStatusBar.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <Array.au3>
#include <Date.au3>
#include <File.au3>
Global $iSRC = 'C:\', $iPRS = '(.*)', $iPRR = '\1', $iNRS = '(.*)', $iNRR = '\1', $iREC = False, $iTST = False
_GetIni()
#Region ### START Koda GUI section ### Form=
$StatusBar1 = _GUICtrlStatusBar_Create($guiBSM)
#EndRegion ### END Koda GUI section ###
ShellExecute('http://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm') MsgBox(48, 'BSM Error', 'Not a valid path') $output = ''
If $iPRS = '' Then $iPRS = '(.*)' If $iPRR = '' Then $iPRR = '\1' If $iNRS = '' Then $iNRS = '(.*)' If $iNRR = '' Then $iNRR = '\1'
_GUICtrlStatusBar_SetText($StatusBar1, 'Finding shortcuts')
$output = _FileListToArrayPlus
($iSRC, "*.lnk", 1, 0, "", 2, True) $output = _FileListToArrayPlus
($iSRC, "*.lnk", 1, 0, "", 2, False) MsgBox(48, 'BSM Error', 'No shortcuts found') IniWrite($inifile, 'Main', 'Folder', $iSRC) IniWrite($inifile, 'Main', 'PathSearch', $iPRS) IniWrite($inifile, 'Main', 'PathReplace', $iPRR) IniWrite($inifile, 'Main', 'NameSearch', $iNRS) IniWrite($inifile, 'Main', 'NameReplace', $iNRR) IniWrite($inifile, 'Main', 'XPos', $wPos[0]) IniWrite($inifile, 'Main', 'YPos', $wPos[1])
Local $j = 1, $target, $targetPath, $newTarget, $newWorking, $prg = 1, $fDScut = 0, $fDLog = '', $fCScut = 0, $fCLog = '', $max, $nMsg2
$max = $files[0]
_GUICtrlStatusBar_SetText($StatusBar1, 'Creating test output')
If $files[0] > 100 Then $max = 100 _GUICtrlStatusBar_SetText($StatusBar1, 'Processing ' & $max & ' shortcuts')
_ArrayDelete($files, $i)
$max -= 1
$i -= 1
$temp[$i][0] = $details[0]
$temp[$i][1] = $newTarget
$temp[0][0] = $i
If Not FileCreateShortcut($newTarget, $files[$i], $newWorking, $details[2], $details[3], $details[4], '', $details[5], $details[6]) Then $fCScut += 1
$fCLog &= $files[$i] & @CRLF $fDScut += 1
$fDLog &= $files[$i] & @CRLF $Percent = Round(($i / $max) * 100, 0) If $Percent <> $Percent_prev Then $Percent_prev = $Percent
_GUICtrlStatusBar_SetText($StatusBar1, 'Interrupted')
_GUICtrlStatusBar_SetText($StatusBar1, 'Finished: ' & Round(TimerDiff($start) / 1000, 1) & ' seconds')
_ArrayBox
($temp, 1, 'BSM Test Output', '|Old Shortcut Target|New Shortcut Target', True) _Log($fCLog, $fCScut, $fDLog, $fDScut, $files[0], $interrupt)
MsgBox(64, 'BSM Results', 'Total shortcuts: ' & $files[0] & @CRLF & 'No failures during Delete/Create')
Func _Log
($cl, $cc, $dl, $dc, $tot, $int) FileWrite($fLog, 'Shortcuts that failed to be deleted: ' & $dc & @CRLF) FileWrite($fLog, 'Shortcuts that failed to be created: ' & $cc & @CRLF)
$iSRC = IniRead($inifile, 'Main', 'Folder', 'C:\') $iPRS = IniRead($inifile, 'Main', 'PathSearch', '(.*)') $iPRR = IniRead($inifile, 'Main', 'PathReplace', '\1') $iNRS = IniRead($inifile, 'Main', 'NameSearch', '(.*)') $iNRR = IniRead($inifile, 'Main', 'NameReplace', '\1') $iREC = IniRead($inifile, 'Main', 'Recurse', 'False') $iTST = IniRead($inifile, 'Main', 'Test', 'False')
;===============================================================================
;
; Function Name: _ArrayBox()
; Description: Shows an array in a GUI window. Improved version of _ArrayDisplay
; Parameter(s): $Array - An array, 1d or 2d, 0-based or 1-based
; $ArrayBase - 1 or 0 - tells what base the array is
; $sTitle - the title to put on the output window
; $Width, $Height, $Left, $Top - Set the size and position of the output window
; Requirement(s): $Array must be 1d or 2d. If 1-based, then arraysize is assumed to be $Array[0] or $Array[0][0]
; Return Value(s): -1 = $Array is not an array, error=1
; Revision: 20050620A
;
;===============================================================================
;
Func _ArrayBox
(ByRef $Array, $ArrayBase = 1, $sTitle = 'Array Box', $sTemp = '', $sIni = False, $Width = 400, $Height = 200, $Left = -1, $Top = -1) Dim $AllDone = 0, $msg, $i, $j, $ArrayDimensions = UBound($Array, 0) Dim $hndForm_Main, $hndListView_Display
;Setup
If $ArrayBase <> 0 Then $ArrayBase = 1 Case $ArrayDimensions = 1 $ArrayMax = $Array[0]
Case $ArrayDimensions = 2 $ArrayMax = $Array[0][0]
$ArrayMax = UBound($Array, 1) - 1
;Create GUI
If $Height < 100 Then $Height = 100 If $Width < 100 Then $Width = 100 $hndForm_Main = GUICreate($sTitle, $Width, $Height, $Left, $Top, BitOR($WS_POPUP, $WS_CAPTION, $WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_EX_DLGMODALFRAME))
;Create List Box
If $sTemp = '' Then $sTemp = 'Index|Value' $sTemp = 'Index'
$sTemp = $sTemp & '|' & $i
$hndListView_Display = GUICtrlCreateListView($sTemp, 0, 0, $Width, $Height - 24, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOSORTHEADER)) _GUICtrlListView_SetColumnWidth($hndListView_Display, 0, 36)
;Create Controls, Show GUI
If $sIni Then WinMove($sTitle, '', IniRead($inifile, 'Test', 'XPos', 20), IniRead($inifile, 'Test', 'YPos', 20), IniRead($inifile, 'Test', 'Width', 400), IniRead($inifile, 'Test', 'Height', 200))
;Display Array
Case $ArrayDimensions = 1 ;1-Dimensional Array For $i = $ArrayBase To $ArrayMax Case $ArrayDimensions = 2 ;2-Dimensional Array For $i = $ArrayBase To $ArrayMax $sTemp = $Array[$i][0]
$sTemp = $sTemp & '|' & $Array[$i][$j]
_GUICtrlListView_SetColumnWidth($hndListView_Display, 1, $LVSCW_AUTOSIZE)
_GUICtrlListView_SetColumnWidth($hndListView_Display, 2, $LVSCW_AUTOSIZE)
;Wait for user to close box
Case $msg = $GUI_EVENT_CLOSE $AllDone = 1
Case $msg = $hndButton_Close $AllDone = 1
IniWrite($inifile, 'Test', 'XPos', $wPos[0]) IniWrite($inifile, 'Test', 'YPos', $wPos[1]) IniWrite($inifile, 'Test', 'Width', $wPos[2]) IniWrite($inifile, 'Test', 'Height', $wPos[3])
; #FUNCTION# =====================================================================================================================
; _FileListToArrayPlus($sPath, $sInclude = "*", $iFlag = 0, $sExcludeFolder = "", $sExclude = "", $iPathType = 0, $bRecursive = False)
; Name...........: _FileListToArray_Rec
; Parameters ....: $sPath: Folder to search
; $sInclude: String to match on (wildcards allowed, multiples delimited by ;)
; $iFlag: Returned data type. 0 = Files and folders (default), 1 = Files only, 2 = Folders only
; $sExcludeFolder: List of folders to exclude from search (wildcards allowed, multiples delimited by ;)
; $sExclude: List of filenames to exclude from search (wildcards allowed, multiples delimited by ;)
; $iPathType: Returned data format. 0 = Filename only (default), 1 = Path relative to $sPath, 2 = Full path/filename
; $bRecursive: False = Search $sPath folder only (default), True = Search $sPath and all subfolders
; Author ........: Half the Autoit Community (Forum thread #96952)
;===================================================================================================================================
Func _FileListToArrayPlus
($sPath, $sInclude = "", $iFlag = 0, $sExcludeFolder = "", $sExclude = "", $iPathType = 0, $bRecursive = False) Local $sRet = "", $sReturnFormat = "", $interrupt = False ; Edit include files list
If $sInclude = "*" Then $sInclude = "" $sInclude = "(?i)\A(" & $sInclude & "$)"; case-insensitive, match from first char, terminate strings
; Edit exclude folders list
$sExcludeFolder = StringRegExpReplace($sExcludeFolder, "[][$.+^{}()]", "\\$0"); Ignore special characters $sExcludeFolder = "(?i)\A(?!" & $sExcludeFolder & "$)"; case-insensitive, match from first char, terminate strings
; Edit exclude files list
$sExclude = "(?i)\A(?!" & $sExclude & "$)"; case-insensitive, match from first char, terminate strings
; MsgBox(1,"Masks","File include: " & $sInclude & @CRLF & "File exclude: " & $sExclude & @CRLF & "Dir exclude : " & $sExcludeFolder)
Local $sOrigPathLen = StringLen($sPath), $aQueue[64] = [1, $sPath], $iQMax = 63 $WorkFolder = $aQueue[$aQueue[0]]
$aQueue[0] -= 1
$sReturnFormat = $WorkFolder
$iQMax += 128
ReDim $aQueue[$iQMax + 1] $aQueue[0] += 1
$aQueue[$aQueue[0]] = $WorkFolder & $file & "\"
$sRet &= $sReturnFormat & $file & "|"
$sRet &= $sReturnFormat & $file & "|"