#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
#include <Security.au3>
#include <Memory.au3>
#include <UDFGlobalID.au3>
#include <GuiStatusBar.au3>
#include-once
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <GUIEdit.au3>
#include <GuiToolbar.au3>
#include <inet.au3>
#include <array.au3>

$iread5 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Settings", "AllwaysOnTop", "0")
$iread6 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Settings", "MinimizeToTray", "0")
$iread7 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Settings", "Transparency", "0")
$iread8 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Settings", "TransPercent", "25")
$iread9 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Settings", "MaxRadios", "10")
$iread10 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Settings", "MaxRadio", "0")
$iread11 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Settings", "Action", "Als .txt speichern")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Technobase.FM Player by Calypso BETA", 290, 290, @DesktopWidth-298, 5)
$z = "260"
If $iread5 = "1" Then
	WinSetOnTop("Technobase.FM Player by Calypso BETA", "", 1)
EndIf
If $iread6 = "1" Then
	Opt("TrayMenuMode", 1)
	$muteitem    = TrayCreateItem("Mute")
	TrayCreateItem("")
	$showitem      = TrayCreateItem("Show")
	TrayCreateItem("")
	$exititem       = TrayCreateItem("Exit")
EndIf
If $iread7 = "1" Then
	WinSetTrans($Form1,"", $iread8*10)
