Jump to content
Sign in to follow this  

Color Select Example

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>
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")
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $file_notepad Then
             $file = Run("notepad.exe")
        if $msg = $file_computer Then
             $file = Run("explorer.exe")
        If $msg = $file_exit Then
        If $msg = $actions_txt_file Then
            $txt_file_1 = FileOpenDialog("Choose a Text File to Open...", @DesktopDir, "Text Files(*.txt)")
        If $msg = $actions_calc Then
        If $msg = $help_about Then
            $help = MsgBox(0, "About", "This Test GUI Was Created by ReaperX")
        Case $msg = $bg_red_radio
        Case $msg = $bg_green_radio
        Case $msg = $bg_yellow_radio

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
While 1
    $msg = GUIGetMsg()
    if $msg = $GUI_EVENT_CLOSE Then Exit
        Case $msg = $button
            $color = _ChooseColor($iReturnType)

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

Share this post

Link to post
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
Sign in to follow this  

  • Similar Content

    • lenclstr746
      By lenclstr746
      I'm a work on a background see and click bot project 
      I can complete it if your help me
      (using imagesearch , gdi+ and  fastfind)
    • ur
      By ur
      When we run our exe from any service or through any background process, it won't interact with the applications running in the foreground, I mean launched when the user is logged in or in GUI mode.
      Let's say, the onedrive sync app can't be detected from the exe we created and running it in background.

      I tried both options below.

      Any Idea how to interact with foreground processes using AuotIT code.

      Other than telling to launch the exe also in foreground.
    • SaeidN
      By SaeidN
      I saw a couple topics about both mousedrag and imagesearch in background or minimized window, but none of them has the solution, and they were old topics.
      So I wanted to ask whether there is a way to mouse drag without the cursor to move, (I want to use mouse when mousedrag is working on a window). I don't know whether I can mix ControlMove with some other stuff or any other way?
      And also for the image search, is there any way to search for image (or pixel) in a background or minimized window? I thought maybe there is a au3 or dll or ... file for doing this.
      Another question I have: Any way to pinch zoom (two fingers) a window like "windows photo viewer" to zoom in or out? I saw something almost the same here, but not what I want.
      I appreciate it.
    • FMS
      By FMS
      I'm rather new at Autoit (picked it up again afther a couple of years) but i dont know what I'm doing wrong here.
      I hope somebody can help me making this script "better readeble" and explain what I'm doing wrong here.
      The thing that i want to do here is making a tool that helps me whit doing mine work.
      Also want to do the "ping" command in the background whit only a msgbox if ok or not.
      In the code I'm writing now I'm using Send commands but know that there is a better way for this.
      At this point there is a error also whish i do not udnerstand where it is comming from.
      the error i get is:
      MsgBox($MB_SYSTEMMODAL, "Error", " Error no IP or name is filled in")
      MsgBox(^ ERROR
      Could somebody help me whit looking at this code?
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 385, 112, 192, 124) $iIP = GUICtrlCreateInput("", 80, 16, 209, 21) $btn_ping = GUICtrlCreateButton("Ping", 24, 56, 89, 25) $btn_vnc = GUICtrlCreateButton("VNC", 136, 56, 89, 25) $btn_evr = GUICtrlCreateButton("Eventvieuwer", 248, 56, 89, 25) GUISetState(@SW_SHOW) Func check_input() If GUICtrlRead($iIP) = "" Then Return False Else Return True Endif EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btn_ping $check = check_input() If ($check = False) Then Run ("cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send ("ping " & GUICtrlRead($iIP) & "{ENTER}") WinClose ("C:\WINDOWS\system32\cmd.exe") ;if ping OK then msgbox OK else NOK Else MsgBox($MB_SYSTEMMODAL, "Error", " Error no IP or name is filled in") EndIf Case $btn_vnc $check = check_input() If ($check = False) Then Run ("cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send ("eventvwr.exe " & GUICtrlRead($iIP) & "{ENTER}") WinClose ("C:\WINDOWS\system32\cmd.exe") Else MsgBox($MB_SYSTEMMODAL, "Error", " Error no IP or name is filled in") EndIf Case $btn_evr $check = check_input() If ($check = False) Then Run ("cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send ("vncviewer " & GUICtrlRead($iIP) & "{ENTER}") WinClose ("C:\WINDOWS\system32\cmd.exe") Else MsgBox($MB_SYSTEMMODAL, "Error", " Error no IP or name is filled in") EndIf EndSwitch WEnd  
    • shokwave8
      By shokwave8
      Hello there Com,
      The following is my problem. I try to create a window with Koda-Formdesigner and the background of the Form, Button and Edit shall be blue with white letters. Everytime i run the code the colour from button and edit background sets to default. 
      i tried to set the backgroundcolour manually to blue for the button and the editbox but then the GUI just does not appear while running the script. 
      I got you some screens of Koda (howitshould.jpg) and the actual running script (howitis.jpg). I hope you guys can help me  
      Thanks for reading and replying.
      (I'm german and i might did some mistakes in language )



Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.