Jump to content

Color Select Example


armoros
 Share

Recommended Posts

These are 2 useful examples on how to change the color of a GUI background.

They are made by a user named ReaperX from another forum, not Autoit

and i didn't ask his permission. Can't tell the forum, maybe it breaks this forums rules.

1) A Sample GUI. It Just Uses 3 Radio Buttons and You Choose One to Change the GUI BG Color to.

include <GUIConstants.au3>
MainGUI()
Func MainGUI()
    GUICreate("ReaperX's Test GUI")
    $file = GUICtrlCreateMenu("File")
    $file_notepad = GUICtrlCreateMenuItem("Open Notepad", $file)
    $file_computer = GUICtrlCreateMenuItem("Open My Computer", $file)
    $file_exit = GUICtrlCreateMenuItem("Exit", $file)
    $actions = GUICtrlCreateMenu("Actions")
    $actions_txt_file = GUICtrlCreateMenuItem("Open Text File", $actions)
    $actions_calc = GUICtrlCreateMenuItem("Open Calculator", $actions)
    $help = GUICtrlCreateMenu("Help")
    $help_about = GUICtrlCreateMenuItem("About", $help)
    $tab_set = GUICtrlCreateTab(110, 100, 135, 150)
    $tab_1 = GUICtrlCreateTabItem("Change BG")
    $bg_red_radio = GUICtrlCreateRadio("Red", 115, 125)
    $bg_green_radio = GUICtrlCreateRadio("Green", 115, 145)
    $bg_yellow_radio = GUICtrlCreateRadio("Yellow", 115, 165)
    $tab_2 = GUICtrlCreateTabItem("AutoIt Info")
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $file_notepad Then
             $file = Run("notepad.exe")
         EndIf
        if $msg = $file_computer Then
             $file = Run("explorer.exe")
         EndIf
        If $msg = $file_exit Then
             Exit
         EndIf
        If $msg = $actions_txt_file Then
            $txt_file_1 = FileOpenDialog("Choose a Text File to Open...", @DesktopDir, "Text Files(*.txt)")
            FileOpen($txt_file_1)
         EndIf
        If $msg = $actions_calc Then
            Run("calc.exe")
         EndIf
        If $msg = $help_about Then
            $help = MsgBox(0, "About", "This Test GUI Was Created by ReaperX")
        EndIf
        Select
        Case $msg = $bg_red_radio
            GUISetBkColor(0xED1C24)
        Case $msg = $bg_green_radio
            GUISetBkColor(0x22B14C)
        Case $msg = $bg_yellow_radio
            GUISetBkColor(0xFFF200)
            EndSelect
    WEnd
EndFunc

2) Brings up a Color Pallette in the GUI and You Use it To Select a Color to Change the BG of the GUI to.

#Include <GUIConstants.au3>
#Include <Misc.au3>
GUICreate("Choose Color")
$button = GUICtrlCreateButton("Choose Color", 150, 150)
$iReturnType = 2
GUISetState()
While 1
    $msg = GUIGetMsg()
    if $msg = $GUI_EVENT_CLOSE Then Exit
        Select
        Case $msg = $button
            $color = _ChooseColor($iReturnType)
            GUISetBkColor($color)
        EndSelect
        WEnd

[font="verdana, geneva, sans-serif"] [/font]

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...