EndIf
$oWMP = ObjCreate("WMPLayer.ocx")
$ername = $iread9
$erurl = $ername
#Region tab1
$Tab1 = GUICtrlCreateTab(0, 0, 600, 20)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUICtrlCreateTabItem("Play")
Dim $iniread[$ername+1]
For $4 = 1 To $ername Step 1
	$iniread[$4] = IniRead(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosNamen", $4, "-")
Next
Global $er
For $5 = 1 To $ername Step 1
	$er = $er & "|" & $iniread[$5]
Next
$Combo1 = GUICtrlCreateCombo("TechnoBase.FM", 5, 35, 190, 30)
GUICtrlSetData(-1, "HouseTime.FM|HardBase.FM|TranceBase.FM|CoreTime.FM"& $er ,"TechnoBase.FM")
$font = "BankGothic Md BT"
$Button1 = GUICtrlCreateButton("Start", 160, 65, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Stopp", 160, 100, 75, 25)
$Button3 = GUICtrlCreateButton("Ändern", 200, 35, 75, 25, 0)
Dim $label11[6]
For $13 = 1 To 5 Step 1
	$label11[$13] = GUICtrlCreateLabel("", 1, 143+25*$13,290, 25)
	GUICtrlSetColor($label11[$13], 0xff0000)
	GUICtrlSetBkColor($label11[$13], 0x000000)
	$14 = "1"
	If $13 = "3" Then $14 = "1,5"
	If $13 = "4" Then $14 = "1,5"
	If $13 = "5" Then $14 = "1,5"
	GUICtrlSetFont($label11[$13], 15/$14, 10000, 0, $font)
Next
GUICtrlSetData($label11[1], "Disconnected")
$Progress1 = GUICtrlCreateProgress(250, 65, 25, 60, $PBS_VERTICAL)
$Label1 = GUICtrlCreateLabel("Lautstärke:", 6, 120)
$slVolume = GUICtrlCreateSlider(12, 136, 259, 30, $TBS_AUTOTICKS)
GUICtrlSetData(-1, $oWMP.settings.volume())
GUICtrlSetState($slVolume, $GUI_DISABLE)
#EndRegion tab1
#Region tab2
$Tab2 = GUICtrlCreateTab(0, 0, 600, 0)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUICtrlCreateTabItem("Einstellungen")
GUICtrlCreateGroup("Hotkeys", 10, 30, 270, 110)
$label3 = GUICtrlCreateLabel("Lauter:", 30, 85)
$label4 = GUICtrlCreateLabel("Leiser:", 30, 105)
$label5 = GUICtrlCreateLabel("-", 90, 85, 100)
$label6 = GUICtrlCreateLabel("-", 90, 105, 100)
$label7 = GUICtrlCreateLabel("Start:", 30, 45)
$label8 = GUICtrlCreateLabel("Stopp:", 30, 65)
$label9 = GUICtrlCreateLabel("-", 90, 45, 100)
$label10 = GUICtrlCreateLabel("-", 90, 65, 100)
$Button4 = GUICtrlCreateButton("&Ändern", 170, 110, 100, 25, 0)
$Button6 = GUICtrlCreateButton("Erweiterte Einstellungen", 150, 160, 130, 25)
#EndRegion tab2
#Region tab3
$Tab3 = GUICtrlCreateTab(0, 0, 600, 0)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUICtrlCreateTabItem("Tracklist")
$Button31 = GUICtrlCreateButton("&Aktualisieren", 110, $z, 85, 25)
$Button32 = GUICtrlCreateButton("&Speichern", 200, $z, 85,25)
$label31 = GUICtrlCreateLabel("Tracklist:", 20, 25, 50, 25)
Dim $label3[11]
For $a = 0 to 10 Step 1
	$label3[$a]=GUICtrlCreateLabel("a", 20, $a*20+45, 300)
Next
_refresh()
#EndRegion tab3

#EndRegion ### END Koda GUI section ###

#Region Vars
$iread1 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeylauter", "-")
$iread2 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeyleiser", "-")
$iread3 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeystart", "-")
$iread4 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeystopp", "-")
If $iread1 = "" Then $iread = "-"
If $iread2 = "" Then $iread = "-"
If $iread3 = "" Then $iread = "-"
If $iread4 = "" Then $iread = "-"
GUICtrlSetData($label5, $iread1)
GUICtrlSetData($label6, $iread2)
GUICtrlSetData($label9, $iread3)
GUICtrlSetData($label10, $iread4)
If $iread1 <> "-" Then $hotkey1 = HotKeySet($iread1, "hotkeylauter")
If $iread2 <> "-" Then $hotkey2 = HotKeySet($iread2, "hotkeyleiser")
If $iread3 <> "-" Then $hotkey3 = HotKeySet($iread3, "hotkeystart")
If $iread4 <> "-" Then $hotkey4 = HotKeySet($iread4, "hotkeystopp")
$init = TimerInit()
$12=1
Global $string
Global $string2
Dim $arrStatus[12]
$arrStatus[0] = 'Undefined'
$arrStatus[1] = 'Stopped'
$arrStatus[2] = 'Paused'
$arrStatus[3] = 'Playing'
$arrStatus[4] = 'ScanForward'
$arrStatus[5] = 'ScanReverse'
$arrStatus[6] = 'Buffering'
$arrStatus[7] = 'Waiting'
$arrStatus[8] = 'MediaEnded'
$arrStatus[9] = 'Transitioning'
$arrStatus[10] = 'Ready'
$arrStatus[11] = 'Reconnecting'
$lastStatus = 0
Dim $color[6]
$color[0] = "0xFF6F04"
$color[1] = "0xED5CFE"
$color[2] = "0x72E1FF"
$color[3] = "0x86E229"
$color[4] = "0xE8F3ED"
$color[5] = "0xff0000"
$statCombo1 = 0
$statud = 0
$16 = "0"
#EndRegion Vars

GUISetState(@SW_SHOW, $Form1)

While 1
	$nMsg = GUIGetMsg()
	$tmsg = TrayGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			GUICtrlSetData($label11[1], "Connecting")
			GUICtrlSetData($label11[2], "")
			Dim $iniread1[$erurl+1]
			For $3 = 1 To $erurl Step 1
				$iniread1[$3] = IniRead(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosURL", $3, "-")
			Next
			$readcombo1 = GUICtrlRead($Combo1)
			Select
				Case $readcombo1 = "TechnoBase.FM"
					$oWMP.URL = 'http://listen.technobase.fm/tunein-dsl-asx'
					$editdata1 = "technobase.fm"
					$ecolor = $color[0]
				Case $readcombo1 = "HouseTime.FM"
					$oWMP.URL = 'http://listen.housetime.fm/tunein-dsl-asx'
					$editdata1 = "housetime.fm"
					$ecolor = $color[1]
				Case $readcombo1 = "HardBase.FM"
					$oWMP.URL = 'http://listen.hardbase.fm/tunein-dsl-asx'
					$editdata1 = "hardbase.fm"
					$ecolor = $color[2]
				Case $readcombo1 = "TranceBase.FM"
					$oWMP.URL = 'http://listen.trancebase.fm/tunein-dsl-asx'
					$editdata1 = "trancebase.fm"
					$ecolor = $color[3]
				Case $readcombo1 = "CoreTime.FM"
					$oWMP.URL = 'http://listen.coretime.fm/tunein-dsl-asx'
					$editdata1 = "coretime.fm"
					$ecolor = $color[4]
				Case Else
					For $6 = 1 To $ername Step 1
						$readcombo1 = $iniread[$6]
						$oWMP.URL = $iniread1[$6]
						$editdata1 = $iniread[$6]
					Next
					$ecolor = $color[5]
			EndSelect
			For $15 = 1 To 5 Step 1
				GUICtrlSetColor($label11[$15], $ecolor)
			Next
			GUICtrlSetData($label11[1], "Connecting")
			$oWMP.controls.play()
;~ 			Do
;~ 				Sleep(100)
;~ 			Until $oWMP.playstate = 7
			GUICtrlSetData($Progress1, 100)
			GUICtrlSetData($label11[1], "Buffering")
			$oWMP.settings.volume = 50
			GUICtrlSetState($slVolume, $GUI_ENABLE)
			GUICtrlSetState($Button1, $GUI_DISABLE)
			Do
				Sleep(100)
			Until $oWMP.playstate = 3
			GUICtrlSetData($label11[1], "Listening:")
			GUICtrlSetData($label11[2], $editdata1)
			_refresh()
		Case $Button2
			$oWMP.controls.stop()
			GUICtrlSetData($label11[1], "Disconnected")
			GUICtrlSetData($label11[2], "")
			GUICtrlSetData($label11[3], "")
			GUICtrlSetData($label11[4], "")
			GUICtrlSetData($label11[5], "")
			GUICtrlSetState($slVolume, $GUI_DISABLE)
			GUICtrlSetState($Button1, $GUI_ENABLE)
			GUICtrlSetData($Progress1, 0)
			$16 = "0"
		Case $Button3
			gui()
		Case $Button4
			GUISetState(@SW_DISABLE, $Form1)
			#Region VIRTUAL_KEYS
			Global Const $VKEY_LBUTTON = 0x01, $VKEY_RBUTTON = 0x02, $VKEY_CANCEL = 0x03, $VKEY_MBUTTON = 0x04
			Global Const $VKEY_XBUTTON1 = 0x05, $VKEY_XBUTTON2 = 0x06, $VKEY_BACK = 0x08, $VKEY_TAB = 0x09
			Global Const $VKEY_CLEAR = 0x0C, $VKEY_RETURN = 0x0D, $VKEY_SHIFT = 0x10, $VKEY_CONTROL = 0x11
			Global Const $VKEY_MENU = 0x12, $VKEY_PAUSE = 0x13, $VKEY_CAPITAL = 0x14, $VKEY_KANA = 0x15
			Global Const $VKEY_HANGEUL = 0x15, $VKEY_HANGUL = 0x15, $VKEY_JUNJA = 0x17, $VKEY_FINAL = 0x18
			Global Const $VKEY_HANJA = 0x19, $VKEY_KANJI = 0x19, $VKEY_ESCAPE = 0x1B, $VKEY_CONVERT = 0x1C
			Global Const $VKEY_NONCONVERT = 0x1D, $VKEY_ACCEPT = 0x1E, $VKEY_MODECHANGE = 0x1F, $VKEY_SPACE = 0x20
			Global Const $VKEY_PRIOR = 0x21, $VKEY_NEXT = 0x22, $VKEY_END = 0x23, $VKEY_HOME = 0x24
			Global Const $VKEY_LEFT = 0x25, $VKEY_UP = 0x26, $VKEY_RIGHT = 0x27, $VKEY_DOWN = 0x28
			Global Const $VKEY_SELECT = 0x29, $VKEY_PRINT = 0x2A, $VKEY_EXECUTE = 0x2B, $VKEY_SNAPSHOT = 0x2C
			Global Const $VKEY_INSERT = 0x2D, $VKEY_DELETE = 0x2E, $VKEY_HELP = 0x2F, $VKEY_LWIN = 0x5B
			Global Const $VKEY_RWIN = 0x5C, $VKEY_APPS = 0x5D, $VKEY_SLEEP = 0x5F, $VKEY_NUMPAD0 = 0x60
			Global Const $VKEY_NUMPAD1 = 0x61, $VKEY_NUMPAD2 = 0x62, $VKEY_NUMPAD3 = 0x63, $VKEY_NUMPAD4 = 0x64
			Global Const $VKEY_NUMPAD5 = 0x65, $VKEY_NUMPAD6 = 0x66, $VKEY_NUMPAD7 = 0x67, $VKEY_NUMPAD8 = 0x68
			Global Const $VKEY_NUMPAD9 = 0x69, $VKEY_MULTIPLY = 0x6A, $VKEY_ADD = 0x6B, $VKEY_SEPARATOR = 0x6C
			Global Const $VKEY_SUBTRACT = 0x6D, $VKEY_DECIMAL = 0x6E, $VKEY_DIVIDE = 0x6F, $VKEY_F1 = 0x70
			Global Const $VKEY_F2 = 0x71, $VKEY_F3 = 0x72, $VKEY_F4 = 0x73, $VKEY_F5 = 0x74
			Global Const $VKEY_F6 = 0x75, $VKEY_F7 = 0x76, $VKEY_F8 = 0x77, $VKEY_F9 = 0x78
			Global Const $VKEY_F10 = 0x79, $VKEY_F11 = 0x7A, $VKEY_F12 = 0x7B, $VKEY_F13 = 0x7C
			Global Const $VKEY_F14 = 0x7D, $VKEY_F15 = 0x7E, $VKEY_F16 = 0x7F, $VKEY_F17 = 0x80
			Global Const $VKEY_F18 = 0x81, $VKEY_F19 = 0x82, $VKEY_F20 = 0x83, $VKEY_F21 = 0x84
			Global Const $VKEY_F22 = 0x85, $VKEY_F23 = 0x86, $VKEY_F24 = 0x87, $VKEY_NUMLOCK = 0x90
			Global Const $VKEY_SCROLL = 0x91, $VKEY_OEM_NEC_EQUAL = 0x92, $VKEY_OEM_FJ_JISHO = 0x92, $VKEY_OEM_FJ_MASSHOU = 0x93
			Global Const $VKEY_OEM_FJ_TOUROKU = 0x94, $VKEY_OEM_FJ_LOYA = 0x95, $VKEY_OEM_FJ_ROYA = 0x96
			Global Const $VKEY_LSHIFT = 0xA0, $VKEY_RSHIFT = 0xA1, $VKEY_LCONTROL = 0xA2, $VKEY_RCONTROL = 0xA3
			Global Const $VKEY_LMENU = 0xA4, $VKEY_RMENU = 0xA5, $VKEY_BROWSER_BACK = 0xA6, $VKEY_BROWSER_FORWARD = 0xA7
			Global Const $VKEY_BROWSER_REFRESH = 0xA8, $VKEY_BROWSER_STOP = 0xA9, $VKEY_BROWSER_SEARCH = 0xAA, $VKEY_BROWSER_FAVORITES = 0xAB
			Global Const $VKEY_BROWSER_HOME = 0xAC, $VKEY_VOLUME_MUTE = 0xAD, $VKEY_VOLUME_DOWN = 0xAE, $VKEY_VOLUME_UP = 0xAF
			Global Const $VKEY_MEDIA_NEXT_TRACK = 0xB0, $VKEY_MEDIA_PREV_TRACK = 0xB1, $VKEY_MEDIA_STOP = 0xB2, $VKEY_MEDIA_PLAY_PAUSE = 0xB3
			Global Const $VKEY_LAUNCH_MAIL = 0xB4, $VKEY_LAUNCH_MEDIA_SELECT = 0xB5, $VKEY_LAUNCH_APP1 = 0xB6, $VKEY_LAUNCH_APP2 = 0xB7
			Global Const $VKEY_OEM_1 = 0xBA, $VKEY_OEM_PLUS = 0xBB, $VKEY_OEM_COMMA = 0xBC, $VKEY_OEM_MINUS = 0xBD
			Global Const $VKEY_OEM_PERIOD = 0xBE, $VKEY_OEM_2 = 0xBF, $VKEY_OEM_3 = 0xC0, $VKEY_OEM_4 = 0xDB
			Global Const $VKEY_OEM_5 = 0xDC, $VKEY_OEM_6 = 0xDD, $VKEY_OEM_7 = 0xDE, $VKEY_OEM_8 = 0xDF
			Global Const $VKEY_OEM_AX = 0xE1, $VKEY_OEM_102 = 0xE2, $VKEY_ICO_HELP = 0xE3, $VKEY_ICO_00 = 0xE4
			Global Const $VKEY_PROCESSKEY = 0xE5, $VKEY_ICO_CLEAR = 0xE6, $VKEY_PACKET = 0xE7, $VKEY_OEM_RESET = 0xE9
			Global Const $VKEY_OEM_JUMP = 0xEA, $VKEY_OEM_PA1 = 0xEB, $VKEY_OEM_PA2 = 0xEC, $VKEY_OEM_PA3 = 0xED
			Global Const $VKEY_OEM_WSCTRL = 0xEE, $VKEY_OEM_CUSEL = 0xEF, $VKEY_OEM_ATTN = 0xF0, $VKEY_OEM_FINISH = 0xF1
			Global Const $VKEY_OEM_COPY = 0xF2, $VKEY_OEM_AUTO = 0xF3, $VKEY_OEM_ENLW = 0xF4, $VKEY_OEM_BACKTAB = 0xF5
			Global Const $VKEY_ATTN = 0xF6, $VKEY_CRSEL = 0xF7, $VKEY_EXSEL = 0xF8, $VKEY_EREOF = 0xF9
			Global Const $VKEY_PLAY = 0xFA, $VKEY_ZOOM = 0xFB, $VKEY_NONAME = 0xFC, $VKEY_PA1 = 0xFD, $VKEY_OEM_CLEAR = 0xFE
			#EndRegion VIRTUAL_KEYS
			#Region GLOBAL_VARIABLES
			; This maps virtual keycodes to AutoIt equivalents
			Global $gaVirtkeyMap[75][2] = [[$VKEY_SPACE, "{SPACE}"],[$VKEY_RETURN, "{ENTER}"],[$VKEY_MENU, "{ALT}"],[$VKEY_BACK, "{BS}"], _ ; 4
					[$VKEY_DELETE, "{DEL}"],[$VKEY_UP, "{UP}"],[$VKEY_DOWN, "{DOWN}"],[$VKEY_LEFT, "{LEFT}"], _ ; 8
					[$VKEY_RIGHT, "{RIGHT}"],[$VKEY_HOME, "{HOME}"],[$VKEY_END, "{END}"],[$VKEY_ESCAPE, "{ESC}"], _ ; 12
					[$VKEY_INSERT, "{INS}"],[$VKEY_PRIOR, "{PGUP}"],[$VKEY_NEXT, "{PGDN}"],[$VKEY_F1, "{F1}"], _ ; 16
					[$VKEY_F2, "{F2}"],[$VKEY_F3, "{F3}"],[$VKEY_F4, "{F4}"],[$VKEY_F5, "{F5}"], _ ; 20
					[$VKEY_F6, "{F6}"],[$VKEY_F7, "{F7}"],[$VKEY_F8, "{F8}"],[$VKEY_F9, "{F9}"], _ ; 24
					[$VKEY_F10, "{F10}"],[$VKEY_F11, "{F11}"],[$VKEY_F12, "{F12}"],[$VKEY_TAB, "{TAB}"], _ ; 28
					[$VKEY_PRINT, "{PRINTSCREEN}"],[$VKEY_LWIN, "{LWIN}"],[$VKEY_RWIN, "{RWIN}"], _ ; 31
					[$VKEY_NUMLOCK, "{NUMLOCK}"],[$VKEY_CAPITAL, "{CAPSLOCK}"],[$VKEY_SCROLL, "{SCROLLLOCK}"], _ ; 34
					[$VKEY_PAUSE, "{PAUSE}"],[$VKEY_NUMPAD0, "{NUMPAD0}"],[$VKEY_NUMPAD1, "{NUMPAD1}"], _ ; 37
					[$VKEY_NUMPAD2, "{NUMPAD2}"],[$VKEY_NUMPAD3, "{NUMPAD3}"],[$VKEY_NUMPAD4, "{NUMPAD4}"], _ ; 40
					[$VKEY_NUMPAD5, "{NUMPAD5}"],[$VKEY_NUMPAD6, "{NUMPAD6}"],[$VKEY_NUMPAD7, "{NUMPAD7}"], _ ; 43
					[$VKEY_NUMPAD8, "{NUMPAD8}"],[$VKEY_NUMPAD9, "{NUMPAD0}"],[$VKEY_ADD, "{NUMPADADD}"], _ ; 46
					[$VKEY_SUBTRACT, "{NUMPADSUB}"],[$VKEY_DIVIDE, "{NUMPADDIV}"],[$VKEY_DECIMAL, "{NUMPADDOT}"], _ ; 49
					[$VKEY_APPS, "{APPSKEY}"],[$VKEY_LMENU, "{LALT}"],[$VKEY_RMENU, "{RALT}"], _ ; 52
					[$VKEY_LCONTROL, "{LCTRL}"],[$VKEY_RCONTROL, "{RCTRL}"],[$VKEY_LSHIFT, "{LSHIFT}"], _ ; 55
					[$VKEY_RSHIFT, "{RSHIFT}"],[$VKEY_SLEEP, "{SLEEP}"],[$VKEY_BROWSER_BACK, "{BROWSER_BACK}"], _ ; 58
					[$VKEY_BROWSER_FORWARD, "{BROWSER_FORWARD}"],[$VKEY_BROWSER_REFRESH, "{BROWSER_REFRESH}"], _ ; 60
					[$VKEY_BROWSER_STOP, "{BROWSER_STOP}"],[$VKEY_BROWSER_SEARCH, "{BROWSER_SEARCH}"], _ ; 62
					[$VKEY_BROWSER_FAVORITES, "{BROWSER_FAVORITES}"],[$VKEY_BROWSER_HOME, "{BROWSER_HOME}"], _ ; 64
					[$VKEY_VOLUME_MUTE, "{VOLUME_MUTE}"],[$VKEY_VOLUME_DOWN, "{VOLUME_DOWN}"],[$VKEY_VOLUME_UP, "{VOLUME_UP}"], _ ; 67
					[$VKEY_MEDIA_NEXT_TRACK, "{MEDIA_NEXT}"],[$VKEY_MEDIA_PREV_TRACK, "{MEDIA_PREV}"], _ ; 69
					[$VKEY_MEDIA_STOP, "{MEDIA_STOP}"],[$VKEY_MEDIA_PLAY_PAUSE, "{MEDIA_PLAY_PAUSE}"], _ ; 71
					[$VKEY_LAUNCH_MAIL, "{LAUNCH_MAIL}"],[$VKEY_LAUNCH_MEDIA_SELECT, "{LAUNCH_MEDIA}"], _ ; 73
					[$VKEY_LAUNCH_APP1, "{LAUNCH_APP1}"],[$VKEY_LAUNCH_APP2, "{LAUNCH_APP2}"]] ; 75
			Global $gaHotkeyList[20][7]
			#EndRegion GLOBAL_VARIABLES
			$hkfenster = GUICreate("Tastenbelegung ändern", 300, 230)
			GUICtrlCreateLabel("Start :", 8, 10)
			GUICtrlCreateLabel("Stopp", 8, 45)
			GUICtrlCreateLabel("Lauter :", 8, 80)
			GUICtrlCreateLabel("Leiser :", 8, 115)

			$okbutton = GUICtrlCreateButton("&Speichern", 110, 180, 80, 23)
			Dim $cEdit1 = GUICtrlCreateInput("-", 110, 10, 130, 24)
			Dim $hwndEdit1 = GUICtrlGetHandle($cEdit1)
			Dim $cEdit2 = GUICtrlCreateInput("-", 110, 45, 130, 24)
			Dim $hwndEdit2 = GUICtrlGetHandle($cEdit2)
			Dim $cEdit3 = GUICtrlCreateInput("-", 110, 80, 130, 24)
			Dim $hwndEdit3 = GUICtrlGetHandle($cEdit3)
			Dim $cEdit4 = GUICtrlCreateInput("-", 110, 115, 130, 24)
			Dim $hwndEdit4 = GUICtrlGetHandle($cEdit4)
			GUISetState(@SW_SHOW)
			_ToggleAsHotkeyControl($hwndEdit1)
			_ToggleAsHotkeyControl($hwndEdit2)
			_ToggleAsHotkeyControl($hwndEdit3)
			_ToggleAsHotkeyControl($hwndEdit4)
			While 1
				Sleep(50)
				$guimsg = GUIGetMsg()
				Switch $guimsg
					Case $GUI_EVENT_CLOSE
						GUIDelete($hkfenster)
						ExitLoop
					Case $okbutton
						IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeystart", _GetAutoItHotkey($hwndEdit1))
						IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeystopp", _GetAutoItHotkey($hwndEdit2))
						IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeylauter", _GetAutoItHotkey($hwndEdit3))
						IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeyleiser", _GetAutoItHotkey($hwndEdit4))
						GUIDelete($hkfenster)
						ExitLoop
				EndSwitch
			WEnd
			GUISetState(@SW_ENABLE, $Form1)
			$iread1 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeylauter", "-")
			$iread2 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeyleiser", "-")
			$iread3 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeystart", "-")
			$iread4 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "Section Hotkeys", "Hotkeystopp", "-")
			GUICtrlSetData($label5, $iread1)
			GUICtrlSetData($label6, $iread2)
			GUICtrlSetData($label9, $iread3)
			GUICtrlSetData($label10, $iread4)
			$hotkey1 = HotKeySet($iread1, "hotkeylauter")
			$hotkey2 = HotKeySet($iread2, "hotkeyleiser")
			$hotkey3 = HotKeySet($iread3, "hotkeystart")
			$hotkey4 = HotKeySet($iread4, "hotkeystopp")
		Case $Button6
			GUISetState(@SW_DISABLE, $Form1)
			sgui()
			GUISetState(@SW_ENABLE, $Form1)
		Case $GUI_EVENT_MINIMIZE
			If $iread6 = "1" Then
				GUISetState(@SW_HIDE)
				TraySetState(1)
			Else
				GUISetState(@SW_MINIMIZE)
			EndIf
		Case $Button31
			$readcombo3 = GUICtrlRead($Combo1)
			If $readcombo3 = "TechnoBase.FM" Or "HouseTime.FM" Or "HardBase.FM" Or "TranceBase.FM" Or "CoreTime.FM" Then
				$source1 = _INetGetSource("http://www."&$readcombo3&"/tracklist.php")
				$sRegExp2 = StringReplace($source1, "amp;", "&")
				$sRegExp1 = StringRegExp($sRegExp2, 'border="\d" src=".+" alt=".+" title="(.+?)" />', 3)
			EndIf
			For $b = 0 to 10 Step 1
				If StringLen($sRegExp1[$b]) > 50 Then
					$sRegExp1[$b] = (StringLeft($sRegExp1[$b], 50) & "...")
				EndIf
				GUICtrlSetData($label3[$b], $sRegExp1[$b])
			Next
		Case $Button32
			$readcombo3 = GUICtrlRead($Combo1)
			If $readcombo3 = "TechnoBase.FM" Or "HouseTime.FM" Or "HardBase.FM" Or "TranceBase.FM" Or "CoreTime.FM" Then
				$source1 = _INetGetSource("http://www."&$readcombo3&"/tracklist.php")
				$sRegExp2 = StringReplace($source1, "amp;", "&")
				$sRegExp1 = StringRegExp($sRegExp2, 'border="\d" src=".+" alt=".+" title="(.+?)" />', 3)
			EndIf
			If $iread11 = "Als .txt speichern" Then
				$file = FileOpen(@ScriptDir & "\Tracklist " & @MDAY & "." & @MON & " um " & @HOUR & "_" & @MIN & ".txt", 1)
				For $c = 1 To 10 Step 1
					FileWrite($file, $sRegExp1[$c] & @CRLF)
				Next
				FileClose($file)
				MsgBox(64, "Info", "Tracklist wurde im Scriptverzeichnis gespeichert")
			ElseIf $iread11 = "Letzten Titel in die Zwischenablage" Then
				ClipPut($sRegExp1[0])
			ElseIf $iread11 = "Alle Titel in die Zwischenablage" Then
				$cp = $sRegExp1[1] & @CRLF
				For $17 = 2 To 10 Step 1
					$cp &= $sRegExp1[$17] & @CRLF
				Next
				ClipPut($cp)
			EndIf
	EndSwitch
	If $iread6 = "1" Then
		Switch $tmsg
			Case $TRAY_EVENT_PRIMARYDOWN
				If $iread6 = "1" Then
					If BitAND(WinGetState($Form1), 16) Then
						GUISetState(@SW_SHOW)
						GUISetState(@SW_RESTORE)
						TraySetState(2)
					EndIf
				EndIf
			Case $showitem
				GUISetState(@SW_SHOW)
				GUISetState(@SW_RESTORE)
				TraySetState(2)
			Case $muteitem
				TrayItemSetText($muteitem, "Unmute")
				If $oWMP.settings.mute = False Then
					$oWMP.settings.mute = True
				Else
					$oWMP.settings.mute = False
				EndIf
			Case $exititem
				Exit
		EndSwitch
	EndIf
	$oWMP.settings.volume = GUICtrlRead($slVolume)
	$curStatus = $oWMP.playstate
	If $curStatus <> $lastStatus Then
		Select
			Case $curStatus = 3
				GUICtrlSetData($label11[1], "Listening:")
				GUICtrlSetData($label11[2], $editdata1)
			Case $curStatus = 6
				GUICtrlSetData($label11[1], "Buffering")
				GUICtrlSetData($label11[2], "")
				GUICtrlSetData($label11[3], "")
				GUICtrlSetData($label11[4], "")
				GUICtrlSetData($label11[5], "")
			Case $curStatus = 7
				GUICtrlSetData($label11[1], "Waiting")
				GUICtrlSetData($label11[2], "")
				GUICtrlSetData($label11[3], "")
				GUICtrlSetData($label11[4], "")
				GUICtrlSetData($label11[5], "")
			Case $curStatus = 11
				GUICtrlSetData($label11[1], "Reconnecting")
				GUICtrlSetData($label11[2], "")
				GUICtrlSetData($label11[3], "")
				GUICtrlSetData($label11[4], "")
				GUICtrlSetData($label11[5], "")
		EndSelect
		$lastStatus = $curStatus
	EndIf
	If TimerDiff($init) >= ($12*12000) Then
		_refresh()
		$12 = $12+1
	EndIf
WEnd


#Region Funktionen
Func hotkeystart()
	ControlClick("Technobase.FM Player by Calypso", "", $Button1)
EndFunc   ;==>hotkeystart

Func hotkeystopp()
	ControlClick("TechnoBase.FM Player by Calypso", "", $Button2)
EndFunc   ;==>hotkeystopp

Func hotkeyleiser()
	$readslider1 = GUICtrlRead($slVolume)
	GUICtrlSetData($slVolume, $readslider1 - 5)
EndFunc   ;==>hotkeyleiser

Func hotkeylauter()
	$readslider1 = GUICtrlRead($slVolume)
	GUICtrlSetData($slVolume, $readslider1 + 5)
EndFunc   ;==>hotkeylauter

Func _refresh()
	$readcombo3 = GUICtrlRead($Combo1)
	If $readcombo3 = "TechnoBase.FM" Or "HouseTime.FM" Or "HardBase.FM" Or "TranceBase.FM" Or "CoreTime.FM" Then
		$source1 = _INetGetSource("http://www."&$readcombo3&"/tracklist.php")
		$sRegExp2 = StringReplace($source1, "amp;", "&")
		$sRegExp1 = StringRegExp($sRegExp2, 'border="\d" src=".+" alt=".+" title="(.+?)" />', 3)
		For $b = 0 to 10 Step 1
			If StringLen($sRegExp1[$b]) > 50 Then
				$sRegExp1[$b] = (StringLeft($sRegExp1[$b], 50) & "...")
			EndIf
			GUICtrlSetData($label3[$b], $sRegExp1[$b])
		Next
		Dim $string[2]
		If GUICtrlRead($label11[1]) = "Listening:" Then
			ControlClick("Technobase.FM Player by Calypso BETA","", $Button31)
			$string = StringSplit(GUICtrlRead($label3[0]),"-",2)
			If StringLen($string[1]) < 4 Then
				$string[0] = $string[0] & $string[1]
				$string[1] = $string[2]
			EndIf
			If StringLen($string[0]) > 24 Then
				$string[0] = StringLeft($string[0], 24) & "..."
			EndIf
			If StringLen($string[1]) > 24 Then
				$string[1] = StringLeft($string[1], 24) & "..."
			EndIf
			GUICtrlSetData($label11[3],$string[0])
			GUICtrlSetData($label11[4],$string[1])
			_dj()
		EndIf
	EndIf
EndFunc

Func _dj()
$inets = _INetGetSource("http://www.technobase.fm/showplan.php")
$sT = StringRegExp($inets, '<td>(.+?)</td>\s*<td align=right><a href="/member/\d*">', 3)
$sN = StringRegExp($inets, '<td align=right><a href="/member/\d*">(.+?)</a></td>', 3)
$sSt = StringRegExp($inets, '<b>(.+?)</b><br>\s*Musikstyle', 3)
$hour = @HOUR
If @MIN > "01" Then $hour = $hour+1
$i24 = 0
Dim $SP[UBound($sT)][3]
For $i = 0 to UBound($sT)-1
    $SP[$i][0] = $sT[$i]
    $SP[$i][1] = $sN[$i]
    $SP[$i][2] = $sSt[$i]
Next
Dim $tsp[UBound($SP)][2]
For $i2 = 0 to UBound($tsp)-1
	$temp = StringSplit($SP[$i2][0],":")
	$tsp[$i2][0] = $temp[1]
Next
For $i22 = 0 to UBound($tsp)-2
	If $hour > $tsp[$i22][0] Then
		$i24 = $i24+1
	Else
		$i24 = $i24-1
		ExitLoop
	EndIf
Next
$string = $SP[$i24][1]
$EST = $SP[$i24][2]
GUICtrlSetData($label11[5], $string&" - "&$EST)
EndFunc

Func gui()
	GUISetState(@SW_DISABLE, $Form1)
	#Region ### START Koda GUI section ### Form=
	$Form21 = GUICreate("Neuen Radiosender hinzufügen", 309, 284, 801, 401)
	$Tab21 = GUICtrlCreateTab(0, 0, 600, 20)
	GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
	GUICtrlCreateTabItem("Sender Hinzufügen")
	$Button21 = GUICtrlCreateButton("&Speichern", 208, 240, 75, 25, 0)
	$Label21 = GUICtrlCreateLabel("Name :", 32, 24, 36, 17)
	$Input21 = GUICtrlCreateInput("", 78, 24, 200, 21)
	$Label22 = GUICtrlCreateLabel("URL :", 32, 64, 36, 17)
	$Edit21 = GUICtrlCreateEdit("", 78, 64, 220, 153)
	GUICtrlSetData(-1, "")
	$Tab21 = GUICtrlCreateTab(0, 0, 600, 20)
	GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
	GUICtrlCreateTabItem("Sender Löschen")
	Dim $iniread2[$ername+1]
	For $7 = 1 To $ername Step 1
		$iniread2[$7] = IniRead(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosNamen", $7, "-")
		If $iniread2[$7] = "-" Then ExitLoop
	Next
	If $7-1 = 0 Then
		$Label23 = GUICtrlCreateLabel("Keine Sender vorhanden", 20, 70)
	Else
		Dim $Checkbox4[$7+1]
		For $8 = 1 To ($7-1) Step 1
			$Checkbox4[$8] = GUICtrlCreateCheckbox($iniread2[$8], 20, 50+20*$8)
		Next
	EndIf
	$Button22 = GUICtrlCreateButton("&Löschen", 208, 240, 75, 25, 0)
	$Label24 = GUICtrlCreateLabel("Zum Löschen des Senders einen Haken in die Checkbox setzen", 20, 30, 300, 40)
	GUISetState(@SW_SHOW)
	#EndRegion ### END Koda GUI section ###
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				GUIDelete($Form21)
				ExitLoop
			Case $Button21
				$input21read = GUICtrlRead($Input21)
				$Edit21read = GUICtrlRead($Edit21)
					For $1 = 1 to $ername Step 1
						If IniRead(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosNamen", $1, "-") = "-" Then
							IniWrite(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosNamen", $1, $input21read)
							ExitLoop
						EndIf
					Next
					For $2 = 1 to $erurl Step 1
						If IniRead(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosURL", $2, "-") = "-" Then
							IniWrite(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosURL", $2, $Edit21read)
							ExitLoop
						EndIf
					Next
				$msgbox1 = MsgBox(68, "Info", "Damit die Änderungen wirksam werden muss das Programm neugestartet werden.")
				Select
					Case $msgbox1 = 6
						GUIDelete($Form21)
						GUIDelete($Form1)
						ShellExecute(@ScriptFullPath)
						Exit
					Case $msgbox1 = 7
						GUIDelete($Form21)
						ExitLoop
				EndSelect
			Case $Button22
				For $9 = 1 To ($8-1) Step 1
					If GUICtrlRead($Checkbox4[$9]) = "1" Then
						IniDelete(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosURL", $9)
						IniDelete(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosNamen", $9)
					EndIf
				Next
				$10 = 1
				For $11 = 1 To ($8-1) Step 1
					If GUICtrlRead($Checkbox4[$11]) = $GUI_UNCHECKED Then
						$s1 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosURL", $11, "")
						$s2 = IniRead(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosNamen", $11, "")
						IniDelete(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosURL", $11)
						IniDelete(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosNamen", $11)
						IniWrite(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosURL", $10, $s1)
						IniWrite(@ScriptDir & "\Eigene_Radios.ini", "EigeneRadiosNamen", $10, $s2)
						$10 = $10 + 1
					EndIf
				Next
				$msgbox2 = MsgBox(68, "Info", "Damit die Änderungen wirksam werden muss das Programm neugestartet werden.")
				Select
					Case $msgbox2 = 6
						GUIDelete($Form21)
						GUIDelete($Form1)
						ShellExecute(@ScriptFullPath)
						Exit
					Case $msgbox2 = 7
						GUIDelete($Form21)
						ExitLoop
				EndSelect
		EndSwitch
	WEnd
	GUISetState(@SW_ENABLE, $Form1)
	GUISetState(@SW_RESTORE, $Form1)
EndFunc

Func sgui()
#Region ### START Koda GUI section ### Form=
$Form2=GUICreate("Erweiterte Einstellungen", 250, 250, @DesktopWidth-550, 150)
WinSetOnTop("Erweiterte Einstellungen","", 1)
$Checkbox1 = GUICtrlCreateCheckbox("Immer im Vordergrund", 20, 17)
If $iread5 = "1" Then GUICtrlSetState($Checkbox1, $GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("Minimize to Tray", 20, 42)
If $iread6 = "1" Then GUICtrlSetState($Checkbox2, $GUI_CHECKED)
$Checkbox3  = GUICtrlCreateCheckbox("Transperenz", 20, 67)
If $iread7 = "1" Then GUICtrlSetState($Checkbox3, $GUI_CHECKED)
$Checkbox4  = GUICtrlCreateCheckbox("Maximale Anzahl an Sendern", 20, 92)
If $iread10 = "1" Then GUICtrlSetState($Checkbox4, $GUI_CHECKED)
$input1 = GUICtrlCreateInput($iread9, 180, 95, 40, 20)
GUICtrlCreateUpdown($input1)
;~ GUICtrlSetData($input1, $iread1)
$Combo2 = GUICtrlCreateCombo($iread8, 180, 70, 40, 20)
GUICtrlSetData($Combo2, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25")
GUICtrlCreateLabel("Aktion beim Drücken es Speichern-Buttons:", 20, 120, 280, 20)
$Combo21 = GUICtrlCreateCombo($iread11, 20, 140, 200, 20)
GUICtrlSetData($Combo21, "Als .txt speichern|Letzten Titel in die Zwischenablage|Alle Titel in die Zwischenablage")
$Button5 = GUICtrlCreateButton("&Speichern", 100, 180, 85, 25, 0)
#EndRegion ### END Koda GUI section ###
GUISetState(@SW_SHOW, $Form2)
While 1
	$nMsg2 = GUIGetMsg()
	$nstatCheck3 = GUICtrlRead($Checkbox3)
	$nstatCheck4 = GUICtrlRead ($Checkbox4)
	Switch $nMsg2
		Case $GUI_EVENT_CLOSE
			GUIDelete($Form2)
			ExitLoop
		Case $Button5
			$readcheck1 = GUICtrlRead($Checkbox1)
			$readcheck2 = GUICtrlRead($Checkbox2)
			$readcheck3 = GUICtrlRead($Checkbox3)
			$readcheck4 = GUICtrlRead($Checkbox4)
			$readcombo2 = GUICtrlRead($Combo2)
			$readcombo21 = GUICtrlRead($Combo21)
			$readud = GUICtrlRead($input1)
			If $readcheck1 = $GUI_CHECKED Then
				IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Settings", "AllwaysOnTop", "1")
			Else
				IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Settings", "AllwaysOnTop", "0")
			EndIf
			If $readcheck2 = $GUI_CHECKED Then
				IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Settings", "MinimizeToTray", "1")
			Else
				IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Settings", "MinimizeToTray", "0")
			EndIf
			If $readcheck3 = $GUI_CHECKED Then
				IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Settings", "Transparency", "1")
				IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Settings", "TransPercent", $readcombo2)
			Else
				IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Settings", "Transparency", "0")
			EndIf
			If $readcheck4 = $GUI_CHECKED And $readud <> "10" Then
				IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Settings", "MaxRadio", "1")
				IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Settings", "MaxRadios", $readud)
			EndIf
			IniWrite(@ScriptDir & "\Eigene_Radios.ini", "Settings", "Action", $readcombo21)
			$msgbox2 = MsgBox(68, "Info", "Damit die Änderungen wirksam werden muss das Programm neugestartet werden.")
			Do
				Select
					Case $msgbox2 = 6
						ShellExecute(@ScriptFullPath)
						Exit
					Case $msgbox2 = 7
						ExitLoop
				EndSelect
			Until WinExists("Info")
	EndSwitch
	If $statCombo1 <> $nstatCheck3 Then
		If $nstatCheck3 = $GUI_CHECKED Then
			GUICtrlSetState($Combo2, $GUI_ENABLE)
		Else
			GUICtrlSetState($Combo2, $GUI_DISABLE)
		EndIf
		$statCombo1 = $nstatCheck3
	EndIf
	If $statud <> $nstatCheck4 Then
		If $nstatCheck4 = $GUI_CHECKED Then
			GUICtrlSetState($input1, $GUI_ENABLE)
		Else
			GUICtrlSetState($input1, $GUI_DISABLE)
		EndIf
		$statud = $nstatCheck4
	EndIf
WEnd
EndFunc

#Region HotkeyControl
; ==================================================================================================
; Func _ToggleAsHotkeyControl($hWnd)
;
; Function to toggle whether the input control is a hotkey
;
; $hWnd = Handle to the input control
;
; Returns:
;   Success: True
;   Failure: False, with @error set:
;
; Author: WideBoyDixon
; ==================================================================================================
Func _ToggleAsHotkeyControl($hWnd)
	Dim $nI, $nJ = -1, $bFound = False

	; Check the current array to see if we've already got this one
	For $nI = 0 To UBound($gaHotkeyList) - 1
		If $gaHotkeyList[$nI][0] = $hWnd Then
			; Found it
			$bFound = True
			$nJ = $nI
			ExitLoop
		ElseIf (Not IsHWnd($gaHotkeyList[$nI][0])) And ($nJ = -1) Then
			; Remember the first empty location
			$nJ = $nI
		EndIf
	Next

	; If we already had it then remove this one
	If $bFound Then
		$gaHotkeyList[$nJ][0] = ""
		_WinAPI_SetWindowLong($hWnd, 0xFFFFFFFC, $gaHotkeyList[$nJ][3])
		Return SetError(0, 0, True)
	EndIf

	; If we don't have any spare slots then this is an error
	If ($nJ = -1) Then Return SetError(1, 0, False)
	; Store the details and subclass the window
	$gaHotkeyList[$nJ][0] = $hWnd
	$gaHotkeyList[$nJ][1] = ""
	$gaHotkeyList[$nJ][2] = DllCallbackRegister("_HotkeyWindowProc", "ptr", "hwnd;uint;long;ptr")
	$gaHotkeyList[$nJ][3] = _WinAPI_SetWindowLong($hWnd, 0xFFFFFFFC, DllCallbackGetPtr($gaHotkeyList[$nJ][2]))
	$gaHotkeyList[$nJ][4] = 0
	$gaHotkeyList[$nJ][5] = False
	$gaHotkeyList[$nJ][6] = ""

	; Success
	Return SetError(0, 0, True)
EndFunc   ;==>_ToggleAsHotkeyControl

; ==================================================================================================
; Func _HotkeyWindowProc($hWnd, $uiMsg, $wParam, $lParam)
;
; Windows procedure for subclassing an input control
;
; $hWnd = Handle to the input control
; $uiMsg = The windows message
; $wParam = WPARAM
; $lParam = LPARAM
;
; Returns:
;   1 = Don't process this message as it's already been handled
;   Other = Use the default processing for this message
;
; Author: WideBoyDixon
; ==================================================================================================
Func _HotkeyWindowProc($hWnd, $uiMsg, $wParam, $lParam)
	Local $scanCode, $sAutoitKey
	Local $nIndex = _GetHandleIndex($hWnd)
	If $nIndex >= 0 Then
		If $uiMsg = $WM_GETDLGCODE Then
			If $wParam = $VKEY_RETURN Then
				$uiMsg = $WM_KEYDOWN
			EndIf
		EndIf
		Switch $uiMsg
			Case $WM_SETFOCUS
				$gaHotkeyList[$nIndex][4] = 0
				$gaHotkeyList[$nIndex][5] = False
				$gaHotkeyList[$nIndex][6] = ""
			Case $WM_SYSKEYDOWN, $WM_KEYDOWN
				$scanCode = DllCall("user32.dll", "uint", "MapVirtualKey", "uint", $wParam, "uint", 2)
				Switch $wParam
					Case $VKEY_SHIFT, $VKEY_LSHIFT, $VKEY_RSHIFT
						$gaHotkeyList[$nIndex][4] = BitOR($gaHotkeyList[$nIndex][4], 1)
					Case $VKEY_CONTROL, $VKEY_LCONTROL, $VKEY_RCONTROL
						$gaHotkeyList[$nIndex][4] = BitOR($gaHotkeyList[$nIndex][4], 2)
					Case $VKEY_LWIN, $VKEY_RWIN
						$gaHotkeyList[$nIndex][4] = BitOR($gaHotkeyList[$nIndex][4], 4)
					Case $VKEY_MENU, $VKEY_LMENU, $VKEY_RMENU
						$gaHotkeyList[$nIndex][4] = BitOR($gaHotkeyList[$nIndex][4], 8)
						$sAutoitKey = _GetAutoItCode($wParam)
					Case Else
						$sAutoitKey = _GetAutoItCode($wParam)
						If $sAutoitKey = "" Then
							Select
								Case $scanCode[0] = 65
									$sAutoitKey = Chr(97)
								Case $scanCode[0] = 66
									$sAutoitKey = Chr(98)
								Case $scanCode[0] = 67
									$sAutoitKey = Chr(99)
								Case $scanCode[0] = 68
									$sAutoitKey = Chr(100)
								Case $scanCode[0] = 69
									$sAutoitKey = Chr(101)
								Case $scanCode[0] = 70
									$sAutoitKey = Chr(102)
								Case $scanCode[0] = 71
									$sAutoitKey = Chr(103)
								Case $scanCode[0] = 72
									$sAutoitKey = Chr(104)
								Case $scanCode[0] = 73
									$sAutoitKey = Chr(105)
								Case $scanCode[0] = 74
									$sAutoitKey = Chr(106)
								Case $scanCode[0] = 75
									$sAutoitKey = Chr(107)
								Case $scanCode[0] = 76
									$sAutoitKey = Chr(108)
								Case $scanCode[0] = 77
									$sAutoitKey = Chr(109)
								Case $scanCode[0] = 78
									$sAutoitKey = Chr(110)
								Case $scanCode[0] = 79
									$sAutoitKey = Chr(111)
								Case $scanCode[0] = 80
									$sAutoitKey = Chr(112)
								Case $scanCode[0] = 81
									$sAutoitKey = Chr(113)
								Case $scanCode[0] = 82
									$sAutoitKey = Chr(114)
								Case $scanCode[0] = 83
									$sAutoitKey = Chr(115)
								Case $scanCode[0] = 84
									$sAutoitKey = Chr(116)
								Case $scanCode[0] = 85
									$sAutoitKey = Chr(117)
								Case $scanCode[0] = 86
									$sAutoitKey = Chr(118)
								Case $scanCode[0] = 87
									$sAutoitKey = Chr(119)
								Case $scanCode[0] = 88
									$sAutoitKey = Chr(120)
								Case $scanCode[0] = 89
									$sAutoitKey = Chr(121)
								Case $scanCode[0] = 90
									$sAutoitKey = Chr(122)
								Case $sAutoitKey = ""
									If $scanCode[0] <> 0 Then $sAutoitKey = Chr($scanCode[0])
							EndSelect
						EndIf
						If $sAutoitKey <> "" Then
							$gaHotkeyList[$nIndex][6] = $sAutoitKey
							_ShowHotKey($nIndex)
							$gaHotkeyList[$nIndex][5] = True
						EndIf
				EndSwitch
				If Not $gaHotkeyList[$nIndex][5] Then _ShowHotKey($nIndex)
				Return 1
			Case $WM_SYSKEYUP, $WM_KEYUP
				Switch $wParam
					Case $VKEY_SHIFT, $VKEY_LSHIFT, $VKEY_RSHIFT
						$gaHotkeyList[$nIndex][4] = BitAND($gaHotkeyList[$nIndex][4], 14)
					Case $VKEY_CONTROL, $VKEY_LCONTROL, $VKEY_RCONTROL
						$gaHotkeyList[$nIndex][4] = BitAND($gaHotkeyList[$nIndex][4], 13)
					Case $VKEY_LWIN, $VKEY_RWIN
						$gaHotkeyList[$nIndex][4] = BitAND($gaHotkeyList[$nIndex][4], 11)
					Case $VKEY_MENU, $VKEY_LMENU, $VKEY_RMENU
						$gaHotkeyList[$nIndex][4] = BitAND($gaHotkeyList[$nIndex][4], 7)
				EndSwitch
				If Not $gaHotkeyList[$nIndex][5] Then _ShowHotKey($nIndex)
				If $gaHotkeyList[$nIndex][5] Then
					$gaHotkeyList[$nIndex][5] = ($gaHotkeyList[$nIndex][5] <> 0)
					If Not $gaHotkeyList[$nIndex][5] Then $gaHotkeyList[$nIndex][6] = ""
				EndIf
				Return 1
			Case $WM_CHAR, $WM_PASTE, $WM_CUT
				Return 1
		EndSwitch
		Return _WinAPI_CallWindowProc($gaHotkeyList[$nIndex][3], $hWnd, $uiMsg, $wParam, $lParam)
	Else
		Return _WinAPI_DefWindowProc($hWnd, $uiMsg, $wParam, $lParam)
	EndIf
EndFunc   ;==>_HotkeyWindowProc

; ==================================================================================================
; Func _GetAutoItCode($vkCode)
;
; Get an AutoIt equivalent for a virtual key
;
; $vkCode = The virtual key code
;
; Returns:
;   The AutoIt equivalent or an empty string if there isn't one
;
; Author: WideBoyDixon
; ==================================================================================================
Func _GetAutoItCode($vkCode)
	Local $nI, $sRet = ""

	; Look through the map array to find this value
	For $nI = 0 To UBound($gaVirtkeyMap) - 1
		If $gaVirtkeyMap[$nI][0] = $vkCode Then
			; Found it ... return it
			$sRet = $gaVirtkeyMap[$nI][1]
			ExitLoop
		EndIf
	Next

	Return SetError(0, 0, $sRet)
EndFunc   ;==>_GetAutoItCode

; ==================================================================================================
; Func _ShowHotKey($nIndex)
;
; Display the hotkey for an input control
;
; $nIndex = The array index for the control
;
; Returns:
;   None - the text of the control is set
;
; Author: WideBoyDixon
; ==================================================================================================
Func _ShowHotKey($nIndex)
	Local $sText = ""
	$gaHotkeyList[$nIndex][1] = ""

	; Build up the hotkey - display and AutoIt specific
	If BitAND($gaHotkeyList[$nIndex][4], 1) Then
		$gaHotkeyList[$nIndex][1] &= "+"
		$sText &= "SHIFT + "
	EndIf
	If BitAND($gaHotkeyList[$nIndex][4], 2) Then
		$gaHotkeyList[$nIndex][1] &= "^"
		$sText &= "CTRL + "
	EndIf
	If BitAND($gaHotkeyList[$nIndex][4], 4) Then
		$gaHotkeyList[$nIndex][1] &= "#"
		$sText &= "WIN + "
	EndIf
	If BitAND($gaHotkeyList[$nIndex][4], 8) Then
		$gaHotkeyList[$nIndex][1] &= "!"
		$sText &= "ALT + "
	EndIf
	$gaHotkeyList[$nIndex][1] &= $gaHotkeyList[$nIndex][6]
	$sText &= $gaHotkeyList[$nIndex][6]
	_WinAPI_SetWindowText($gaHotkeyList[$nIndex][0], $sText)
	_GUICtrlEdit_SetSel($gaHotkeyList[$nIndex][0], StringLen($sText), StringLen($sText))
EndFunc   ;==>_ShowHotKey

; ==================================================================================================
; Func _GetHandleIndex($hWnd)
;
; Get the index in the array for a window handle
;
; $hWnd = The window handle of the input control
;
; Returns:
;   The array index for the handle or -1 if it's not found
;
; Author: WideBoyDixon
; ==================================================================================================
Func _GetHandleIndex($hWnd)
	Local $nI, $nJ = -1
	For $nI = 0 To UBound($gaHotkeyList) - 1
		If $gaHotkeyList[$nI][0] = $hWnd Then
			$nJ = $nI
			ExitLoop
		EndIf
	Next
	Return $nJ
EndFunc   ;==>_GetHandleIndex

; ==================================================================================================
; Func _GetAutoItHotkey($hWnd)
;
; Get the AutoIt hotkey combination for a window handle
;
; $hWnd = The window handle of the input control
;
; Returns:
;   Success: The AutoIt version of the hotkey which can be used in HotKeySet
;   Failure: An empty string ("") with @error set to 1
;
; Author: WideBoyDixon
; ==================================================================================================
Func _GetAutoItHotkey($hWnd)
	Local $nIndex = _GetHandleIndex($hWnd)
	If $nIndex = -1 Then Return SetError(1, 0, "")
	Return SetError(0, 0, $gaHotkeyList[$nIndex][1])
EndFunc   ;==>_GetAutoItHotkey

; ==================================================================================================
; Func _SetAutoItHotkey($hWnd, $sAutoitKey)
;
; Set the AutoIt hotkey combination for a window handle
;
; $hWnd = The window handle of the input control
; $sAutoitKey = The Autoit hotkey string
;
; Returns:
;   Success: The AutoIt version of the hotkey which can be used in HotKeySet
;   Failure: An empty string ("") with @error set to 1
;
; Author: WideBoyDixon
; ==================================================================================================
Func _SetAutoItHotkey($hWnd, $sAutoitKey)
	Local $nIndex = _GetHandleIndex($hWnd), $sKey = $sAutoitKey
	If $nIndex = -1 Then Return SetError(1, 0, False)
	$gaHotkeyList[$nIndex][4] = 0
	$gaHotkeyList[$nIndex][5] = False
	$gaHotkeyList[$nIndex][6] = ""
	While StringInStr("+^#!", StringLeft($sKey, 1)) > 0
		Switch StringLeft($sKey, 1)
			Case "+"
				$gaHotkeyList[$nIndex][4] += 1
			Case "^"
				$gaHotkeyList[$nIndex][4] += 2
			Case "#"
				$gaHotkeyList[$nIndex][4] += 4
			Case "!"
				$gaHotkeyList[$nIndex][4] += 8
		EndSwitch
		$sKey = StringMid($sKey, 2)
	WEnd
	$gaHotkeyList[$nIndex][6] = $sKey
	_ShowHotKey($nIndex)
EndFunc   ;==>_SetAutoItHotkey
#EndRegion HotkeyControl
#EndRegion Funktionen
