#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.6 Prototype

#include <GuiConstants.au3>
#include <Process.au3>

$gui = GuiCreate("7-Zip Switchless Installer Creator", 370, 175,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUICtrlCreateLabel('7-Zip Switchless Installer Creator - by redfive19', 40, 10, 250)
$sfxbutton = GuiCtrlCreateButton("SFX File", 5, 50, 50, 20)
;~  = GuiCtrlCreateButton('...', 50, 50, 10, 20)
$SFX = GuiCtrlCreateInput("", 60, 50, 190, 20)

$config = GuiCtrlCreateInput("", 60, 80, 190, 20)
$configbutton = GuiCtrlCreateButton("Config.txt", 5, 80, 50, 20)

$7Z = GuiCtrlCreateInput("", 60, 110, 190, 20)
$7zbutton = GuiCtrlCreateButton(".7z file ", 5, 110, 50, 20)

$Output = GuiCtrlCreateInput("", 60, 140, 190, 20)
$Outputbutton = GuiCtrlCreateButton("Output exe", 5, 140, 54, 20)

$ok = GuiCtrlCreateButton("OK", 290, 50, 70, 50)
$cancel = GuiCtrlCreateButton("Cancel", 290, 110, 70, 50)
GuiSetState()
While 1
	$msg = GuiGetMsg()
	Select
	Case $msg = $GUI_EVENT_CLOSE
		Exit
	Case $msg = $cancel
		Exit
		
	Case $msg = $configbutton
		$configfilename = FileOpenDialog('Please choose the config.txt file...', '', 'Text files (*.txt)', 1 + 4 )
		If @error <> 1 Then
		GUICtrlSetData($config, $configfilename)
		EndIf
	Case $msg = $7zbutton
		$7zfilename = FileOpenDialog('Please choose the 7-Zip file...', '', '7-Zip files (*.7z)', 1 + 4 )
		GUICtrlSetData($7Z, $7zfilename)
    Case $msg = $sfxbutton
		$sfxfilename = FileOpenDialog('Please choose the SFX file...', '', '7-Zip files (*.sfx)', 1 + 4 )
		GUICtrlSetData($SFX, $sfxfilename)
    Case $msg = $Outputbutton
		$outfilename = FileSaveDialog('Please choose your output EXE file...', '', 'EXE files (*.exe)', 1 + 4 )
		$outfilenamereal = GUICtrlSetData($Output, $outfilename & '.exe')
		
	Case $msg = $ok
	If(StringLen(GUICtrlRead($SFX)) == 0) Then
			MsgBox(0,"SFX", "SFX Required!!")
			ContinueLoop
		ElseIf (StringLen(GUICtrlRead($config)) == 0) Then
			MsgBox(0,"Config.txt", "Config.txt must be chosen!")
			ContinueLoop
		ElseIf (StringLen(GUICtrlRead($7Z)) == 0) Then
			MsgBox(0,".7z", ".7z file must be chosen!")
			ContinueLoop
		ElseIf (StringLen(GUICtrlRead($Output)) == 0) Then
			MsgBox(0,"Output EXE", "Output EXE must be chosen!")
			ContinueLoop
		EndIf
		GUISetState($gui, @SW_HIDE)
		ExitLoop
	
	Case Else
		;;;
	EndSelect
WEnd
WinSetState('7-Zip Switchless Installer Creator', '', @SW_HIDE)
_RunDOS('copy /b ' & '"' & $sfxfilename & '"' & ' + ' & '"' & $configfilename & '"' & ' + ' & '"' & $7zfilename & '" ' & '"' & $outfilename & '.exe' & '"')
;~ FileWrite(@HomeDrive & '\test.txt', $run)
If @error <> 1 Then
MsgBox(0, 'It worked!', 'Woot! It worked!')
EndIf

Exit
#endregion --- GuiBuilder generated code End ---
