#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
;// options
#NoTrayIcon
;// vars
$path = "c:\dummy.bin"
;// gui
$main_gui = GUICreate("Dummy file maker", 353, 96, -1, -1)
$browse_input = GUICtrlCreateInput($path, 8, 24, 313, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$browse_button = GUICtrlCreateButton("...", 320, 24, 27, 21, 0)
$size_input = GUICtrlCreateInput("0", 8, 64, 105, 21)
$Updown1 = GUICtrlCreateUpdown($size_input)
$store_label = GUICtrlCreateLabel("Store location. Avaliable free space on drive: " & Round(DriveSpaceFree(StringLeft(GUICtrlRead($browse_input), 3)), 1) & "MB", 8, 8, 353, 15)
$Label2 = GUICtrlCreateLabel("Size", 8, 48, 24, 15)
$type_input = GUICtrlCreateCombo("KB", 120, 64, 65, 25)
GUICtrlSetData(-1, "MB|GB")
$create_button = GUICtrlCreateButton("Create", 192, 64, 75, 25, 0)
$exit_button = GUICtrlCreateButton("Exit", 272, 64, 75, 25, 0)
GUISetState(@SW_SHOW)
;// main loop
Do
$msg = GUIGetMsg()
If $msg = $browse_button then
$path = filesaveDialog("Save dummy file to ...", "c:", "All (*.*)", 2, "dummy.bin")
If FileExists($path) then
MsgBox(0, "Dummy file maker", "File must NOT exist.")
Else
If $path = "" then
$path = "c:\dummy.bin"
GUICtrlSetData($browse_input, $path)
GUICtrlSetData($store_label, "Store location. Avaliable free space on drive: " & Round(DriveSpaceFree(StringLeft(GUICtrlRead($browse_input), 3)), 1) & "MB")
Else
GUICtrlSetData($browse_input, $path)
GUICtrlSetData($store_label, "Store location. Avaliable free space on drive: " & Round(DriveSpaceFree(StringLeft(GUICtrlRead($browse_input), 3)), 1) & "MB")
EndIf
EndIF
EndIf
If $msg = $create_button then
$size = GUICtrlRead($size_input)
$size_check = $size
If GUICtrlRead($type_input) = "KB" then
$size = $size * 1024
EndIf
If GUICtrlRead($type_input) = "MB" then
$size = $size * 1024 * 1024
EndIf
If GUICtrlRead($type_input) = "GB" then
$size = $size * 1024 * 1024 * 1024
EndIf
If $size <= 0 then
MsgBox(0, "Dummy file maker", "Desired size cannot be negative or 0 (zero).")
Else
$answer = MsgBox(4, "Dummy file maker", "Please confirm the folowing:" & @CRLF & "Dummy file size: " & $size & "KB" & @CRLF & "Destination: " & GUICtrlRead($browse_input))
If $answer = 6 then
_RunDOS("fsutil file createnew """ & GUICtrlRead($browse_input) & """z " & $size)
MsgBox(0, "Dummy file maker", "Creation completed.")
Else
MsgBox(0, "Dummy file maker", "Creation aborted.")
EndIf
EndIf
EndIf
Until $msg = $GUI_EVENT_CLOSE or $msg = $exit_button