3lbuniverse Posted January 18, 2010 Share Posted January 18, 2010 Hello there! Moving the mouse over a button changes it to blue, so how do I change the color it changes the button to? Can I get it to change the color of a button with a background color already set? Thanks for your help. Link to comment Share on other sites More sharing options...
picea892 Posted January 19, 2010 Share Posted January 19, 2010 Please provide code. If you have a code that changes a button to blue on mouseover it would be extremely simple to change the colour it changes to. Link to comment Share on other sites More sharing options...
3lbuniverse Posted January 19, 2010 Author Share Posted January 19, 2010 Thats the thing, when I move the mouse over the button, it just turns blue by itself. I didn't do anything and can't find any code to control the change at all. And when I color the button with a GUICtrlSetBkColor($btn,0xffe4b5), then it doesn't change color at all. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> GUICreate("Buttons", 510, 400) $btn = GUICtrlCreateButton("Button", 10, 10, 90, 50) GUISetState(@SW_SHOW) While 1 $msg= GUIGetMsg() Select Case $msg=$GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Link to comment Share on other sites More sharing options...
Mat Posted January 19, 2010 Share Posted January 19, 2010 I think that Custom drawing the control would do it, but unless you know what your doing it's probably not what you want to do. That colour is decided by the windows theme (I presume you are running vista, as thats the effect I get) AutoIt Project Listing Link to comment Share on other sites More sharing options...
3lbuniverse Posted January 19, 2010 Author Share Posted January 19, 2010 So, its a windows thing, not an autoit thing? I figured I might be dealing with some internal function that I couldn't bend to my will. I'm not sure what you mean by Custom drawing the control but I'm interested in learning more, especially if it's an alternative to the _ButtonHover. Any other approaches to controling the color of a button when the mouse is over it? Thanks! Link to comment Share on other sites More sharing options...
picea892 Posted January 19, 2010 Share Posted January 19, 2010 someone say custom buttons? Link to comment Share on other sites More sharing options...
3lbuniverse Posted January 20, 2010 Author Share Posted January 20, 2010 I got it! First I was making it too simple by hoping I could control what Mat pointed out was a windows vista theme, then I was was making it too complex trying to use new UDFs, though those buttons do look pretty cool picea892. I thought it had to be possible using simple GUIGetCursorInfo but I kept getting this flickering, so combing through this forum, Melba23 provided a perfect soultion with a flag to prevent the flickering. Works great, thank you all! #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> $Green=0x00FF00 $Red=0xFF0000 GUICreate("Buttons", 510, 400) $btn = GUICtrlCreateButton("Button", 10, 10, 90, 50) GUICtrlSetBkColor($btn, $Red) $fLabel = "Red" GUISetState(@SW_SHOW) While 1 $msg= GUIGetMsg() $a = GUIGetCursorInfo() Select Case $msg=$GUI_EVENT_CLOSE ExitLoop EndSelect If $a[4] = $btn And $fLabel = "Red" Then GUICtrlSetBkColor($btn, $Green) $fLabel = "Green" ElseIf $a[4] <> $btn And $fLabel = "Green" Then GUICtrlSetBkColor($btn, $Red) $fLabel = "Red" EndIf WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 20, 2010 Moderators Share Posted January 20, 2010 3lbuniverse,Delighted I could help without actually being there - so to speak! A couple of points:1. When you colour your buttons they trap "Enter" - i.e. whenever you press the "Enter" key, it is as though you pressed the button. It is a known bug and too deeply embedded in AutoIt for it to be changed. There is no reason not to colour buttons - but you need to be aware of this behaviour or it can get a bit confusing when the script apparently happens to fire off events on its own! Here is your code with a small addition - try pressing "Enter" and see what happens :#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> $Green = 0x00FF00 $Red = 0xFF0000 GUICreate("Buttons", 510, 400) $btn = GUICtrlCreateButton("Button", 10, 10, 90, 50) GUICtrlSetBkColor($btn, $Red) $fLabel = "Red" GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() $a = GUIGetCursorInfo() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btn MsgBox(0, "Button", "Did you click the button" & @CRLF & "Or press Enter?") EndSelect If $a[4] = $btn And $fLabel = "Red" Then GUICtrlSetBkColor($btn, $Green) $fLabel = "Green" ElseIf $a[4] <> $btn And $fLabel = "Green" Then GUICtrlSetBkColor($btn, $Red) $fLabel = "Red" EndIf WEnd2. When you post code, it makes it much easier to read if you use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
3lbuniverse Posted January 21, 2010 Author Share Posted January 21, 2010 I see what you mean about it pressing enter, thats interesting. Thanks for the tips! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now