; by Ritzelrocker04, Xenobiologist and Oscar
Opt('MustDeclareVars', 1)
#include <GUIConstants.au3>
#include <String.au3>
#include <Array.au3>
#NoTrayIcon

Global Const $WM_LBUTTONDOWN = 0x0201
Global $aFDrive = DriveGetDrive('FIXED'), $aNDrive = DriveGetDrive('NETWORK')
If IsArray($aNDrive) Then
	For $i = 1 To $aNDrive[0]
		_ArrayAdd($aFDrive, $aNDrive[$i])
		$aFDrive[0] += 1
	Next
EndIf
Global $aProgress[$aFDrive[0]], $aName[$aFDrive[0]], $msg = 0, $aVol = 0
Global $GUI = GUICreate('SpaceBar v 2.0', 248, 8 + $aFDrive[0] * 50, @DesktopWidth - 250, 27, $WS_POPUPWINDOW, $WS_EX_TOPMOST)

For $i = 0 To $aFDrive[0] - 1
	$aProgress[$i] = GUICtrlCreateProgress(8, 8 + $i * 50, 230, 17)
	$aName[$i] = GUICtrlCreateInput('', 8, 27 + $i * 50, 230, 21, $ES_READONLY)
Next
Global $trackmenu = GUICtrlCreateContextMenu()
Global $aboutitem = GUICtrlCreateMenuItem('About', $trackmenu)
GUICtrlCreateMenuItem('', $trackmenu)
Global $exititem = GUICtrlCreateMenuItem('Exit', $trackmenu)
GUIRegisterMsg($WM_LBUTTONDOWN, "_WinMove")
GUISetState()

_Update()
AdlibEnable('_Update', 60000) ; Empfehlung AdlibEnable('_Update', 300000) = 5min

While 1
	$msg = GUIGetMsg()
	If $msg = $exititem Or $msg = -3 Or $msg = -1 Then Exit (0)
	If $msg = $aboutitem Then MsgBox(0, 'About', 'SpaceBar v 2.0.0.0' & @CRLF & 'Build 2007-12-18' & @CRLF & 'Copyright by Ritzelrocker04 !')
WEnd

Func _Update()
	For $i = 0 To $aFDrive[0] - 1
		$aVol = _DriveFree($aFDrive[$i + 1])
		GUICtrlSetData($aProgress[$i], $aVol[0])
		GUICtrlSetData($aName[$i], 'Auf ' & $aVol[1] & ' sind ' & $aVol[2] & ' MB frei')
	Next
EndFunc   ;==>_Update

Func _DriveFree($LW)
	Local $TOTAL = DriveSpaceTotal($LW), $FREE = DriveSpaceFree($LW), $aDrive[3] = [StringReplace(Round(($TOTAL - $FREE) / ($TOTAL / 100), 2), '.', ','), _
	StringUpper($LW) & ' (' & DriveGetLabel($LW) & ')', _StringAddComma(StringReplace(Round($FREE, 2), '.', ','), '.', ',')]
	Return $aDrive
EndFunc   ;==>_DriveFree

Func _WinMove($HWnd, $Command, $wParam, $lParam)
	If BitAND(WinGetState($HWnd), 32) Then Return $GUI_RUNDEFMSG
	DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0)
EndFunc   ;==>_WinMove
