so, ich habe jetzt mein erstes script geschrieben, funktioniert eigentlich soweit ganz gut, obwohl es sicherlich auch einfacher gehen würde. wie gesagt, bin anfänger.
meine frage nun, würde gern noch bei format die funktion FAT einbinden (für disketten). hab das probiert und scheitere an der dritten combobox. weiß net wie ich das in code verwandeln soll so das man eine meldung bekommt wenn alle comboboxes ON/OFF sind.
naja guckts euch mal an, vielleicht hat jemand eine idee oder andere vorschläge.
Spoiler anzeigen
; Script Start
[/autoit] [autoit][/autoit] [autoit]; Menü & Statusbar --------------------------------------------------------------------------------------------------
#NoTrayIcon
#include <GUIConstants.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
GUICreate("DriveControl v0.1.1",500,370)
[/autoit] [autoit][/autoit] [autoit]Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
Global $defaultstatus = "Ready"
Global $status
Dim $suche1
Dim $suche2
$filemenu = GUICtrlCreateMenu ("&DriveControl")
;$fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
$exititem = GUICtrlCreateMenuitem ("Beenden",$filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$helpmenu = GUICtrlCreateMenu ("?")
;$saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
;GUICtrlSetState(-1,$GUI_DISABLE)
$infoitem = GUICtrlCreateMenuitem ("Über",$helpmenu)
;$recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)
[/autoit] [autoit][/autoit] [autoit];$separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line
[/autoit] [autoit][/autoit] [autoit]$viewmenu = GUICtrlCreateMenu("Ansicht",-1,1) ; is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuitem ("Status",$viewmenu)
GUICtrlSetState(-1,$GUI_CHECKED)
$exitbutton = GUICtrlCreateButton ("Beenden",215,300,70,20)
GUICtrlSetState(-1,$GUI_FOCUS)
$statuslabel = GUICtrlCreateLabel ($defaultstatus,0,333,500,16,BitOr($SS_SIMPLE,$SS_SUNKEN))
[/autoit] [autoit][/autoit] [autoit]GUISetState ()
; Menü & Statusbar Ende --------------------------------------------------------------------------------------------
GUICtrlCreateGroup ("Laufwerke", 15, 15, 470, 85) ;Öffne Gruppe Laufwerke
; Alle Laufwerke ---------------------------------------------------------------------------------------------------
$AllLw =""
$all = DriveGetDrive( "fixed" )
If NOT @error Then
For $a = 1 to $all[0]
$AllLw &= $all[$a] & "\ "
Next
EndIf
; Festplatten ------------------------------------------------------------------------------------------------------
$Drives =""
$drive = DriveGetDrive( "fixed" )
If NOT @error Then
For $i = 1 to $drive[0]
$Drives &= $drive[$i] & "\ "
Next
EndIf
If $drive < 1 Then
GUICtrlCreateLabel("0 Festplatten gefunden.", 25,35,300)
Else
GUICtrlCreateLabel("" & $drive[0] & " Festplatte(n) gefunden: ( " & $Drives & ")" ,25,35,300)
EndIf
; Wechseldatenträger -----------------------------------------------------------------------------------------------
$Removable =""
$remove = DriveGetDrive( "removable" )
If NOT @error Then
For $f = 1 to $remove[0]
$Removable &= $remove[$f] & "\ "
Next
EndIf
If $remove < 1 Then
GUICtrlCreateLabel("0 Wechseldatenträger gefunden.", 25,55,300)
Else
GUICtrlCreateLabel("" & $remove[0] & " Wechseldatenträger gefunden: ( " & $Removable & ")" ,25,55,300)
EndIf
; CD-ROM ----------------------------------------------------------------------------------------------------------
$Cd =""
$cdrom = DriveGetDrive( "cdrom" )
If NOT @error Then
For $g = 1 to $cdrom[0]
$Cd &= $cdrom[$g] & "\ "
Next
EndIf
If $cdrom < 1 Then
GUICtrlCreateLabel("0 CD-ROM Laufwerke gefunden.", 25,75,300)
Else
GUICtrlCreateLabel("" & $cdrom[0] & " CD-ROM Laufwerk(e) gefunden: ( " & $Cd & ")" ,25,75,300)
EndIf
GUICtrlCreateGroup ("",-99,-99,1,1) ;Schließe Gruppe Laufwerke
[/autoit] [autoit][/autoit] [autoit];-----------------------------------------------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]GUICtrlCreateGroup ("Datenträger formatieren", 15, 110, 470, 85) ;Öffne Gruppe formatieren
[/autoit] [autoit][/autoit] [autoit]GUICtrlCreateLabel ("Bitte den zu formatierenden Datenträger angeben:", 25, 130 , 300)
[/autoit] [autoit][/autoit] [autoit]$input = GUICtrlCreateInput("", 50, 150, 15)
GUICtrlCreateLabel (":\", 70, 153, 20)
$ntfs = GUICtrlCreateCheckbox ("Ntfs", 90, 150)
GUICtrlSetState ( $ntfs, $GUI_UNCHECKED )
$fat = GUICtrlCreateCheckbox ("Fat32", 150, 150)
GUICtrlSetState ( $fat, $GUI_UNCHECKED )
$formatbutton = GUICtrlCreateButton("FORMAT", 300, 150, 60, 20)
$helpformat = GUICtrlCreateButton (" ? ", 370, 150, 20, 20)
GUICtrlCreateGroup ("",-99,-99,1,1) ;Schließe Gruppe formatieren
;----------------------------------------------------------------------------------------------------------------
GUICtrlCreateGroup ("Datenträger defragmentieren", 15, 205, 470, 85) ;Öffne Gruppe defragmentieren
GUICtrlCreateLabel ("Bitte den zu defragmentiernden Datenträger angeben:", 25, 225 , 300)
[/autoit] [autoit][/autoit] [autoit]$defraginput = GUICtrlCreateInput("", 50, 245, 15)
GUICtrlCreateLabel (":\", 70, 248, 20)
$defragbutton = GUICtrlCreateButton("DEFRAG", 300, 245, 60, 20)
$helpdefrag = GUICtrlCreateButton (" ? ", 370, 245, 20, 20)
GUICtrlCreateGroup ("",-99,-99,1,1) ;Schließe Gruppe defragmentieren
;---------------------------------------------------------------------------------------------------------------
While 1
$msg = GUIGetMsg()
; Format Hilfe -------------------------------------------------------------------------------------------------
If $msg = $helpformat Then
MsgBox (32, "Hilfe : Formatierung", @CRLF & "Formatiert werden können folgende Dateisysteme:"& @CRLF & @CRLF &"NTFS: Dateisystem für Festplatten mit Windows XP. (Kann nicht von Windows 9x gelesen werden)" & @CRLF & "FAT 32: Dateisystem für Festplatten mit Windows 9x." & @CRLF)
EndIf
; Format Hilfe Ende --------------------------------------------------------------------------------------------
; Defrag Hilfe -------------------------------------------------------------------------------------------------
If $msg = $helpdefrag Then
MsgBox (32, "Hilfe : Defragmentierung", @CRLF & "Mit der DEFRAG Funktion können Festplatten, Disketten und USB-Sticks defragmentiert werden." & @CRLF)
EndIf
; Defrag Hilfe Ende --------------------------------------------------------------------------------------------
; Prüfe auf Laufwerke für Formatierung -------------------------------------------------------------------------
If $msg = $formatbutton Then
$suche1 = _ArraySearch($all, GUICtrlRead($input), 0, 0, 0, True) Or $suche2 = _ArraySearch($remove, GUICtrlRead($input), 0, 0, 0, True)
If @error Then
MsgBox(0,"Fehler","Dieses Laufwerk kann nicht formatiert werden oder existiert nicht") ;Fehlermeldung
;Else
ElseIf GUICtrlRead ($ntfs) = GUICtrlRead ($fat) Then
MsgBox(0,"Fehler","Wählen sie NTFS oder FAT32 als Dateisystem!")
;Else
ElseIf GUICtrlRead ($ntfs) = $GUI_CHECKED Then
$msgabort = MsgBox(33,"NTFS formatieren","Laufwerk "& GUICtrlRead($input) &": mit NTFS formatieren?") ;Info
If $msgabort = 2 Then MsgBox(64,"Formatierung abbrechen" , "Formatierung abgebrochen")
If $msgabort = 1 Then
Run(@WindowsDir&'\system32\cmd.exe',"")
WinWait(@WindowsDir & "\system32\cmd.exe","")
If Not WinActive(@WindowsDir& "\system32\cmd.exe","") Then WinActivate(@WindowsDir & "\system32\cmd.exe","")
WinWaitActive(@WindowsDir & "\system32\cmd.exe","")
Send("format{SPACE}" & GUICtrlRead($input) & "{SHIFTDOWN}.{SHIFTUP}{SPACE}{SHIFTDOWN}7{SHIFTUP}fs{SHIFTDOWN}.{SHIFTUP}ntfs")
Sleep(3000)
Send("{ENTER}")
Sleep(3000)
send("j{ENTER}")
Sleep(2000)
send("{ENTER}")
send("exit{ENTER}")
MsgBox(64,"Laufwerk "& GUICtrlRead($input) &": formatiert","Dieses Laufwerk wurde mit NTFS formatiert") ;Ende
EndIf
Else
$msgabort = MsgBox(33,"FAT32 formatieren","Laufwerk "& GUICtrlRead($input) &": mit FAT32 formatieren?") ;Info
If $msgabort = 2 Then MsgBox(64,"Formatierung abbrechen" , "Formatierung abgebrochen")
If $msgabort = 1 Then
Run(@WindowsDir & '\system32\cmd.exe',"")
WinWait(@WindowsDir & "\system32\cmd.exe","")
If Not WinActive(@WindowsDir & "\system32\cmd.exe","") Then WinActivate(@WindowsDir & "\system32\cmd.exe","")
WinWaitActive(@WindowsDir & "\system32\cmd.exe","")
Send("format{SPACE}" & GUICtrlRead($input) & "{SHIFTDOWN}.{SHIFTUP}{SPACE}{SHIFTDOWN}7{SHIFTUP}fs{SHIFTDOWN}.{SHIFTUP}fat32")
Sleep(3000)
Send("{ENTER}")
Sleep(3000)
send("j{ENTER}")
Sleep(2000)
send("{ENTER}")
send("exit{ENTER}")
MsgBox(64,"Laufwerk "& GUICtrlRead($input) &": formatiert","Dieses Laufwerk wurde mit FAT32 formatiert") ;Ende
EndIf
EndIf
EndIf
; Ende Prüfung ---------------------------------------------------------------------------------------------------
; Prüfe auf Laufwerke für Defragmentierung -------------------------------------------------------------------------
If $msg = $defragbutton Then
$suche1 = _ArraySearch($all, GUICtrlRead($defraginput), 0, 0, 0, True) Or $suche2 = _ArraySearch($remove, GUICtrlRead($defraginput), 0, 0, 0, True)
If @error Then
MsgBox(0,"Fehler","Dieses Laufwerk kann nicht defragmentiert werden oder existiert nicht") ;Fehlermeldung
Else
$defragabort = MsgBox(33,"Datenträger "& GUICtrlRead($defraginput) &": defragmentieren","Soll Laufwerk "& GUICtrlRead($defraginput) & ": defragmentiert werden?") ;Info
If $defragabort = 2 Then MsgBox(64,"Defragmentierung abbrechen" , "Defragmentierung abgebrochen")
If $defragabort = 1 Then
Run(@WindowsDir & '\system32\cmd.exe',"")
WinWait(@WindowsDir & "\system32\cmd.exe","")
If Not WinActive(@WindowsDir & "\system32\cmd.exe","") Then WinActivate(@WindowsDir & "\system32\cmd.exe","")
WinWaitActive(@WindowsDir & "\system32\cmd.exe","")
Send("defrag{SPACE}" & GUICtrlRead($defraginput) & "{SHIFTDOWN}.{SHIFTUP}{CTRLDOWN}{ALTDOWN}ß{CTRLUP}{ALTUP}")
Sleep(3000)
Send("{ENTER}")
Sleep(2000)
send("{ENTER}")
send("exit{ENTER}")
MsgBox(64,"Laufwerk "& GUICtrlRead($defraginput) &": defragmentiert","Laufwerk "& GUICtrlRead($defraginput) &": wurde defragmentiert") ;Ende
EndIf
EndIf
EndIf
; Ende Prüfung ---------------------------------------------------------------------------------------------------
If $msg = $viewstatusitem Then
If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
GUICtrlSetState($statuslabel,$GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
GUICtrlSetState($statuslabel,$GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $exitbutton Or $msg = $exititem Then ExitLoop
If $msg = $infoitem Then Msgbox(64,"Über",@CRLF &"DriveControl v0.1.1 "& @CRLF &"License: FREE" & @CRLF &"Copyright (c)2007 Sebastian Zeuch / SZ-soft. "& @CRLF)
WEnd
GUIDelete()
Exit
[/autoit] [autoit][/autoit] [autoit][/autoit]danke! gruß seb!