Hallo, ich bin vor kurzem in die Welt von Autoit eingestiegen und stehe nun vor einem Problem. Ich möchte eine "hover-funktion" einbauen, sodass also beispielsweise ein button seine Farbe ändert, sobald ich mit der Maus über diesen schwebe. Ich weiß, dass es schon viele Einträge zu diesem Thema gibt, jedoch mache ich anscheinend irgendetwas falsch..
Ich hoffe ihr könnt mir weiterhelfen!
Hier ist mein Quellcode:
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
Global $GREEN = 0x00FF00
Global $RED= 0xFF0000
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]$Fav = GUICreate("Fav", 1200, 700, 300, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
$Pic = GUICtrlCreatePic("../Bilder/archiv.jpg", 0, -50, 1200, 801) ;Hintergrundbild
GUICtrlSetState(-1, $GUI_DISABLE)
$Games = GUICtrlCreateLabel("Games", 507.5, 60, 185, 60)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 40, 1000, 0, "Century Gothic")
$Button_f = GUICtrlCreateButton("Favoriten", 195, 180, 130, 41,$WS_GROUP)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button_s = GUICtrlCreateButton("Shooter", 331, 180, 130, 41,$BS_BITMAP, $WS_GROUP)
GUICtrlSetImage(-1, "../Bilder/button_shooter.bmp")
GUICtrlSetOnEvent(-1, "_shows")
$Button_r = GUICtrlCreateButton("RPG's", 467, 180, 130, 41,$WS_GROUP)
GUICtrlSetBkColor(-1, $GREEN)
GUICtrlSetOnEvent(-1, "_showr")
$Button_ra = GUICtrlCreateButton("Racing", 603, 180, 130, 41,$WS_GROUP)
;$GUICtrlSetOnEvent(-1, "_showra")
$Button_st = GUICtrlCreateButton("Strategy", 739, 180, 130, 41,$WS_GROUP)
;GUICtrlSetOnEvent(-1, "_showst")
$Button_o = GUICtrlCreateButton("Other", 875, 180, 130, 41,$WS_GROUP)
;GUICtrlSetOnEvent(-1, "_showo")
$Favoriten = GUICtrlCreateLabel("Favoriten", 104, 320, 135, 30)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 29, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1,$color_White)
GUISetState(@SW_SHOW)
$shoot = GUICreate("shoot", 1200, 700, 300, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
$Games = GUICtrlCreateLabel("Games", 545, 48, 110, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Shooter = GUICtrlCreateLabel("Shooter", 104, 320, 82, 28)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$Button_f = GUICtrlCreateButton("Favoriten", 208, 160, 130, 41,$WS_GROUP)
GUICtrlSetOnEvent(-1, "_showf")
$Button_s = GUICtrlCreateButton("Shooter", 344, 160, 130, 41,$WS_GROUP)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button_r = GUICtrlCreateButton("RPG's", 480, 160, 130, 41,$WS_GROUP)
GUICtrlSetOnEvent(-1, "_showr")
$Button_ra = GUICtrlCreateButton("Racing", 616, 160, 130, 41,$WS_GROUP)
;$GUICtrlSetOnEvent(-1, "_showra")
$Button_st = GUICtrlCreateButton("Strategy", 752, 160, 130, 41,$WS_GROUP)
;GUICtrlSetOnEvent(-1, "_showst")
$Button_o = GUICtrlCreateButton("Other", 888, 160, 130, 41,$WS_GROUP)
;GUICtrlSetOnEvent(-1, "_showo")
GUISetState(@SW_HIDE)
$rp = GUICreate("rpg", 1200, 700, 300, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
$Games = GUICtrlCreateLabel("Games", 545, 48, 110, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$RPG = GUICtrlCreateLabel("RPG's", 104, 320, 82, 28)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$Button_f = GUICtrlCreateButton("Favoriten", 208, 160, 130, 41,$WS_GROUP)
GUICtrlSetOnEvent(-1, "_showf")
$Button_s = GUICtrlCreateButton("Shooter", 344, 160, 130, 41,$WS_GROUP)
GUICtrlSetOnEvent(-1, "_shows")
$Button_r = GUICtrlCreateButton("RPG's", 480, 160, 130, 41,$WS_GROUP)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button_ra = GUICtrlCreateButton("Racing", 616, 160, 130, 41,$WS_GROUP)
; $GUICtrlSetOnEvent(-1, "_showra")
$Button_st = GUICtrlCreateButton("Strategy", 752, 160, 130, 41,$WS_GROUP)
; GUICtrlSetOnEvent(-1, "_showst")
$Button_o = GUICtrlCreateButton("Other", 888, 160, 130, 41,$WS_GROUP)
; GUICtrlSetOnEvent(-1, "_showo")
GUISetState(@SW_HIDE)
While 1
Sleep(100)
WEnd
$Button = 0
while 1
$Maus_pos = GUIGetCursorInfo()
Select
case $Maus_pos[4] = $Button_r And $Button <> 1
GUICtrlSetBkColor($Button_r,$RED)
$Button = 1
case $Maus_pos[4] <> $Button_r And $Button = 1
GUICtrlSetBkColor($Button_r, $GREEN)
$Button = 0
EndSelect
[/autoit] [autoit][/autoit] [autoit]WEnd
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _showf()
GUISetState(@SW_HIDE, $shoot)
GUISetState(@SW_HIDE, $rp)
GUISetState(@SW_SHOW, $Fav)
EndFunc ;==>_show1
Func _shows()
GUISetState(@SW_HIDE, $Fav)
GUISetState(@SW_HIDE, $rp)
GUISetState(@SW_SHOW, $shoot)
EndFunc ;==>_show2
Func _showr()
GUISetState(@SW_HIDE, $Fav)
GUISetState(@SW_HIDE, $shoot)
GUISetState(@SW_SHOW, $rp)
EndFunc ;==>_show3
Func _exit()
Exit
EndFunc ;==>_exit