mrmacadamia Posted November 28, 2009 Share Posted November 28, 2009 hi i want to create a list of FIXED hdd using GUICtrlCreateCombo. If i select a harddisk it will show its free space, label and so on. So far this is what i got. I stuck at how to show different drive with specific data. expandcollapse popup#include <ComboConstants.au3> #include <GUIConstantsEx.au3> #Include <Array.au3> #Include <GuiComboBox.au3> Global Const $CD_VOLUME = DriveGetLabel(@HomeDrive) Global Const $CD_SERIAL = DriveGetSerial(@HomeDrive) Global Const $CD_TOTALSPACE = DriveSpaceTotal(@HomeDrive) Global Const $CD_FREESPACE = DriveSpaceFree(@HomeDrive) Global Const $CD_SYSTEMTYPE = DriveGetFileSystem(@HomeDrive) Global Const $CD_STATUS = DriveStatus(@HomeDrive) _HDD() Func _HDD() $MainGUI = GUICreate("HDD", 350, 300, -1, -1) $Drives = DriveGetDrive("FIXED") $Comb_Data = StringUpper(_ArrayToString($Drives, "|", 1)) $Combo_Dsel = GUICtrlCreateCombo("", 100, 100, 100, 30, $CBS_DROPDOWNLIST) If $Drives[0] Then For $i = 0 To $Drives[0] _GUICtrlComboBox_AddString($Comb_Data, $Drives[$i]) Next Else _GUICtrlComboBox_AddString($Comb_Data, 'None') GUICtrlSetState(-1, $GUI_DISABLE) EndIf GUICtrlSetData($Combo_Dsel, $Comb_Data, StringUpper($Drives[1])) _GUICtrlComboBox_SetCurSel($Comb_Data, 0) $Round_TOTALSPACE = Round($CD_TOTALSPACE / 1000, 1) $Round_FREESPACE = Round($CD_FREESPACE / 1000, 1) $Percent_FREESPACE = Round(($CD_FREESPACE / $CD_TOTALSPACE) * 100, 1) GUICtrlCreateLabel("FileSystem : ", 110, 160, 70, 14) GUICtrlCreateLabel("Capacity : ", 110, 175, 60, 14) GUICtrlCreateLabel("Free Space : ", 110, 190, 70, 14) GUICtrlCreateLabel("% Free Space : ", 110, 205, 80, 14) $filesystem = GUICtrlCreateLabel("", 180, 160, 40, 14) GUICtrlSetData($filesystem, $CD_SYSTEMTYPE) $capacity = GUICtrlCreateLabel("", 170, 175, 40, 14) GUICtrlSetData($capacity, $Round_TOTALSPACE) $freespace = GUICtrlCreateLabel("",180, 190, 40, 14) GUICtrlSetData($freespace, $Round_FREESPACE) $percentfreespace = GUICtrlCreateLabel("", 190, 205, 30, 14) GUICtrlSetData($percentfreespace, $Percent_FREESPACE) GUISetState() While 1 $nMsg = GUIGetMsg() Select Case $nMsg = -3 Exit Case $nMsg = $Combo_Dsel $cRead = GUICtrlRead($Combo_Dsel) ;If $cRead = "C:" Then GUICtrlSetData($capacity, Floor(DriveSpaceTotal($Combo_Dsel) / 1024)) ;For $i = 1 To $Drives[0] ;_GUICtrlComboBox_GetCurSel($Combo_Dsel) ;$Drive = GUICtrlRead($Combo_Dsel) ;GUICtrlSetData($filesystem, Floor(DriveSpaceTotal($Combo_Dsel) / 1024)) ; MsgBox(4160, "Information", "Cur Sel: " & _GUICtrlComboBox_GetCurSel($Combo_Dsel)) EndSelect WEnd EndFunc Link to comment Share on other sites More sharing options...
BrettF Posted November 28, 2009 Share Posted November 28, 2009 Basically the way I've done it in the past was to check if the selection had changed and then react upon that... So what you probably want to do is create a zero-based, two dimension array of fixed drives and sizes ($aDriveData) , and populate the combo. Set $sel to be 1 or whatever. Then you want to use something like $cur = _GUICtrlComboBox_GetCurSel to get the selection. If $sel <> $cur then it is different so we want to react. Else we want to sleep or something. If we're reacting we're getting the data in the $aDriveData[$cur][n]. This is persudo, but would be how I would go about doing it. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now