#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=Beta
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#region ### include ###
#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>


#include "Installation.au3"
#include"Info.au3"
#endregion ### include ###
;=============
#region ### ini ###
$opt_path = IniRead('Option.ini', 'Install_Path', 'Path', 'C:\Program Files (x86)')
#endregion ### ini ###
;=============
#region ### Global ###
Global $Instdir, $akpath, $hGui, $ListView
#endregion ### Global ###
;=============
#region ### Global Style ###
Global $style = BitOR($WS_SYSMENU, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER)
#endregion ### Global Style ###
;=============
#region ### Array angaben: BoxNames & Funktions ###
;=============Install Names=============
Global $BoxNames64_32[70] = ['Abiword', 'Adobe Air', 'Adobe Flash', 'Adobe Reader', 'Adobe Shockwave', 'Audacity', 'AutoIt', 'Avast', 'AVG Antivirus', 'Avira', 'Boinc', 'CCleaner', 'CDBunerXP', 'Comodo Antivirus', 'Comodo Firewall', 'Copernic Desktop Search', 'Cute PDF Writer', 'Daemon Tools Lite', 'Device Manager Pro','Dropbox', 'DSynchronize', 'DVDisaster', 'EasyCleaner', 'Eraser', 'Exact Audio Copy', 'Exif Sorter', 'Foobar 2000', 'Foxit Reader', 'Free Commander', 'Free Minder', 'Geosetter', 'Google Earth', 'HxD', 'ImgBurn', 'Inkscape', 'Irfanview', 'Mozilla Firefox 3.6', 'Mozilla Firefox 4', 'Mozilla Thunderbird', 'MP3Gain', 'MP3Tag', 'MUCommander', 'NotePad++', 'OpenIffice', 'Opera', 'PaintDotNet', 'PC Instector File Recovery', 'PDF Creator', 'Pidgin', 'Process Explorer', 'QuickPar', 'Recuva', 'RenameFiles', 'Skype','Soluto', 'Spybit Search and Destroy', 'TCPView', 'Tor Browser', 'Toucan', 'Truecrypt', 'Universal Extractor', 'Virtual CloneDrive', 'VirtualBox', 'Vist ShutDown Timer', 'VLC Media Player', 'WinAmp', 'xMedia Recorde', 'XnView', 'XviD']
Global $BoxNames64[4] = ['7-zip', 'Java', 'Media Player Classic HC', 'WinRar']
Global $BoxNames86[4] = ['7-zip64', 'Java64', 'Media Player Classic HC64', 'WinRar64']
;=======================================
;=============Install Func==============
Global $aFunktions[71] = ['Abiword', 'Adobe_Air', 'Adobe_Flash', 'Adobe_Reader', 'Adobe_Shockwave', 'Audacity', 'AutoIt', 'Avast', 'AVG_Antivirus', 'Avira', 'Boinc', 'CCleaner', 'CDBurnerXP', 'Comodo_Antivirus', 'Comodo Firewall', 'Copernic Desktop Search', 'Cute PDF Writer', 'Daemon Tools Lite', 'Device Manager Pro','Dropbox', 'DSynchronize', 'DVDisaster', 'EasyCleaner', 'Eraser', 'Exact Audio Copy', 'Exif Sorter', 'Foobar 2000', 'Foxit Reader', 'Free Commander', 'Free Minder', 'Geosetter', 'Google Earth', 'HxD', 'ImgBurn', 'Inkscape', 'Irfanview', 'MokaFive', 'Mozilla Firefox 3.6', 'Mozilla Firefox 4', 'Mozilla Thunderbird', 'MP3Gain', 'MP3Tag', 'MUCommander', 'NotePad++', 'OpenIffice', 'Opera', 'PaintDotNet', 'PC Instector File Recovery', 'PDF Creator', 'Pidgin', 'Process Explorer', 'QuickPar', 'Recuva', 'RenameFiles', 'Skype','Soluto', 'Spybit Search and Destroy', 'TCPView', 'Tor Browser', 'Toucan', 'Truecrypt', 'Universal Extractor', 'Virtual CloneDrive', 'VirtualBox', 'Vist ShutDown Timer', 'VLC Media Player', 'WinAmp', 'xMedia Recorde', 'XnView', 'XviD']
Global $X64Funktions[4] = ['7-zip', 'Java', 'Media Player Classic HC', 'WinRar']
Global $X86Funktions[4] = ['_7zip86', 'Java86','_MediaPlayerClassicHC86', '_WinRar86']
;========================================
;========Checkbox Names _SpezOpt=========
Global $Checkbox[14]
Global $CheckNames[14] = ['RAR', 'Zip', 'CAB', 'ARJ', 'LZH', 'ACE', '7-Zip', 'TAR', 'GZip', 'UUE', 'BZ2', 'JAR', 'ISO', 'Z']
Global $Left[14] = [16, 72, 128, 184, 240, 296, 352, 408, 464, 520, 16, 72, 128, 184]
Global $Top[14] = [352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 376, 376, 376, 376]
;RAR ZIP CAB ARJ LZH ACE 7ZIP TAR GZIP UUE BZ2 JAR ISO Z
;========================================
#endregion ### Array angaben: BoxNames & Funktions ###
;=============
#region ### GUI ###
$hGui = GUICreate('Auto Install', 421, 421, -1, -1, $style)
GUICtrlCreateGroup('( X86 ) 32Bit und ( X64 ) 64Bit', 10, 10, 230, 400)
GUICtrlCreateGroup('Install Manager', 250, 10, 161, 200)
GUICtrlCreateGroup('( ' & @OSArch & ' )' & ' Bit only', 248, 210, 161, 200)
$install = GUICtrlCreateLabel('Ausgewählte Installieren', 264, 30, 118, 17)
$deinstall = GUICtrlCreateLabel('Deinstallations Info', 264, 50, 131, 17)
$opt = GUICtrlCreateLabel('Optionen', 304, 160, 47, 17)
$exit = GUICtrlCreateLabel('Beenden', 304, 180, 47, 17)
$akpath = GUICtrlCreateLabel('Install Pfad: ' & @CRLF & $opt_path, 264, 120, 139, 33)
#endregion ### GUI ###
;=============
#region ### ListView ###
$Header = 'Name'
$ListView = GUICtrlCreateListView($Header, 20, 25, 210, 370, $LVS_SINGLESEL, $LVS_EX_CHECKBOXES)
_GUICtrlListView_RegisterSortCallBack($ListView)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSendMsg($ListView, $LVM_SETCOLUMNWIDTH, 0, 193)

