SoulBlade Posted September 1, 2007 Posted September 1, 2007 Hi! In this fully working CHKDSK GUI, i'm trying to use D: as the default drive instead of C: . Any ideia how can i accomplish this? CODEAutoItSetOption("TrayIconHide", 1) #include <GUIConstants.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) Dim $drivearray[100] GuiCreate("CHKDSK 1.0", 330, 235) GUISetIcon("CHKDSK.ICO", 0) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUICtrlCreateGroup ("Check Disk ", 10, 10, 310, 90) $ReadOnly = GUICtrlCreateRadio ("Read-only mode", 40, 30, 100, 20) $Fix = GUICtrlCreateRadio ("Fix errors on the disk", 40, 50, 120, 20) $Recover = GUICtrlCreateRadio ("Locate bad sectors and recovers information", 40, 70, 265, 20) GUICtrlSetState ($Recover,$GUI_CHECKED) GUICtrlCreateGroup ("",-99,-99,1,1) GUICtrlCreateGroup ("",10,170,310,50) ;--------------- Build-up list of disks that can be checked --------------- $drives = DriveGetDrive("ALL") $drivelist = "" $y = 1 For $i = 1 to $drives[0] $DriveType = DriveGetType($drives[$i]) If $DriveType = "Removable" or $DriveType = "Fixed" or $DriveType = "RAMDisk" then $drivearray[$y] = $drives[$i] $y = $y + 1 EndIf Next $drivearray[0] = $y - 1 _ArraySort($drivearray, 0, 0, $y - 1) If NOT @error Then For $i = 1 to $drivearray[0] $drivearray[$i] = StringUpper($drivearray[$i]) $DriveStatus = DriveStatus($drivearray[$i]) if $DriveStatus = "NOTREADY" then $DriveInfo = "drive is empty" elseif $DriveStatus = "UNKNOWN" then $DriveInfo = "may be unformatted" else $DriveInfo = DriveGetLabel($drivearray[$i]) if $DriveInfo = "" then $DriveInfo = "has no label" endif $drivearray[$i] = String($drivearray[$i] & " [" & $DriveInfo & "]") If $i > 1 Then $drivelist = $drivelist & "|" Endif $drivelist = $drivelist & $drivearray[$i] Next EndIf If $drivelist = "" Then ; no suitable drives found, show all drive letters $drivelist = "A:|B:|C:|D:|E:|F:|G:|H:|I:|J:|K:|L:|M:|N:|O:|P:|Q:|R:|S:|T:|U:|V:|W:|X:|Y:|Z:" $defaultdrive = "C:" Else $defaultdrive = $drivearray[1] Endif GUICtrlCreateGroup ("Select Disk ", 10, 110, 310, 50) $Drive = GUICtrlCreateCombo ("", 50,130,230) GUICtrlSetData(-1, $drivelist, $defaultdrive) $OKID = GuiCtrlCreateButton("RUN", 130, 186, 75, 23) GUICtrlSetOnEvent($OKID,"OnOK") GUISetState () While 1 sleep (250) Wend ;--------------- Functions --------------- Func OnOK() $fulllocation = GUICtrlRead($Drive) $location = StringLeft($fulllocation, 2) envset ("Target", $location) IF GUICtrlRead($ReadOnly) = "1" then WinSetState ( "Microsoft Check Disk", "", @SW_MINIMIZE) Run(@ComSpec & " /c" & '@color 17 && @echo. && %systemroot%\system32\chkdsk.exe %Target% & echo. && pause',"") exit ElseIF GUICtrlRead($Fix) = "1" then WinSetState ( "Microsoft Check Disk", "", @SW_MINIMIZE) Run(@ComSpec & " /c" & '@color 17 && @echo. && %systemroot%\system32\chkdsk.exe %Target% /F & echo. && pause',"") exit ElseIF GUICtrlRead($Recover) = "1" then WinSetState ( "Microsoft Check Disk", "", @SW_MINIMIZE) Run(@ComSpec & " /c" & '@color 17 && @echo. && %systemroot%\system32\chkdsk.exe %Target% /R & echo. && pause',"") exit EndIF WinSetState ( "Microsoft Check Disk", "", @SW_RESTORE) EndFunc Func OnCANCEL() Exit EndFunc Func SpecialEvents() If @GUI_CTRLID = $GUI_EVENT_CLOSE Then Exit EndFunc Thanks for help!
FuryCell Posted September 1, 2007 Posted September 1, 2007 (edited) Did you try changing $defaultdrive = "C:" Edit:Removed weird characters from forum update. Edited June 1, 2010 by FuryCell HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
SoulBlade Posted September 1, 2007 Author Posted September 1, 2007 Did you try changing $defaultdrive = "C:"oÝ÷ Úȳz쥩ì·)^ That piece of code in the program works when there is no drives detected. If you try this GUI in your machine, A: or C: will be the default drive; i need D: (an harddisk) to be the default one. Thanks,
FuryCell Posted September 1, 2007 Posted September 1, 2007 That piece of code in the program works when there is no drives detected. If you try this GUI in your machine, A: or C: will be the default drive; i need D: (an harddisk) to be the default one. Thanks, This appears to work. expandcollapse popupAutoItSetOption("TrayIconHide", 1) $Pos=1 #include <GUIConstants.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) Dim $drivearray[100] GuiCreate("CHKDSK 1.0", 330, 235) GUISetIcon("CHKDSK.ICO", 0) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUICtrlCreateGroup ("Check Disk ", 10, 10, 310, 90) $ReadOnly = GUICtrlCreateRadio ("Read-only mode", 40, 30, 100, 20) $Fix = GUICtrlCreateRadio ("Fix errors on the disk", 40, 50, 120, 20) $Recover = GUICtrlCreateRadio ("Locate bad sectors and recovers information", 40, 70, 265, 20) GUICtrlSetState ($Recover,$GUI_CHECKED) GUICtrlCreateGroup ("",-99,-99,1,1) GUICtrlCreateGroup ("",10,170,310,50) ;--------------- Build-up list of disks that can be checked --------------- $drives = DriveGetDrive("ALL") $drivelist = "" $y = 1 For $i = 1 to $drives[0] $DriveType = DriveGetType($drives[$i]) If $DriveType = "Removable" or $DriveType = "Fixed" or $DriveType = "RAMDisk" then $drivearray[$y] = $drives[$i] $y = $y + 1 EndIf Next $drivearray[0] = $y - 1 _ArraySort($drivearray, 0, 0, $y - 1) If NOT @error Then For $i = 1 to $drivearray[0] $drivearray[$i] = StringUpper($drivearray[$i]) $DriveStatus = DriveStatus($drivearray[$i]) if $DriveStatus = "NOTREADY" then $DriveInfo = "drive is empty" elseif $DriveStatus = "UNKNOWN" then $DriveInfo = "may be unformatted" else $DriveInfo = DriveGetLabel($drivearray[$i]) if $DriveInfo = "" then $DriveInfo = "has no label" endif $drivearray[$i] = String($drivearray[$i] & " [" & $DriveInfo & "]") If StringLeft($DriveArray[$i],2) then $Pos=$i If $i > 1 Then $drivelist = $drivelist & "|" Endif $drivelist = $drivelist & $drivearray[$i] Next EndIf If $drivelist = "" Then ; no suitable drives found, show all drive letters $drivelist = "A:|B:|C:|D:|E:|F:|G:|H:|I:|J:|K:|L:|M:|N:|O:|P:|Q:|R:|S:|T:|U:|V:|W:|X:|Y:|Z:" $defaultdrive = "C:" Else $defaultdrive = $drivearray[$Pos] Endif GUICtrlCreateGroup ("Select Disk ", 10, 110, 310, 50) $Drive = GUICtrlCreateCombo ("", 50,130,230) GUICtrlSetData(-1, $drivelist, $defaultdrive) $OKID = GuiCtrlCreateButton("RUN", 130, 186, 75, 23) GUICtrlSetOnEvent($OKID,"OnOK") GUISetState () While 1 sleep (250) Wend ;--------------- Functions --------------- Func OnOK() $fulllocation = GUICtrlRead($Drive) $location = StringLeft($fulllocation, 2) envset ("Target", $location) IF GUICtrlRead($ReadOnly) = "1" then WinSetState ( "Microsoft Check Disk", "", @SW_MINIMIZE) Run(@ComSpec & " /c" & '@color 17 && @echo. && %systemroot%\system32\chkdsk.exe %Target% & echo. && pause',"") exit ElseIF GUICtrlRead($Fix) = "1" then WinSetState ( "Microsoft Check Disk", "", @SW_MINIMIZE) Run(@ComSpec & " /c" & '@color 17 && @echo. && %systemroot%\system32\chkdsk.exe %Target% /F & echo. && pause',"") exit ElseIF GUICtrlRead($Recover) = "1" then WinSetState ( "Microsoft Check Disk", "", @SW_MINIMIZE) Run(@ComSpec & " /c" & '@color 17 && @echo. && %systemroot%\system32\chkdsk.exe %Target% /R & echo. && pause',"") exit EndIF WinSetState ( "Microsoft Check Disk", "", @SW_RESTORE) EndFunc Func OnCANCEL() Exit EndFunc Func SpecialEvents() If @GUI_CTRLID = $GUI_EVENT_CLOSE Then Exit EndFunc HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
SoulBlade Posted September 1, 2007 Author Posted September 1, 2007 That really did the trick! P5ych0Gigabyte, to fully understand the modifications you did in the code, can you show me please, the modifications needed to make C: the default drive instead D: ? :"> Thanks for your patience!
randallc Posted September 1, 2007 Posted September 1, 2007 (edited) Hi, For this to work, change line 43 to; If StringLeft($drivearray[$i], 2)="D:" Then $Pos = $iperhaps? Best, randall Edited September 1, 2007 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
SoulBlade Posted September 1, 2007 Author Posted September 1, 2007 Hi,For this to work, change line 43 to;perhaps?Best, randallYes that's the solution!Many thanks!
am632 Posted March 16, 2010 Posted March 16, 2010 Thanks for this nice bit of coding - very useful tool. I have just 1 query, would it be possible to exclude the drive letter 'A' in the list from computers what have a floppy drive? I just dont remember the last time i needed 2 use it Thanks again
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