#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=SA-MP XTreme KeyBinder by PrideRage.exe
#AutoIt3Wrapper_Res_Description=XTreme KeyBinder
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=PrideRage
#AutoIt3Wrapper_Res_Language=1031
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>
#include <Misc.au3>

#Region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\pride\desktop\keybinder.kxf
$Form1 = GUICreate("KeyBinder by PrideRage", 400, 194, 205, 130)
$kb1 = GUICtrlCreateInput("", 8, 48, 169, 21)
$key1 = GUICtrlCreateCombo("", 200, 48, 65, 25)
GUICtrlSetData($key1, "1|2|3")
$Label1 = GUICtrlCreateLabel("KeyBind Text", 8, 8, 108, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Taste", 200, 8, 49, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Aktiviert", 280, 8, 69, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$cb1 = GUICtrlCreateCheckbox("", 304, 48, 17, 17)
$kb2 = GUICtrlCreateInput("", 8, 88, 169, 21)
$key2 = GUICtrlCreateCombo("", 200, 88, 65, 25)
GUICtrlSetData(-1, "1|2|3")
$cb2 = GUICtrlCreateCheckbox("cb2", 304, 88, 17, 17)
$kb3 = GUICtrlCreateInput("", 8, 128, 169, 21)
$key3 = GUICtrlCreateCombo("", 200, 128, 65, 25)
GUICtrlSetData(-1, "1|2|3")
$cb3 = GUICtrlCreateCheckbox("cb3", 304, 128, 17, 17)
$start = GUICtrlCreateButton("Start", 48, 168, 97, 17, $WS_GROUP)
$quit = GUICtrlCreateButton("Beenden", 192, 168, 113, 17, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $start
			_KeyBinder_Start()
		Case $quit
			Exit
	EndSwitch
WEnd

Func _KeyBinder_Start()
	;KeyBinder Texte
	$text1 = GUICtrlRead($kb1)
	$text2 = GUICtrlRead($kb2)
	$text3 = GUICtrlRead($kb3)


	;Tastenbelegung
	Global $key1_Button = _GUICtrlComboBox_GetCurSel($key1) + 1
	Global $key2_Button = _GUICtrlComboBox_GetCurSel($key2) + 1
	Global $key3_Button = _GUICtrlComboBox_GetCurSel($key3) + 1
	Global $hexkey1
	Global $hexkey2
	Global $hexkey3

	If $key1_Button = 1 Then
		$hexkey1 = "31"
	EndIf
	If $key1_Button = 2 Then
		$hexkey1= 32
	EndIf
	If $key1_Button = 3 Then
		$hexkey1 = 33
	EndIf
	If $key2_Button = 1 Then
		$hexkey2 = 31
	EndIf
	If $key2_Button = 2 Then
		$hexkey2 = 32
	EndIf
	If $key2_Button = 3 Then
		$hexkey2 = 33
	EndIf
	If $key3_Button = 1 Then
		$hexkey3 = 31
	EndIf
	If $key3_Button = 2 Then
		$hexkey3 = 32
	EndIf
	If $key3_Button = 3 Then
		$hexkey3 = 33
	EndIf

	;Aktiviert oder nicht...
	Global $check_cb1 = GUICtrlRead($cb1)
	Global $check_cb2 = GUICtrlRead($cb2)
	Global $check_cb3 = GUICtrlRead($cb3)

	Global $checked_cb1 = False
	Global $checked_cb2 = False
	Global $checked_cb3 = False

	If $check_cb1 = $GUI_CHECKED Then
		$checked_cb1 = True
	EndIf

	If $check_cb2 = $GUI_CHECKED Then
		$checked_cb2 = True
	EndIf

	If $check_cb3 = $GUI_CHECKED Then
		$checked_cb3 = True
	EndIf


	;KeyBind funktion
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $quit
			Exit
		EndSwitch

		If _IsPressed($hexkey1) And $checked_cb1 = True Then
			Send($text1)
		EndIf

		If _IsPressed($hexkey2) And $checked_cb2 = True Then
			Send($text2)
		EndIf

		If _IsPressed($hexkey3) And $checked_cb3 = True Then
			Send($text3)
		EndIf
	WEnd
EndFunc
