detefon, There is a bug deep within the core AutoIt GUI code (and which will not be fixed any time soon) which means that colouring buttons leads to all sorts of problems - they trap the {ENTER} key and refuse many style changes (as you have discovered). I suggest you drop the idea of coloured buttons and perhaps use a border - like this:
#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
Global $hGui, $hMsg
Global $color
$hGui = GUICreate('title', 140, 80)
$cLabel = GUICtrlCreateLabel("", 8, 8, 124, 24)
GUICtrlSetBkColor($cLabel, 0xff0000)
$hButton0 = GUICtrlCreateButton('button', 10, 10, 120, 20, $BS_LEFT)
$hButton1 = GUICtrlCreateButton('change color', 10, 40, 120, 20)
GUISetState(@SW_SHOWNORMAL)
While 1
$hMsg = GUIGetMsg()
Switch $hMsg
Case $GUI_EVENT_CLOSE
_exit()
Case $hButton1
$color = _Iif($color == 0x00ff00, 0xff0000, 0x00ff00)
GUICtrlSetBkColor($cLabel, $color)
GUICtrlSetStyle($hButton0, $BS_LEFT);try coment and uncoment this line, and see the error...
EndSwitch
WEnd
Func _exit()
Exit
EndFunc ;==>_exit
How does that look to you? M23