#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

$iPass = "Password"

GUIToolbox()

Func GUIToolbox()
    ; Erstellt eine GUI mit verschiedenen Controls.
    Local $hGui = GUICreate("Toolbox", 370, 280)
    ; Erstellt die verschiedenen Schaltflächen
	Local $iSysinfo = GUICtrlCreateButton("Systeminformation", 10, 10, 150, 23)
	Local $iRegedit = GUICtrlCreateButton("REGedit", 10, 150, 150, 23)


	Local $idClose = GUICtrlCreateButton("Schliessen", 130, 220, 85, 23)

    ; Zeigt die GUI
    GUISetState(@SW_SHOW, $hGui)

    ; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslöst.
    While 1
        Switch GUIGetMsg()

			Case $iSysinfo
				Sysinfo()
			;ExitLoop

			Case $iRegedit
				Regedit()
			;ExitLoop
			Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop
        EndSwitch
    WEnd

    GUIDelete($hGui)	; Löscht die vorherige GUI und alle Controls.
EndFunc   ;==>GUIToolbox


Func Login()
$LoginGUI = GUICreate("Password Dialog", 443, 186, -1, -1)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabelUser = GUICtrlCreateLabel("Username:", 8, 25, 70, 20)
$EnterUser = GUICtrlCreateInput("", 86, 25, 201, 21)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabelPass = GUICtrlCreateLabel("Password", 8, 60, 64, 20, 0)
$EnterPass = GUICtrlCreateInput("password", 86, 60, 200, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabelDomaene = GUICtrlCreateLabel("Domäne", 8, 95, 64, 20)
$EnterDomaene = GUICtrlCreateInput("sigg.zz", 88, 95, 201, 21)
$ButtonOk = GUICtrlCreateButton("&OK", 86, 130, 75, 25, $BS_NOTIFY)
$ButtonCancel = GUICtrlCreateButton("&Cancel", 180, 130, 75, 25, $BS_NOTIFY)
GUISetState(@SW_SHOW)

While 1
	$idMsg = GUIGetMsg()
        Switch $idMsg
			Case $ButtonOk
				Global $iUser = GUICtrlRead($EnterUser) ; Rückgabe des Eingabefeldes User
				Global $iPass = GUICtrlRead($EnterPass) ; Rückgabe des Eingabefeldes Pass
				Global $iDom = GUICtrlRead($EnterDomaene) ; Rückgabe des Eingabefeldes Domäne
			ExitLoop

			Case $ButtonCancel
				MsgBox($MB_SYSTEMMODAL, "Titel", "Anmeldung wurde durch Benutzer abgebrochen")
			ExitLoop

		EndSwitch
	WEnd

EndFunc	;==>Login

Func Sysinfo()
	$pcname = @ComputerName
	$username = @UserName
	$ipaddress1 = @IPAddress1
	$ipaddress2 = @IPAddress2
	$OSVersion = RegRead ("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName")
	$sCurrentBuild = RegRead ("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuild")
	$sUBR = RegRead ("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "UBR")
	$OSBuild = $sCurrentBuild & "." & $sUBR
	$sO365Build = RegRead ("HKLM64\SOFTWARE\Microsoft\Office\ClickToRun\Configuration", "VersionToReport")
	$O365Build = StringTrimLeft ($sO365Build, 5)

MsgBox($MB_OK, "Computerinformationen", "Computername: " & $pcname & @CRLF & "Username: " & $username & @CRLF & "IP-Adresse_1: " & $ipaddress1 & @CRLF & "IP-Adresse_2: " & $ipaddress2 & @CRLF & "OS Version: " & $OSVersion & @CRLF & "OS Build: " & $OSBuild & @CRLF & "Office365 Build: " & $O365Build)

EndFunc   ;==>Sysinfo

Func Regedit()
	If $iPass = "Password" Then
		Call (Login())
	Else
		Run(@comspec & ' /c regedit.exe' ,"", @SW_HIDE)
	EndIf
EndFunc   ;==>Regedit
