Hallo Zusammen,
ich bin recht neu in der AutoIt Welt bin aber angenhem überrascht wie einfach man doch zu erfolgen kommen
Gestern Abend hab ich mich an ein ganz kleine Gui Anwendung versucht die auch im Grunde läuft aber mit einem Logik Fehler, und da hoffe ich nun auf eure Hilfe.
Ich habe ein kleine Gui mit 4 Buttons. Beim ersten Klick auf einem Button wird dieser Grün. So soll es auch sein. Sobald ich wieder auf diesem Button klicke wird dieser Rot. Dann wieder Grün und so weiter.
So nun habe ich aber 4 Buttons und es Klappt nicht mehr. Wenn ich den ersten Button auf Grün klicke und dann auf den zweiten wird dieser nicht auch Grün sondern gleich Rot.
Das soll natürlich nicht so sein. Hier mal mein Code :
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
Local $switch = False
GUICreate('')
$b1 = GUICtrlCreateButton("", 112, 64, 25, 25)
$b1LEDid = "0101"
$b2 = GUICtrlCreateButton("", 212, 64, 25, 25)
$b2LEDid = "0100"
$b3 = GUICtrlCreateButton("", 112, 128, 25, 25)
$b3LEDid = "0110"
$b4 = GUICtrlCreateButton("", 212, 128, 25, 25)
$b4LEDid = "1100"
GUISetState()
[/autoit][autoit][/autoit][autoit]While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $b1
$switch = Not $switch
If $switch Then
GUICtrlSetBkColor($b1,0x990000)
_Func1 ($b1LEDid)
Else
GUICtrlSetBkColor($b1,0x059122)
_Func1 ($b1LEDid)
EndIf
Case $b2
$switch = Not $switch
If $switch Then
GUICtrlSetBkColor($b2,0x990000)
_Func1 ($b2LEDid)
Else
GUICtrlSetBkColor($b2,0x059122)
_Func1 ($b2LEDid)
EndIf
Case $b3
$switch = Not $switch
If $switch Then
GUICtrlSetBkColor($b3,0x990000)
_Func1 ($b3LEDid)
Else
GUICtrlSetBkColor($b2,0x059122)
_Func1 ($b3LEDid)
EndIf
Case $b4
$switch = Not $switch
If $switch Then
GUICtrlSetBkColor($b4,0x990000)
_Func1 ($b2LEDid)
Else
GUICtrlSetBkColor($b4,0x059122)
_Func1 ($b2LEDid)
EndIf
EndSwitch
WEnd
Func _Func1 ($var)
MsgBox(0, "Test", $var)
EndFunc
Es ist doch sicher möglich das verhalten der Buttons so hin zu bekommen das die richtigen Farben kommen oder?
Eine weiter Frage die sich mit stellt kann man den Codeteil mit dem Switch verbessern?
Ich benötige Später nicht 4 Buttons sondern einige Hundert.
Beste Grüße
Luxor