#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <array.au3>
Opt("WinTitleMatchMode", 3)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Window Transparency", 523, 251, 578, 335)
$List1 = GUICtrlCreateList("", 0, 0, 521, 201)
$Slider1 = GUICtrlCreateSlider(152, 216, 134, 29)
GUICtrlSetLimit(-1, 255, 0)
$Button1 = GUICtrlCreateButton("Setzte Transparenz", 8, 216, 123, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("0", 296, 216, 34, 28)
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("Liste erneuern", 352, 216, 107, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $Slider_Read
GUICtrlSetData($List1, "")
$Win = WinList()
For $i = 1 To $Win[0][0]
	If $Win[$i][0] <> "" Then _GUICtrlListBox_AddString($List1, $Win[$i][0])
Next
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			WinSetTrans(GUICtrlRead($List1), "", GUICtrlRead($Slider1))
			If Not @error Then
				MsgBox(0, "", "Transparenz wurde gesetzt")
			Else
				MsgBox(0, "", "Fehlgeschlagen")
			EndIf
		Case $Button2
			GUICtrlSetData($List1, "")
			$Win = WinList()
			For $i = 1 To $Win[0][0]
				If $Win[$i][0] <> "" Then _GUICtrlListBox_AddString($List1, $Win[$i][0])
			Next
	EndSwitch
	If GUICtrlRead($Slider1) <> $Slider_Read Then
		$Slider_Read = GUICtrlRead($Slider1)
		GUICtrlSetData($Label1, $Slider_Read)
	EndIf
	Sleep(20)
WEnd