For $i = 0 To UBound($BoxNames64_32) - 1
	$item32_64 = GUICtrlCreateListViewItem($BoxNames64_32[$i], $ListView)
Next
#endregion ### ListView ###
;=============
#region ### ListView Os ###
$HeaderOS = 'Name'
$ListViewOS = GUICtrlCreateListView($HeaderOS, 258, 225, 141, 170, $LVS_SINGLESEL, $LVS_EX_CHECKBOXES)
_GUICtrlListView_RegisterSortCallBack($ListViewOS)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSendMsg($ListViewOS, $LVM_SETCOLUMNWIDTH, 0, 140)

If @OSArch = 'X64' Then
	For $a = 0 To UBound($BoxNames64) - 1
		$item64 = GUICtrlCreateListViewItem($BoxNames64[$a], $ListViewOS)
	Next
ElseIf @OSArch = 'X86' Then
	For $b = 0 To UBound($BoxNames86) - 1
		$item86 = GUICtrlCreateListViewItem($BoxNames86[$b], $ListViewOS)
	Next
EndIf
#endregion ### ListView Os ###
GUISetState(@SW_SHOW)
;=============
#region ### EVENT ###
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $exit
			Exit
		Case $opt
			_opt($Instdir)
		Case $install
			_Install()
		Case $deinstall
			_Deinstall()
	EndSwitch
