#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Fileversion=1.1.0
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Res_Language=1031
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

HotKeySet("{/}", "dividieren")
HotKeySet("{*}", "multiplizieren")
HotKeySet("{+}", "addieren")
HotKeySet("{-}", "subtrahieren")
HotKeySet("{ENTER}", "gleich")
HotKeySet("{NUMPAD1}", "nummer1")
HotKeySet("{NUMPAD2}", "nummer2")
HotKeySet("{NUMPAD3}", "nummer3")
HotKeySet("{NUMPAD4}", "nummer4")
HotKeySet("{NUMPAD5}", "nummer5")
HotKeySet("{NUMPAD6}", "nummer6")
HotKeySet("{NUMPAD7}", "nummer7")
HotKeySet("{NUMPAD8}", "nummer8")
HotKeySet("{NUMPAD9}", "nummer9")
HotKeySet("{NUMPAD0}", "nummer0")
HotKeySet("{NUMPADMULT}", "multiplizieren")
HotKeySet("{NUMPADADD}", "addieren")
HotKeySet("{NUMPADSUB}", "subtrahieren")
HotKeySet("{NUMPADDIV}", "dividieren")
HotKeySet("{NUMPADENTER}", "gleich")
HotKeySet("{^}", "hoch")
HotKeySet("{BACKSPACE}", "backspace")

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Rechner v1.1.0", 346, 313, 205, 145)
$Group1 = GUICtrlCreateGroup("", 8, 8, 329, 41)
$Label1 = GUICtrlCreateLabel("", 16, 23, 307, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input1 = GUICtrlCreateInput("", 8, 56, 329, 21)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetState(-1, $GUI_DISABLE)
$Button1 = GUICtrlCreateButton("0", 8, 256, 107, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("1", 8, 216, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button3 = GUICtrlCreateButton("2", 64, 216, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button4 = GUICtrlCreateButton("3", 120, 216, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button5 = GUICtrlCreateButton("4", 8, 176, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button6 = GUICtrlCreateButton("5", 64, 176, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button7 = GUICtrlCreateButton("6", 120, 176, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button8 = GUICtrlCreateButton("7", 8, 136, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button9 = GUICtrlCreateButton("8", 64, 136, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button10 = GUICtrlCreateButton("9", 120, 136, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button11 = GUICtrlCreateButton("/", 184, 96, 75, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button12 = GUICtrlCreateButton("*", 184, 136, 75, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button13 = GUICtrlCreateButton("-", 184, 176, 75, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button14 = GUICtrlCreateButton("+", 184, 216, 75, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button15 = GUICtrlCreateButton("=", 184, 256, 75, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button16 = GUICtrlCreateButton("C", 8, 96, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button17 = GUICtrlCreateButton(",", 120, 256, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button18 = GUICtrlCreateButton("^", 120, 96, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button19 = GUICtrlCreateButton("+/-", 64, 96, 51, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button20 = GUICtrlCreateButton("(", 264, 96, 75, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button21 = GUICtrlCreateButton(")", 264, 136, 75, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button22 = GUICtrlCreateButton("Wurzel", 264, 176, 75, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button23 = GUICtrlCreateButton("<-", 264, 216, 75, 33)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("©", 8, 292, 12, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Philipp Lehnhausen", 19, 293, 97, 17)
$zahl1="0"
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

		Case $Button16
			$zahl1=""
			GUICtrlSetData($label1,"")
			GUICtrlSetData($input1,"")
		Case $Button2
			guictrlsetdata($label1, guictrlread($label1)&"1")
		Case $Button3
			guictrlsetdata($label1, guictrlread($label1)&"2")
		Case $Button4
			guictrlsetdata($label1, guictrlread($label1)&"3")
		Case $Button5
			guictrlsetdata($label1, guictrlread($label1)&"4")
		Case $Button6
			guictrlsetdata($label1, guictrlread($label1)&"5")
		Case $Button7
			guictrlsetdata($label1, guictrlread($label1)&"6")
		Case $Button8
			guictrlsetdata($label1, guictrlread($label1)&"7")
		Case $Button9
			guictrlsetdata($label1, guictrlread($label1)&"8")
		Case $Button10
			guictrlsetdata($label1, guictrlread($label1)&"9")
		Case $Button1
			guictrlsetdata($label1, guictrlread($label1)&"0")
		Case $Button17
			if not guictrlread($label1)="" then
				guictrlsetdata($label1, guictrlread($label1)&".")
			Endif
		Case $Button14
			if not guictrlread($label1)="" then
			guictrlsetdata($label1, guictrlread($label1)&"+")
			endif
		Case $Button13
			if not guictrlread($label1)="" then
			guictrlsetdata($label1, guictrlread($label1)&"-")
			endif
		Case $Button12
			if not guictrlread($label1)="" then
			guictrlsetdata($label1, guictrlread($label1)&"*")
			endif
		Case $Button11
			if not guictrlread($label1)="" then
			guictrlsetdata($label1, guictrlread($label1)&"/")
			endif
		Case $Button18
			if not guictrlread($label1)="" then
			guictrlsetdata($label1, guictrlread($label1)&"^")
			endif
		Case $button20
			guictrlsetdata($label1, guictrlread($label1)&"(")
		Case $button21
			guictrlsetdata($label1, guictrlread($label1)&")")
		Case $Button19
			$zahl1=guictrlread ($label1)*(-1)
			GUICtrlSetData($label1, $zahl1)
			GUICtrlSetData($input1, $zahl1)
		Case $Button22
			$zahl1=guictrlread ($label1)
			$zahl1=sqrt($zahl1)
			GUICtrlSetData($label1, $zahl1)
			GUICtrlSetData($input1, $zahl1)
		Case $Button23
			if not $label1="" Then
				$str=guictrlread($label1)
				guictrlsetdata($label1,StringLeft($str,StringLen($str)-1))
			EndIf
		Case $Button15
			GUICtrlSetData($label1, Execute(GUICtrlRead($label1)))
			GUICtrlSetData($input1, Execute(GUICtrlRead($label1)))

EndSwitch



WEnd

Func nummer1()
	GUICtrlSetData($Label1, GUICtrlRead($Label1) & "1")
EndFunc

Func nummer2()
	GUICtrlSetData($Label1, GUICtrlRead($Label1) & "2")
EndFunc

Func nummer3()
	GUICtrlSetData($Label1, GUICtrlRead($Label1) & "3")
EndFunc

Func nummer4()
	GUICtrlSetData($Label1, GUICtrlRead($Label1) & "4")
EndFunc

Func nummer5()
	GUICtrlSetData($Label1, GUICtrlRead($Label1) & "5")
EndFunc

Func nummer6()
	GUICtrlSetData($Label1, GUICtrlRead($Label1) & "6")
EndFunc

Func nummer7()
	GUICtrlSetData($Label1, GUICtrlRead($Label1) & "7")
EndFunc

Func nummer8()
	GUICtrlSetData($Label1, GUICtrlRead($Label1) & "8")
EndFunc

Func nummer9()
	GUICtrlSetData($Label1, GUICtrlRead($Label1) & "9")
EndFunc

Func nummer0()
	GUICtrlSetData($Label1, GUICtrlRead($Label1) & "0")
EndFunc

func addieren ()
	if not guictrlread($label1)="" then
	guictrlsetdata($label1, guictrlread($label1)&"+")
endif
EndFunc

func subtrahieren ()
	if not guictrlread($label1)="" then
	guictrlsetdata($label1, guictrlread($label1)&"-")
endif
EndFunc

func dividieren()
	if not guictrlread($label1)="" then
	guictrlsetdata($label1, guictrlread($label1)&"/")
endif
EndFunc

func multiplizieren()
	if not guictrlread($label1)="" then
	guictrlsetdata($label1, guictrlread($label1)&"*")
endif
EndFunc

Func hoch()
	if not guictrlread($label1)="" then
	GUICtrlSetData($Label1, GUICtrlRead($Label1) & "^")
	EndIf
EndFunc

Func backspace()
	if not $label1="" Then
		$str=guictrlread($label1)
		guictrlsetdata($label1,StringLeft($str,StringLen($str)-1))
	EndIf
EndFunc

func gleich()
	GUICtrlSetData($label1, Execute(GUICtrlRead($label1)))
	GUICtrlSetData($input1, Execute(GUICtrlRead($label1)))
EndFunc
