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

    • By b9k
      Hi, I am stuck on a GUI problem and would like your help to solve it.
      I am trying to automate the SoundWire Server app to match my current system volume level while it is minimized to the notification area (so no clicking or stealing focus),
      I can already get the handle and alter the tracker position by sending a WM_SETPOS message, but somehow the actual volume is not changed: I think I need to do something else to trigger the event handler for the value change and propagate it correctly.
      This is the control summary from Au3 info:
      >>>> Window <<<< Title: SoundWire Server Class: #32770 Position: 441, 218 Size: 566, 429 Style: 0x94CA00C4 ExStyle: 0x00050101 Handle: 0x0000000000510E12 >>>> Control <<<< Class: msctls_trackbar32 Instance: 4 ClassnameNN: msctls_trackbar324 Name: Advanced (Class): [CLASS:msctls_trackbar32; INSTANCE:4] ID: 6002 Text: Position: 51, 222 Size: 47, 126 ControlClick Coords: 1, 101 Style: 0x5001000A ExStyle: 0x00000000 Handle: 0x00000000001234C8 >>>> Mouse <<<< Position: 496, 567 Cursor ID: 2 Color: 0xF0F0F0 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< Default multimedia device Tray on Start Static Server Address: Status: Connected to B9K~OP3 Audio Output Audio Input Level Record to File Input Select: 44.1 kHz Minimize to Master Volume Mute >>>> Hidden Text <<<< Slider2 Mute OK Cancel Label Balance Slider1 Volume Front L/R Fr C/LFE Side L/R Back L/R
      I am attaching the program in question so you don't have to install it (i don't know if it is portable enough, tough): 

      SoundWire Server_files.zip

      Thanks in advance and I hope I didn't post in the wrong section
    • 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)
    • 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.
    • 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.
    • 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  
  • Create New...