Jump to content

Recommended Posts

Posted

I've created some buttons and I've used guictrlsetbkcolor to change their colors. I want to make the buttons flash two alternating colors, but I want to alternate with the exsisting color to another color. There is no command to get the bkcolor and I don't want to use pixelsearch, because I would have to know the coordinates for the buttons. Is there another way to get the background color from the button?

Posted

I've created some buttons and I've used guictrlsetbkcolor to change their colors. I want to make the buttons flash two alternating colors, but I want to alternate with the exsisting color to another color. There is no command to get the bkcolor and I don't want to use pixelsearch, because I would have to know the coordinates for the buttons. Is there another way to get the background color from the button?

Hi! 2 examples:

get color:

#include <GUIConstantsEx.au3>

Opt("PixelCoordMode", 2)

$hGUI = GUICreate("Get button color", 200, 100)

$button = GUICtrlCreateButton("Test", 60, 20, 75, 23)
GUICtrlSetBkColor(-1, 0xFF0000) ;red color

$GetColor_Button = GUICtrlCreateButton("Get", 60, 60, 75, 23)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GetColor_Button
            $aPos = ControlGetPos($hGUI, "", $button)
            $Color = PixelGetColor($aPos[0] + 3, $aPos[1] + 3)
            $Color = "0x" & Hex($Color, 6)
            MsgBox(0, "Color", $Color)
    EndSwitch
WEndoÝ÷ ÙÈZ¢Z+jëh×6#include <GUIConstantsEx.au3>

Global $color = 0xFF0000

Opt("PixelCoordMode", 2)

$hGUI = GUICreate("Get button color", 200, 100)

$button = GUICtrlCreateButton("Test", 60, 40, 75, 23)
GUICtrlSetBkColor(-1, $color)

GUISetState()

AdlibEnable("_SetColor", 500)

Do
Until GUIGetMsg() = -3

Func _SetColor()
    $color = BitNOT($color)
    GUICtrlSetBkColor($button, $color)
EndFunc

muttley

Posted

$color = 0xFFFFFF - $color

That changes the color to it's inverse each time, instead of to black...

I would probably use 2 separate colors.

#include <GUIConstantsEx.au3>

Global $color = 0xFF0000

Opt("PixelCoordMode", 2)

$hGUI = GUICreate("Get button color", 200, 100)

$button = GUICtrlCreateButton("Test", 60, 40, 75, 23)
GUICtrlSetBkColor(-1, $color)

GUISetState()

AdlibEnable("_SetColor", 500)

Do
Until GUIGetMsg() = -3

Func _SetColor()
    If $color = 0xFF0000 Then
        $color = 0x00FF00
    Else
        $color = 0xFF0000
    EndIf
    GUICtrlSetBkColor($button, $color)
EndFunc
  • 4 months later...
Posted

Hi,

why is it so hard to implement ...getbkColor functions?

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...