Page 1 sur 1
[R] Afficher toutes les partitions avec info
Posté : lun. 29 juil. 2013 11:48
par guyom24h
Bonjour a tous, j'ai parcouru le forum et passer du temps a faire des tests, etc... Mais je bloque!
J'aimerai qu'en cliquant sur un bouton, j'ai l'affichage de tous les disque avec des infos associé, type, taille, taille libre, et systeme de fichier...
J'ai fait cela...
► Afficher le texte
Code : Tout sélectionner
Case $Disk
Local $aArray = DriveGetDrive("ALL")
$Filesystem = DriveGetFileSystem($aArray & "\")
$Type = DriveGetType($aArray & "\")
$Freespace = DriveSpaceFree($aArray & "\")
$totalspace = DriveSpaceTotal($aArray & "\")
;~ next
If @error Then
; An error occurred when retrieving the drives.
MsgBox(64, "DriveGetDrive", "Erreur!!")
Else
For $i = 1 To $aArray[0]
Local $avArray[2][5] = [[$aArray[$i], $Filesystem, $Type, $Freespace, $totalspace],[$aArray[$i], $Filesystem, $Type, $Freespace, $totalspace]]
;~ _ArrayDisplay($avArray, "$avArray as a 2D array")
_ArrayDisplay($avArray, "$avArray as a 2D array, transposed", -1, 1)
next
EndIf
Mais ca ne fait pas tout dans un meme tableau, quelqu'un peut il m'aider?
Re: [..] Afficher toutes les partitions avec info
Posté : lun. 29 juil. 2013 13:29
par jguinch
Salut
Essai avec un truc comme ça :
► Afficher le texte
Code : Tout sélectionner
Local $aArray = DriveGetDrive("ALL")
Local $avArray[ $aArray[0] ][5]
For $i = 1 To $aArray[0]
$Filesystem = DriveGetFileSystem($aArray[$i] & "\")
$Type = DriveGetType($aArray[$i] & "\")
$Freespace = DriveSpaceFree($aArray[$i] & "\")
$totalspace = DriveSpaceTotal($aArray[$i] & "\")
$avArray[$i - 1][0] = $aArray[$i]
$avArray[$i - 1][1] = $Filesystem
$avArray[$i - 1][2] = $Type
$avArray[$i - 1][3] = $Freespace
$avArray[$i - 1][4] = $totalspace
Next
_ArrayDisplay($avArray)
Re: [..] Afficher toutes les partitions avec info
Posté : lun. 29 juil. 2013 13:53
par guyom24h
Ah merci!!!
Je suis parti dans tous les sens...
C'est une obligation l'affichage des row et des col?
On peut changer et mettre des titres a la place? genre partition, taille disponible etc...??
Re: [..] Afficher toutes les partitions avec info
Posté : lun. 29 juil. 2013 14:57
par jguinch
Regarde dans la doc de la fonction _ArrayDisplay, le paramètre $sheader permet de mettre les titres que tu veux aux colonnes.
Re: [..] Afficher toutes les partitions avec info
Posté : lun. 29 juil. 2013 17:55
par mikell
Tu peux aussi créer ta propre listview...
Et essayer WMI si certaines infos manquent
► Afficher le texte
Code : Tout sélectionner
#include <GUIConstantsEx.au3>
;#include <Array.au3>
#include <ListviewConstants.au3>
SplashTextOn ("", "Loading...", 180, 60, -1, -1, 49)
Global $var = DriveGetDrive("FIXED")
$myinfos = _GetDriveInfos()
;_arraydisplay($myinfos)
$W = 610
$Ypos = 45+(14*$var[0])
$Main = GuiCreate("Disques", $W+260, $Ypos)
$listview = GUICtrlCreateListView("Volume|Nom|Taille (Go)|Disponible (Go)|Occupé (Go)|" & _
"Plein à|Libre (Go)|Disque physique|ID", 10, 5, $W+240, $Ypos-15)
For $i = 0 to $var[0]-1
$percentocc = Round(($myinfos[$i][2]-$myinfos[$i][3])*100/$myinfos[$i][2], 1)
GUICtrlCreateListViewItem(StringUpper($myinfos[$i][0]) &"|"& $myinfos[$i][6] &"|"& _
$myinfos[$i][4] &"|"& $myinfos[$i][2] &"|"& $myinfos[$i][2]-$myinfos[$i][3] &"|"& _
$percentocc &" %" &"|"& $myinfos[$i][3] &"|"& $myinfos[$i][1] &"|"& $myinfos[$i][5], $listview)
Next
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 0, 60)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 1, 110)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 2, 70)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 3, 90)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 4, 80)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 5, 70)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 6, 70)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 7, 170)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 8, 120)
GUISetState()
SplashOff()
While GUIGetMsg()<>$GUI_EVENT_CLOSE
Sleep(10)
WEnd
;======================================
Func _GetDriveInfos()
Dim $specifs[$var[0]][7]
For $i = 1 to $var[0]
Dim $Services = ObjGet('winmgmts:\\.\root\cimv2')
Dim $DiskDrives = $Services.ExecQuery("Select Caption, DeviceID From Win32_DiskDrive")
For $DiskDrive In $DiskDrives
Dim $DiskPartitions = $Services.ExecQuery("Associators of {Win32_DiskDrive.DeviceID='" & _
$DiskDrive.DeviceID & "'} Where AssocClass = Win32_DiskDriveToDiskPartition")
For $DiskPartition In $DiskPartitions
Dim $LogicalDisks = $Services.ExecQuery ("Associators of {Win32_DiskPartition.DeviceID='" & _
$DiskPartition.DeviceID & "'} Where AssocClass = Win32_LogicalDiskToPartition")
For $LogicalDisk In $LogicalDisks
If $LogicalDisk.DeviceID = $var[$i] Then
$specifs[$i-1][0] = $var[$i]
$specifs[$i-1][1] = $DiskDrive.Caption
$specifs[$i-1][2] = Round(DriveSpaceTotal($var[$i])/1000 )
$specifs[$i-1][3] = Round(DriveSpaceFree($var[$i])/1000 )
$specifs[$i-1][4] = Round($LogicalDisk.Size/1000000000)
$specifs[$i-1][5] = $DiskPartition.DeviceID
$specifs[$i-1][6] = $LogicalDisk.VolumeName
EndIf
Next
Next
Next
Next
Return $specifs
EndFunc
Re: [..] Afficher toutes les partitions avec info
Posté : mar. 30 juil. 2013 10:44
par guyom24h
Si je veux mettre ma liste de disque dans une combo, j'essai un truc dans ce style...mais bon...
► Afficher le texte
Code : Tout sélectionner
Local $liste_fixed = DriveGetDrive("FIXED")
For $i = 1 To $liste_fixed[0]
$reel = $liste_fixed[$i]
Next
GuiCtrlSetData($combo, $reel))
ou ca...
► Afficher le texte
Code : Tout sélectionner
Local $liste_fixed = DriveGetDrive("FIXED")
For $i = 1 To $liste_fixed[0]
;~ $reel = $liste_fixed[$i]
Next
GuiCtrlSetData($combo, $liste_fixed[1] & "|" & $liste_fixed[$i - 1 ])
Sinon pour les header, j'ai fait comme indiqué dans la doc, mais cela ne passe pas. De meme pour les row, comment les retirer?
J'ai fait:
► Afficher le texte
Code : Tout sélectionner
Local $aArray = DriveGetDrive("ALL")
Local $avArray[ $aArray[0] ][5]
For $i = 1 To $aArray[0]
$Filesystem = DriveGetFileSystem($aArray[$i] & "\")
$Type = DriveGetType($aArray[$i] & "\")
$Freespace = DriveSpaceFree($aArray[$i] & "\")
$totalspace = DriveSpaceTotal($aArray[$i] & "\")
$avArray[$i - 1][0] = $aArray[$i]
$avArray[$i - 1][1] = $Filesystem
$avArray[$i - 1][2] = $Type
$avArray[$i - 1][3] = $Freespace & " Mo"
$avArray[$i - 1][4] = $totalspace & " Mo"
$sHeader = "Volume|Format|Type|Libre (Mo)|Total (Mo)"
Next
_ArrayDisplay($avArray, "Liste des disques", $sHeader)
Merci Mikel, j'avais vu ton script en parcourant le forum. Bien compliqué pour mon niveau concernant les Array, je m'y perds!
Re: [..] Afficher toutes les partitions avec info
Posté : mar. 30 juil. 2013 10:56
par jguinch
Fais plutôt comme ça :
Code : Tout sélectionner
_ArrayDisplay ( $avArray, "Liste des disques", -1, 0, "", "|", $sHeader )
Quelque soit la fonction, si tu veux spécifier un paramètre non obligatoire (entre crochets dans la doc), il faudra spécifier tous les paramètres qui précédent.
Re: [..] Afficher toutes les partitions avec info
Posté : mar. 30 juil. 2013 11:13
par guyom24h
Ok merci, ca m'indique toujours les [0], [1],[2], etc... a chaque ligne...
Re: [..] Afficher toutes les partitions avec info
Posté : mar. 30 juil. 2013 12:02
par jguinch
ah oui, désolé, je suis allé trop vite...
Non, le ROWID reste visible à priori. Sinon, il faudra aller modifier la fonction _ArrayDiplay dans l'include mais bon, est-ce vraiment nécessaire ?
Autant faire ta propre fenêtre comme l'a suggéré Mikell.
Re: [..] Afficher toutes les partitions avec info
Posté : mar. 30 juil. 2013 12:30
par guyom24h
Ok, c'est pas grave, ca donne un apercu sur le nombre de disque...
Et pour l'integration dans une combo ca te parle?
Re: [..] Afficher toutes les partitions avec info
Posté : mar. 30 juil. 2013 14:10
par mikell
Pour la combo c'est comme pour la listview, c'est pas difficile si tu respectes la syntaxe
► Afficher le texte
Code : Tout sélectionner
GuiCreate("test")
$combo = GuiCtrlCreateCombo("disques", 10, 10)
Local $liste_fixed = DriveGetDrive("FIXED")
$reel = ""
For $i = 1 To $liste_fixed[0]
$reel &= $liste_fixed[$i] & "|"
Next
GuiCtrlSetData($combo, $reel)
GuiSetState()
While GuiGetMsg()<>-3
Wend
Re: [..] Afficher toutes les partitions avec info
Posté : mar. 30 juil. 2013 14:24
par guyom24h
J'y étais presque!!
Pourquoi avoir mis un "&=" dans...
$reel &= $liste_fixed[$i] & "|"
Re: [..] Afficher toutes les partitions avec info
Posté : mar. 30 juil. 2013 15:11
par mikell
Parce que...
Code : Tout sélectionner
$title = StringRegExpReplace(@Autoitexe, '(.+)\\[^\\]+', "$1") & "\AutoIt3.chm"
$oIE=ObjCreate("Shell.Explorer.2")
$gui = GUICreate($title, 700, 450, -1, -1, -1, 0x80)
$gX = GUICtrlCreateObj($oIE, 0, 0, 700, 450)
GUISetState()
$oIE.Navigate("mk:@MSITStore:" & $title & "::/html/intro/lang_operators.htm")
While GuiGetMsg()<>-3
Wend
Re: [R] Afficher toutes les partitions avec info
Posté : mer. 31 juil. 2013 09:58
par guyom24h
Ca je ne comprends pas?