WEnd
#endregion ### EVENT ###
;=============
#region ### _opt() ###
Func _opt($Instdir)
	$ini = IniRead('Option.ini', 'Install_Path', 'Path', 'C:\Program Files (x86)')
	$option = GUICreate('Optionen', 434, 147, -1, -1, $style)
	GUICtrlCreateGroup('', 10, 10, 410, 120)
	$Instdir = GUICtrlCreateInput($ini, 30, 30, 350, 21,$ES_READONLY)
	$path = GUICtrlCreateButton('...', 380, 30, 15, 20)
	GUICtrlCreateLabel('Legt den Standard Installations Pfad fest', 30, 56, 198, 15)
	$SpezOpt = GUICtrlCreateLabel('Prog-Spez Optionen', 310, 87, -1, 17)
	$save = GUICtrlCreateLabel('Speichern', 310, 104, 50, 17)
	$back = GUICtrlCreateLabel('Zurück', 368, 104, 38, 15)
	$DCut = GUICtrlCreateCheckbox('Desktop Shortcut', 30, 87, 137, 17)
	$QLCut = GUICtrlCreateCheckbox('Quick Launch Shortcuts', 30, 104, 137, 17)
	If IniRead('Option.ini', 'Shortcuts', 'Desktop Shortcuts', '') = 'Ja' Then
		ControlCommand($option,'','[CLASS:Button; INSTANCE:3]','Check', '')
	ElseIf IniRead('Option.ini', 'Shortcuts', 'Desktop Shortcuts', '') = 'Nein' Then
		ControlCommand($option,'','[CLASS:Button; INSTANCE:3]','UnCheck', '')
	EndIf
	If IniRead('Option.ini', 'Shortcuts', 'Quick Launch Shortcuts', '') = 'Ja' Then
		ControlCommand($option,'','[CLASS:Button; INSTANCE:4]','Check', '')
	ElseIf IniRead('Option.ini', 'Shortcuts', 'Quick Launch Shortcuts', '') = 'Nein' Then
		ControlCommand($option,'','[CLASS:Button; INSTANCE:4]','UnCheck', '')
	EndIf
	GUISetState(@SW_SHOW, $option)
	;=============
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $back
				GUISetState(@SW_HIDE, $option)
				Return
			Case $path
                $pathinst = FileSelectFolder('Installations Verzeichniss auswählen', '')
                If (Not @error) Then
                    If (StringRight($pathinst, 1) <> '\') Then
                        $pathinst = $pathinst & '\'
                    EndIf
                    $opt_path = $pathinst
                    GUICtrlSetData($akpath, 'Install Pfad: ' & @CRLF & $opt_path)
                    ControlSetText('', '', $Instdir, $opt_path)
                EndIf
			Case $save
                IniWrite('Option.ini', 'Install_Path', 'Path', GUICtrlRead($Instdir))
                If GUICtrlRead($DCut) = 1 Then
                    IniWrite('Option.ini', 'Shortcuts', 'Desktop Shortcuts', 'Ja')
                Else
                    IniWrite('Option.ini', 'Shortcuts', 'Desktop Shortcuts', 'Nein')
                endif
                If GUICtrlRead($QLCut) = 1 Then
                    IniWrite('Option.ini', 'Shortcuts', 'Quick Launch Shortcuts', 'Ja')
                Else
                    IniWrite('Option.ini', 'Shortcuts', 'Quick Launch Shortcuts', 'Nein')
                endif
                MsgBox(0,'Optionen','Optionen Gespeichert',2)
                Sleep(500)
                ControlClick('Optionen','','[CLASS:Static; INSTANCE:4]')
			Case $SpezOpt
				_SpezOpt()
		EndSwitch
	WEnd
EndFunc   ;==>_opt
#endregion ### _opt() ###
;=============
#region ### _SpezOpt() ###
Func _SpezOpt()
	$ini_konto = IniRead('Spez-Option.ini', 'Dropbox', 'Konto-Name', '')
	$ini_pw = IniRead('Spez-Option.ini', 'Dropbox', 'Konto-Password', '')
	$SpezOptGUI = GUICreate('SpezOpt',625, 475,-1,-1,$style)
	GUICtrlCreateGroup('Programm Speziefische Optionen',8,8,601,153)
	GUICtrlCreateGroup('Dropbox',16,24,585,115)
	GUICtrlCreateGroup('Info',312,32,281,89)
	GUICtrlCreateLabel('Besitzen Sie ein Dropbox-Konto?',24,40,160,17)
	GUICtrlCreateLabel('Konto Name',24,64,60,17)
	GUICtrlCreateLabel('Konto Password',24,88,78,17)
	GUICtrlCreateLabel('Ihre Kontodaten werden in der Option.ini Gespeichert.'&@CRLF&@CRLF&'Nach der Installation von Dropbox, werden Sie Gefragt ob der Eintrag in der Option.ini Gelöscht werden soll',320,48,266,68)
	$KsV = GUICtrlCreateLabel('Konto-Daten vorab Erstellen',24,142,137,17)
	$Ja = GUICtrlCreateRadio('Ja',184,40,33,17)
	$Nein = GUICtrlCreateRadio('Nein',224,40,41,17)
	$Konto = GUICtrlCreateInput($ini_konto,104,64,201,21)
	$Password = GUICtrlCreateInput($ini_pw,104,88,201,21)
	$Avast = GUICtrlCreateGroup('Avast', 8, 168, 601, 73)
	GUICtrlCreateLabel('Avast wird mit dem Parameter /verysilent Installiert, dass heisst das es eine Volle Unsichtbare Installation ist.'&@CRLF&'Durch die /verysilent Installation wird Google Chrome mit Installiert', 16, 184, 590, 50)
	GUICtrlCreateGroup('WinRAR', 8, 336, 601, 73)
	GUICtrlCreateGroup('',488, 410, 121, 50)
	$Speichern = GUICtrlCreateLabel('Speichern',496, 430, 52, 17)
	$Zur = GUICtrlCreateLabel('Zurück',560, 430, 35, 17)

	For $Cii = 0 To UBound($CheckNames) - 1
		$Checkbox[$Cii] = GUICtrlCreateCheckbox($CheckNames[$Cii], $Left[$Cii], $Top[$Cii], 49, 17)
		If IniRead('Spez-Option.ini', 'WinRAR', $CheckNames[$Cii], 'Nein') = 'Ja' Then
			ControlCommand($SpezOptGUI,'',$CheckNames[$Cii],'Check')
		Else
			ControlCommand($SpezOptGUI,'',$CheckNames[$Cii],'UnCheck')
		EndIf
	Next

	If IniRead('Spez-Option.ini','Dropbox','Konto','') = 'Ja' Then
		ControlCommand($SpezOptGUI,'','[CLASS:Button; INSTANCE:5]','UnCheck','')
		ControlCommand($SpezOptGUI,'','[CLASS:Button; INSTANCE:4]','Check','')
	ElseIf IniRead('Spez-Option.ini','Dropbox','Konto','') = 'Nein' Then
		ControlCommand($SpezOptGUI,'','[CLASS:Button; INSTANCE:4]','UnCheck','')
		ControlCommand($SpezOptGUI,'','[CLASS:Button; INSTANCE:5]','Check','')
	EndIf



	GUISetState(@SW_SHOW)
	;=============
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $Zur
				GUISetState(@SW_HIDE, $SpezOptGUI)
				Return
			Case $Speichern
				If GUICtrlRead($Ja) = 1 Then
					IniWrite('Spez-Option.ini', 'Dropbox', 'Konto', 'Ja')
					IniWrite('Spez-Option.ini', 'Dropbox', 'Konto-Name', GUICtrlRead($Konto))
					IniWrite('Spez-Option.ini', 'Dropbox', 'Konto-Password', GUICtrlRead($Password))
					MsgBox(0,'Optionen','Optionen Gespeichert',2)
				Else
					If MsgBox(4,'Konto Erstellen','Möchten Sie die Daten für die Erstellung eines Dropbox-Kontos vorab Speichern?') = 6 Then
						_Konto_Erst()
					Else
						IniWrite('Spez-Option.ini', 'Dropbox', 'Konto', 'Nein')
						IniWrite('Spez-Option.ini', 'Dropbox', 'Konto-Name', '')
						IniWrite('Spez-Option.ini', 'Dropbox', 'Konto-Password', '')
					EndIf
				EndIf

				For $i = 0 To 13
					If BitAND(GUICtrlRead($Checkbox[$i]), $GUI_CHECKED) = $GUI_CHECKED Then
						IniWrite('Spez-Option.ini', 'WinRAR', $CheckNames[$i], 'Ja')
					Else
						IniWrite('Spez-Option.ini','WinRAR', $CheckNames[$i], 'Nein')
					EndIf
				Next


				Sleep(500)
				ControlClick('SpezOpt','','[CLASS:Static; INSTANCE:8]')
				Sleep(500)
				ControlClick('Optionen','','[CLASS:Static; INSTANCE:4]')
			Case $KsV
				_Konto_Erst()
		EndSwitch
	WEnd
EndFunc
#endregion ### _SpezOpt() ###
;=============
#region ### _Konto_Erst() ###
Func _Konto_Erst()
	$ini_VN = IniRead('Spez-Option.ini','Konto vorab save','Vorname','')
	$ini_NN = IniRead('Spez-Option.ini','Konto vorab save','Nachname','')
	$ini_EM = IniRead('Spez-Option.ini','Konto vorab save','E-Mail','')
	$ini_PW = IniRead('Spez-Option.ini','Konto vorab save','Kennwort','')
	$KvS = GUICreate('Konto vorab Speicherung', 306, 162,-1, -1,$style)
	GUICtrlCreateGroup('', 8, 8, 289, 145)
	$Vorname = GUICtrlCreateLabel(' Vorname:', 24, 24, 52, 17)
	$Nachname = GUICtrlCreateLabel('Nachname:', 16, 48, 59, 17)
	$email = GUICtrlCreateLabel('E-Mail:', 40, 72, 36, 17)
	$Kennwort = GUICtrlCreateLabel('Kennwort:', 24, 96, 52, 17)
	$InputVN = GUICtrlCreateInput($ini_VN, 80, 24, 209, 21)
	$InputNN = GUICtrlCreateInput($ini_NN, 80, 48, 209, 21)
	$InputEM = GUICtrlCreateInput($ini_EM, 80, 72, 209, 21)
	$InputPW = GUICtrlCreateInput($ini_PW, 80, 96, 209, 21)
	$Speichern_KvS = GUICtrlCreateLabel('Speichern', 184, 128, 52, 17)
	$Zur_KvS = GUICtrlCreateLabel('Zurück', 248, 128, 38, 17)
	GUISetState(@SW_SHOW)

	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $Zur_KvS
				GUISetState(@SW_HIDE, $KvS)
				Return
			Case $Speichern_KvS()
				IniWrite('Spez-Option.ini','Konto vorab save','Vorname',GUICtrlRead($InputVN))
				IniWrite('Spez-Option.ini','Konto vorab save','Nachname',GUICtrlRead($InputNN))
				IniWrite('Spez-Option.ini','Konto vorab save','E-Mail',GUICtrlRead($InputEM))
				IniWrite('Spez-Option.ini','Konto vorab save','Kennwort',GUICtrlRead($InputPW))
				MsgBox(0,'Info','Gespeichert',2)
				Sleep(500)
				ControlClick('Konto vorab Speicherung','','[CLASS:Static; INSTANCE:6]')
				Sleep(500)
				ControlClick('SpezOpt','','[CLASS:Static; INSTANCE:7]')
				Sleep(500)
				ControlClick('Optionen','','[CLASS:Static; INSTANCE:4]')
		EndSwitch
	WEnd
EndFunc
#endregion ### _Konto_Erst() ###
;=============
#region ### _Install() ###
Func _Install()
	For $i = 0 To _GUICtrlListView_GetItemCount($listview) - 1
        If _GUICtrlListView_GetItemChecked($listview, $i) Then Call($aFunktions[$i])
    Next
    If @OSArch = 'X64' Then
        For $a = 0 To _GUICtrlListView_GetItemCount($listviewOs) -1
            If _GUICtrlListView_GetItemChecked($listviewOs, $a) Then Call($X64Funktions[$a])
        Next
    ElseIf @OSArch = 'X86' Then
        For $b = 0 To _GUICtrlListView_GetItemCount($listviewOs) -1
            If _GUICtrlListView_GetItemChecked($listviewOs, $b) Then Call($X86Funktions[$b])
        Next
    EndIf
	_Finish()
EndFunc   ;==>_Install
#endregion ### _Install() ###
;=============
#region ### _Deinstall() ###
Func _Deinstall()
	MsgBox(0,'Deinstallations Info','Es wird Empfohlen, Programme über die' & @CRLF & '"Systemsteuerung -> Programme und Funktionen"' & @CRLF & 'zu Deinstallieren.' & @CRLF & @CRLF & 'Win7:' & @CRLF & 'Falls Ihre "Anzeige:" auf "Kategorie" Eingestellt ist.' & @CRLF & '"Programme -> Programme und Funktionen"')
EndFunc
#endregion ### _Deinstall() ###