J'ai fait un script qui permet (théoriquement) d'explorer les fichiers et dossiers de mon ordinateur.
A force de vouloir le perfectionner, il se bloque .
J'ai ce problème avec XP (admin et limité) et Seven (limité). (Je n'ai pas eut l'occasion de tester ailleurs.)
► Afficher le texteConsole
Code : Tout sélectionner
>"F:\Autoit\Executeur\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "G:\Brouillon\os_4.au3" /UserParams
+>12:24:06 Starting AutoIt3Wrapper v.2.1.0.33 Environment(Language:040C Keyboard:0000040C OS:WIN_7/Service Pack 1 CPU:X64 OS:X64)
>Running AU3Check (3.3.12.0) from:F:\Autoit\Executeur
+>12:24:06 AU3Check ended.rc:0
>Running:(3.3.12.0):F:\Autoit\Executeur\autoit3_x64.exe "G:\Brouillon\os_4.au3"
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
[color=#FF0000]!>12:25:42 AutoIT3.exe ended.rc:-1073741819[/color]
>Exit code: -1073741819 Time: 98.393► Afficher le texte
Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <File.au3>
#include <GuiListView.au3>
#include <String.au3>
#include <GuiStatusBar.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $hGui = GUICreate("Form1", 900, 765)
Global $Tab1 = GUICtrlCreateTab(0, 0, 897, 745)
Global $TabSheet1 = GUICtrlCreateTabItem("Normal")
$hTreeview = GUICtrlCreateTreeView(10, 32, 180, 700, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS))
Global $hListView = GUICtrlCreateListView("Nom", 192, 32, 697, 705)
Global $TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
GUICtrlCreateTabItem("")
$g_hStatus = _GUICtrlStatusBar_Create($hGui)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $path
Global $sPath1 = DriveGetDrive("ALL")
Global $hRoot2[UBound($sPath1)-1]
$hWndTreeview = GUICtrlGetHandle($hTreeview)
$hImage64 = _GUIImageList_Create(64, 64, 5,3)
_GUIImageList_AddIcon($hImage64, 'shell32.dll', 4,1);dossier 0
_GUIImageList_AddIcon($hImage64, "explorer.exe", 0,1);poste de travail 1
_GUIImageList_AddIcon($hImage64, 'shell32.dll', 8,1); disque dur 2
_GUIImageList_AddIcon($hImage64, @ScriptDir & '\dll2.dll',0,1);script au3 3
_GUIImageList_AddIcon($hImage64, 'shell32.dll', 0,1); fichier 4
_GUIImageList_AddIcon($hImage64, 'shell32.dll', 70,1); fichier txt 5
_GUIImageList_AddIcon($hImage64, 'shell32.dll', 2,1); .exe 6
_GUIImageList_AddIcon($hImage64, 'shell32.dll', 116,1); musique 7
_GUIImageList_AddIcon($hImage64, 'shell32.dll', 115,1); film 8
_GUIImageList_AddIcon($hImage64, @ScriptDir & '\dll2.dll',2,1); pdf 9
_GUIImageList_AddIcon($hImage64, @ScriptDir & '\dll2.dll',5,1);jpeg 10
_GUIImageList_AddIcon($hImage64, @ScriptDir & '\dll2.dll',4,1);bmp 11
_GUIImageList_AddIcon($hImage64, @ScriptDir & '\dll2.dll',3,1);zip 12
_GUIImageList_AddIcon($hImage64, @ScriptDir & '\dll2.dll',6,1);png 13
_GUIImageList_AddIcon($hImage64, @ScriptDir & '\dll2.dll',7,1);tiff 14
_GUIImageList_AddIcon($hImage64, @ScriptDir & '\dll2.dll',9,1);word 15
_GUIImageList_AddIcon($hImage64, @ScriptDir & '\dll2.dll',10,1);video 16
_GUIImageList_AddIcon($hImage64, @ScriptDir & '\dll2.dll',11,1);blender 17
_GUIImageList_AddIcon($hImage64, @ScriptDir & '\dll2.dll',12,1);? 18
_GUIImageList_AddIcon($hImage64, 'shell32.dll',7,1);amovible 19
_GUIImageList_AddIcon($hImage64, 'shell32.dll',11,1);CD 20
_GUIImageList_AddIcon($hImage64, 'shell32.dll',9,1);reseau 21
_GUIImageList_AddIcon($hImage64, 'shell32.dll',53,1);? 22
_GUIImageList_AddIcon($hImage64, 'shell32.dll',1,1);RTF 23
_GUIImageList_AddIcon($hImage64, 'shell32.dll',20,1);Tmp 24
_GUIImageList_AddIcon($hImage64, 'shell32.dll',-75,1);FONT 25
_GUIImageList_AddIcon($hImage64, 'shell32.dll',-70,1);ini 26
_GUIImageList_AddIcon($hImage64, 'shell32.dll',-72,1);Bat 27
_GUIImageList_AddIcon($hImage64, 'shell32.dll',-142,1);Theme 28
_GUICtrlListView_SetImageList($hListView,$hImage64)
#Region
;dll2.dll 0= au3 1= autoit 2=pdf 3=zip 4=bmp 5=jpeg 8=tiff
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 4); dossier 0
_GUIImageList_AddIcon($hImage, "explorer.exe", 0); poste de travail 1
_GUIImageList_AddIcon($hImage, 'shell32.dll', 8); disque dur 2
_GUIImageList_AddIcon($hImage, @ScriptDir & '\dll2.dll',0);script au3 3
_GUIImageList_AddIcon($hImage, 'shell32.dll', 0); fichier 4
_GUIImageList_AddIcon($hImage, 'shell32.dll', 70); fichier txt 5
_GUIImageList_AddIcon($hImage, 'shell32.dll', 2); .exe 6
_GUIImageList_AddIcon($hImage, 'shell32.dll', 116); musique 7
_GUIImageList_AddIcon($hImage, 'shell32.dll', 115); film 8
_GUIImageList_AddIcon($hImage, @ScriptDir & '\dll2.dll',2); pdf 9
_GUIImageList_AddIcon($hImage, @ScriptDir & '\dll2.dll',5);jpeg 10
_GUIImageList_AddIcon($hImage, @ScriptDir & '\dll2.dll',4);bmp 11
_GUIImageList_AddIcon($hImage, @ScriptDir & '\dll2.dll',3);zip 12
_GUIImageList_AddIcon($hImage, @ScriptDir & '\dll2.dll',6);png 13
_GUIImageList_AddIcon($hImage, @ScriptDir & '\dll2.dll',7);tiff 14
_GUIImageList_AddIcon($hImage, @ScriptDir & '\dll2.dll',9);word 15
_GUIImageList_AddIcon($hImage, @ScriptDir & '\dll2.dll',10);video 16
_GUIImageList_AddIcon($hImage, @ScriptDir & '\dll2.dll',11);blender 17
_GUIImageList_AddIcon($hImage, @ScriptDir & '\dll2.dll',12);? 18
_GUIImageList_AddIcon($hImage, 'shell32.dll',7);amovible 19
_GUIImageList_AddIcon($hImage, 'shell32.dll',11);CD 20
_GUIImageList_AddIcon($hImage, 'shell32.dll',9);reseau 21
_GUIImageList_AddIcon($hImage, 'shell32.dll',53);? 22
_GUICtrlTreeView_SetNormalImageList($hTreeview, $hImage)
#EndRegion
GUISetState()
GUICtrlSetStyle($hTreeview, Default, $WS_EX_COMPOSITED + $WS_EX_CLIENTEDGE )
; - - - - - - - - - - - - - - - - - - - - integration des repertoires - - - - - - - - - - - - - - - - - - - - -
$Ordinateur = _GUICtrlTreeView_Add($hTreeview, $hTreeview,"Poste de travail",1,1)
_GUICtrlTreeView_SetState($hTreeview, $Ordinateur, $TVIS_EXPANDED)
For $j = 2 to $sPath1[0]
$ok = ok($sPath1[$j])
If $ok = 0 Then ContinueLoop
Switch DriveGetType($sPath1[$j])
Case "Removable"
$ico = 19
Case "Fixed"
$ico = 2
Case "CDROM"
$ico = 20
Case "Network"
$ico = 21
Case Else
$ico = 22
EndSwitch
$hRoot2[$j-2] = _GUICtrlTreeView_AddChild($hTreeview,$Ordinateur, $sPath1[$j] & " " & DriveGetLabel($sPath1[$j]) , $ico,$ico)
_GUICtrlTreeView_SetState($hTreeview, $hRoot2[$j-2], $TVIS_EXPANDED)
; - - - - - - - - - - - - - - - - - - - - arborescence des repertoires - - - - - - - - - - - - - - - - - - - - -
_GUICtrlTreeView_BeginUpdate($hTreeview)
GUISetCursor(15, 1, $hGui)
_GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hRoot2[$j-2], $sPath1[$j],$ok);Number(InputBox("Niveau de recherche","Veuiller indiquer les nombre de sous dossier que vous voulez explorer.",4)));
GUISetCursor(2, 1, $hGui)
_GUICtrlTreeView_EndUpdate($hTreeview)
Next
_GUICtrlListView_SetView($hListView,0)
;~ ExploreFile( @ScriptDir)
GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE;, $hCancel
Exit
EndSwitch
WEnd
#region
Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
GUIRegisterMsg($WM_NOTIFY, '')
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
$iCode = DllStructGetData($tNMHDR, 'Code')
If $iCode = $NM_CLICK Then
$aTVPos = ControlGetPos($hGui, '', $hTreeview)
$aPos = GUIGetCursorInfo($hGui)
If $aPos[0] > $aTVPos[0] And $aPos[0] < $aTVPos[0] + $aTVPos[2] And $aPos[1] > $aTVPos[1] And $aPos[1] < $aTVPos[1] + $aTVPos[3] Then
ToolTip('Chargement...', Default, Default, 'Lecture', 1)
_GUICtrlTreeView_FileExplorer($hGui, $hTreeview)
ToolTip('')
EndIf
ElseIf $iCode = $NM_DBLCLK Then
$aLVPos = ControlGetPos($hGui, '', $hListView)
$aPos = GUIGetCursorInfo($hGui)
If $aPos[0] > $aLVPos[0] And $aPos[0] < $aLVPos[0] + $aLVPos[2] And $aPos[1] > $aLVPos[1] And $aPos[1] < $aLVPos[1] + $aLVPos[3] Then
ToolTip('Chargement...', Default, Default, 'Lecture', 1)
_GUICtrlListView_FileExplorer($hGui, $hListView)
ToolTip('')
EndIf
EndIf
GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
Return $GUI_RUNDEFMSG
EndFunc
Func _GUICtrlTreeView_FileExplorer($hGui, $hTreeview)
Local $aTVPos, $aPos, $hItem, $hChild, $sTree
Sleep(10)
$aTVPos = ControlGetPos($hGui, '', $hTreeview)
$aPos = GUIGetCursorInfo($hGui)
$check= GUICtrlSetState(-1, $GUI_CHECKED)
$hItem = _GUICtrlTreeView_HitTestItem($hTreeview, $aPos[0], $aPos[1] - $aTVPos[1])
$hChild = _GUICtrlTreeView_GetFirstChild($hTreeview, $hItem-1)
If $hItem Then
Global $path = StringReplace(_GUICtrlTreeView_GetTree($hTreeview, $hChild), '|', '\')
$path = StringReplace($path,"Poste de travail\","")
If $path = "Poste de travail" Then Return
$path = StringReplace($path,StringSplit($path , "\" )[1] ,StringLeft($path,1)& ":")
ExploreFile($path)
EndIf
;~ If _GUICtrlTreeView_GetExpanded($hTreeview, $hItem) Then Return
;~ _GUICtrlTreeView_BeginUpdate($hTreeview)
;~ If $hChild <> 0 Then
;~ $sTree = StringReplace(_GUICtrlTreeView_GetTree($hTreeview, $hChild), '|', '\')
;~ _GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hChild, $sTree, 1)
;~ EndIf
;~ $hChild = _GUICtrlTreeView_GetNextChild($hTreeview, $hChild)
;~ _GUICtrlTreeView_EndUpdate($hTreeview)
EndFunc ;==>_GUICtrlTreeView_FileExplorer
Func _GUICtrlListView_FileExplorer($hGui, $hListView)
$num = _GUICtrlListView_GetHotItem($hListView)
$nubm = _GUICtrlListView_GetItemTextString($hListView,$num)
ShellExecute($path & "\" & $nubm)
EndFunc
Func ExploreFile($path)
$timer = TimerInit()
_GUICtrlStatusBar_SetText( $g_hStatus,$path )
ConsoleWrite(@LF & $path & @CR) ;= StringReplace($path,"Poste de travail\","")
_GUICtrlListView_DeleteAllItems ( $hListView )
_GUICtrlListView_BeginUpdate($hListView)
$aFileList = _FileListToArray($path, '*', 1); - - - fichiers - - -
If IsArray($aFileList) Then
For $i = 1 To $aFileList[0]
If Not StringInStr(FileGetAttrib($path & '\' & $aFileList[$i]), 's') Then;si il n'est pas un fichier système
$hIcon2 = icon64($path & "\" , $aFileList[$i])
$tmp = _GUICtrlListView_AddItem($hListView,$aFileList[$i],$hIcon2)
EndIf
If TimerDiff($timer) > 10000 Then ExitLoop
Next
EndIf
_GUICtrlListView_EndUpdate($hListView)
;~ _GUICtrlListView_SetView($hListView,0)
EndFunc
Func _GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hItem, $sPath, $iRec)
Sleep(1)
Local $aDirList, $aFileList, $tmp, $hIcon
$iRec -= 1
$aDirList = _FileListToArray($sPath, '*', 2); - - - dossiers - - -
If IsArray($aDirList) Then
For $i = 1 To $aDirList[0]
If Not StringInStr(FileGetAttrib($sPath & '\' & $aDirList[$i]), 's') And $aDirList[$i] <> "Windows" Then;si il n'est pas un fichier système
$tmp = _GUICtrlTreeView_AddChild($hTreeview, $hItem, $aDirList[$i], 0, 0)
If StringInStr(FileGetAttrib($sPath & '\' & $aDirList[$i]), 'h') Then _GUICtrlTreeView_SetState($hTreeview,$tmp,4);4 = hide ;16 gras ; - - - - - - -
If $iRec <> 0 Then _GUICtrlTreeView_FileExplorerRecursive($hTreeview, $tmp, $sPath & '\' & $aDirList[$i], $iRec)
EndIf
Next
EndIf
EndFunc ;==>_GUICtrlTreeView_FileExplorerRecur
#endregion
Func icon64($sPath2,$2)
$hIcon2 = _GUIImageList_AddIcon($hImage64, $sPath2 & $2, 0,1)
If $hIcon2 > 0 Then
_GUICtrlListView_SetImageList($hListView, $hImage64)
Return $hIcon2
Else
If Not StringInStr($2,".") Then
$hIcon2 = 4
Else
$hIcon2 = 4
If StringInStr($2,".au3") Then $hIcon2 = 3
If StringInStr($2,".txt") Then $hIcon2 = 5
If StringInStr($2,".exe") Then $hIcon2 = 6
If StringInStr($2,".mp3") Or StringInStr($2,".wma") Then $hIcon2 = 7
If StringInStr($2,".avi") Or StringInStr($2,".mp4") Or StringInStr($2,".mpg") Then $hIcon2 = 16
If StringInStr($2,".pdf") Then $hIcon2 = 9
If StringInStr($2,".jpg") Or StringInStr($2,".jpeg") Then $hIcon2= 10
If StringInStr($2,".bmp") Then $hIcon2 = 11
If StringInStr($2,".zip") Then $hIcon2 = 12
If StringInStr($2,".png") Then $hIcon2 = 13
If StringInStr($2,".tiff") Then $hIcon2 = 14
If StringInStr($2,".docx") Or StringInStr($2,".doc") Then $hIcon2 = 15
If StringInStr($2,".blend") Then $hIcon2 = 17
If StringInStr($2,".rtf") Then $hIcon2 = 23
If StringInStr($2,".ini") Or StringInStr($2,".dat") Or StringInStr($2,".log") Then $hIcon2 = 26
If StringInStr($2,".fon") Or StringInStr($2,".otf") Or StringInStr($2,".ttf") Then $hIcon2 = 25
If StringInStr($2,".bat") Then $hIcon2 = 27
If StringInStr($2,".theme") Then $hIcon2 = 28
EndIf
;~ _GUICtrlListView_SetImageList($hListView, $hImage64)
Return $hIcon2
EndIf
EndFunc
Func ok($drive)
#Region ### START Koda GUI section ### Form=
Global $Form3 = GUICreate($drive & " " & DriveGetLabel($drive), 350, 245, 397, 290)
Switch DriveGetType($drive)
Case "Removable"
$ico = 8
Case "Fixed"
$ico = 9
Case "CDROM"
$ico = 12
Case "Network"
$ico = 10
Case Else
$ico = 54
EndSwitch
GUICtrlCreateIcon(@SystemDir & "\shell32.dll", $ico, 8, 8, 48, 48)
Global $Label1 = GUICtrlCreateLabel($drive, 80, 8, 30, 36)
GUICtrlSetFont(-1, 18, 400, 0,"System")
Global $Label2 = GUICtrlCreateLabel(DriveGetLabel($drive), 136, 8, 92, 36)
GUICtrlSetFont(-1, 18, 400, 0,"System")
GUICtrlCreateLabel("Taille totale :", 70, 64, 88, 20)
GUICtrlCreateLabel(DriveSpaceTotal($drive) & " Mo", 214, 64, 120, 20)
GUICtrlCreateLabel("Systeme de fichiers :", 70, 112, 141, 20)
GUICtrlCreateLabel("Serial number :", 70, 136, 103, 20)
GUICtrlCreateLabel(DriveGetFileSystem($drive), 214, 112, 120, 20)
GUICtrlCreateLabel(DriveGetSerial($drive), 214, 136, 120, 20)
Global $msgLabel10 = GUICtrlCreateLabel("Espace libre :", 70, 88, 93, 20)
Global $msgLabel11 = GUICtrlCreateLabel(DriveSpaceFree($drive) & " Mo", 214, 88, 120, 20)
Global $msgButton1 = GUICtrlCreateButton("Voir en entier", 8, 184, 105, 25)
Global $msgCheckbox1 = GUICtrlCreateCheckbox("Annaliser", 8, 216, 89, 25)
Global $msginput1 = GUICtrlCreateInput(4, 104, 216, 49, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
Global $msgUpdown1 = GUICtrlCreateUpdown($msginput1)
GUICtrlSetLimit(-1, 20, 1)
Global $msgLabel12 = GUICtrlCreateLabel("dossier(s)", 160, 216, 69, 20)
Global $msgButton2 = GUICtrlCreateButton("Lancer", 232, 216, 57, 25)
Global $msgButton3 = GUICtrlCreateButton("Annuler", 232, 184, 105, 25)
Global $msgButton4 = GUICtrlCreateButton("Passer", 120, 184, 105, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $msgButton3
Exit
Case $msgButton1
GUIDelete($Form3)
Return -1
Case $msgButton2
$ret = GUICtrlRead($msginput1)
GUIDelete($Form3)
Return $ret
Case $msgButton4
GUIDelete($Form3)
Return 0
EndSwitch
WEnd
EndFunc
PS:
dll2.dll est une dll que j'ai créée avec autoit.
Code : Tout sélectionner
Exit 0Je vous déconseille de "voir le disque" (création de la liste complète de tous ses dossiers) en entier si il est gros (ça prend du temps).



