Sign in to follow this  
Followers 0
shanet

Problem changing group and checkbox text colour

6 posts in this topic

Hi guys,

Been a while since I was last using AutoIt properly and it's showing!

I am creating a simple game launcher - before you all pounce, this is not a hack. I will use it to pass command line parameters to a game. Not to hack it.

Anyway, I have loaded the background image and have a button displayed - however the text on both the checkbox and group will not change?

Looking through the help file, I noted:

Only Button, Label, Checkbox, Group, Radio, Edit, Input, List, Listview, ListviewItem, Treeview, TreeviewItem, Graphic, Progress and Combo controls can currently be colored.

Checkbox, Radio, Group or Progress controls cannot be painted if the "Windows XP/Vista style" is used.

That sort of contradicts itself? My brother tried to show me optional 'workarounds' however neither of them suited what I want to do. So here is the program. Works the same without the background image.

#include <GDIPlus.au3>
#include <WinAPI.au3>

Global $hGUI, $hImage, $hGraphic, $hLabel
Global $hRunGroup, $hRun, $hRunTesting

; Create GUI
$hGUI = GuiCreate("Assaultcube Launcher", 400, 400)
;~   GUICtrlSetDefColor(0xFFFFFF, $hGUI)
  GUISetBkColor(0x000000, $hGUI)
GUISetState()

; Create background image
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile("C:\Program Files\AssaultCube_v1.1.0.4\packages\misc\startscreen.png")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 10, -20, 380, 380)

; Hide Loading... text
GUICtrlCreateLabel("", 130, 180, 120, 30)
GUICtrlSetBkColor(-1, 0x000000)

; Create controls
$hRunGroup = GUICtrlCreateGroup("Run Assaultcube", 10, 250, 380, 50)
$hRun = GUICtrlCreateButton("Run Assaultcube", 40, 300)
$hRunTesting = GUICtrlCreateCheckbox("Testing", 100, 100)

; Set appropriate colours
GUICtrlSetColor($hRunGroup, 0xFFFFFF)
GUICtrlSetColor($hRun, 0x000000 )
GUICtrlSetColor($hRunTesting, 0xFFFFFF)

While 1
switch GUIGetMsg()
case -3
_Exit()
EndSwitch

WEnd

Func _Exit()
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ShutDown()
Exit
EndFunc

Can anyone help me to set the group and checkbox text colours please? Please note the background colours must stay the same.


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites



shanet,

Next time just write a short script showing the problem that does not even mention games and then you will not have to go through the explanation and I will not get reports about the thread - makes us both happy. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Ok, I apologise for that. Any ideas Melba?


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

It's not a contradiction, you just need to disable theming to set colors for them.

Here's an example of mine I like to quote when this turns up.

You can make only the group-control run without any theme by doing like so:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

$Form1_1 = GUICreate("Amortization Plus", 644, 303, 207, 200)
GUISetBkColor(0x000080)
$Group1 = GUICtrlCreateGroup("Amortization Table", 8, 0, 625, 81, BitOR($BS_CENTER, $BS_FLAT))
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group1), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 10, 400, 0, "System")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

(this of course also works on Checkbox, Radio and Progress)

Or disable it for the whole gui like so:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)

$Form1_1 = GUICreate("Amortization Plus", 644, 303, 207, 200)
GUISetBkColor(0x000080)
$Group1 = GUICtrlCreateGroup("Amortization Table", 8, 0, 625, 81, BitOR($BS_CENTER, $BS_FLAT))
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 10, 400, 0, "System")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Func StyleToggle($Off = 1)
If Not StringInStr(@OSType, "WIN32_NT") Then Return 0
$XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
If $Off Then
  DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
  Return 1
ElseIf IsArray($XS_n) Then
  DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
  $XS_n = ""
  Return 1
EndIf
Return 0
EndFunc   ;==>StyleToggle

you can use this!

Example:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

StyleToggle(1)
$Form1_1 = GUICreate("Amortization Plus", 644, 303, 207, 200)
GUISetBkColor(0x000080)
$Group1 = GUICtrlCreateGroup("Amortization Table", 8, 0, 625, 81, BitOR($BS_CENTER, $BS_FLAT))
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 10, 400, 0, "System")
StyleToggle(0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

Func StyleToggle($Off = 1)
If Not StringInStr(@OSType, "WIN32_NT") Then Return 0
$XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
If $Off Then
  DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
  Return 1
ElseIf IsArray($XS_n) Then
  DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
  $XS_n = ""
  Return 1
EndIf
Return 0
EndFunc   ;==>StyleToggle
Edited by golfinhu

Share this post


Link to post
Share on other sites

AdmiralWithHat, many thanks for that DllCall. Works like a charm.

Maybe that should be included in the help file? If it is, I apologise for missing it.

Thanks guys!


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

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  
Followers 0

  • Similar Content

    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Guys this is my gui and i need the numeric value typed in the highlighted  inputbox. if this value is greater than 1 i need to perform some operations
      \
       
      Here is the summary about that field which i got from wininfo tool

      i tried writing the code as shown below.. but the msgbox is popping up empty value..when the same code is pasted under some button action i am able to access the value present in the field..but when placed alone as written in the attached script i am unable to fetch it... 

      here i am using the valu present in the field

      can you guys tell me what's wrong??? or how can i get that value?
       
      My_GUI.au3

    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      in need the path/text present int above shown input box to be copied or retrieved into a variable .. how can i do that?
       
      Thanks
       
    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Friends i am new to autoit and i am stuck in middle of automation of flashing tool..
      my requirement is i have a window and i have to get the value present in that window (below is the picture)

      in the above window i need to get the value of the highlighted field.the value of this filed keeps on changing...ii need to get the current value present in the field..below are the details of the window and field..

       
      CAN it be done?
       
      thanks

    • houser747
      By houser747
      I have previously used _IEFormElementGetObjByName and _IEFormElementSetValue to enter text into a search box on a form and then submit the form.
      I am now trying to enter text into a search box which is not part of a form. 
      Here is the HTML from the website that i'm trying to enter the data on and then submit the search.
      <div class="row">
          <div class="form-group col-xs-12">
              <span id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_lblSearchText" for="input-search">Registreringsbeteckning</span>
              <div class="input-group col-xs-12">
                  <span id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_preSearchText" class="input-group-addon">SE -</span>
                  <input name="ctl00$FullWidthWithSubmenuContent$FullWidthContent$MainContent$AircraftRegistry$txtSearchText" type="text" value="DTH" id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_txtSearchText" class="form-control" />
              </div>
          </div>
      </div>
      <div class="row">
          <div class="form-group col-xs-12">
              <label class="sr-only" for="">Sök</label>
              <input type="submit" name="ctl00$FullWidthWithSubmenuContent$FullWidthContent$MainContent$AircraftRegistry$btnSearch" value="Sök" id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_btnSearch" class="btn btn-primary ladda-button" data-style="expand-right" />
          </div>
      </div>
      Many thanks in advance
      cheers
      Roger
    • Jibberish
      By Jibberish
      Hello,
      I have used this forum to get help many times. I thought it was time to (hopefully) help others.
      I created a script that reads a text file with a list of videos, displays the videos in a GUI with checkboxes next to the names, and displays the selected videos. This will become a part of a larger script I am creating to test a video player. The tough part for me was creating the GUI and Dynamic list of videos. I had a lot of trouble finding samples to help me, but finally found one  written by Melba23. The link is in the code, so he gets credit for helping! I also have not used arrays much and they are very picky about looping through the arrays without getting the dreaded error " Array variable has incorrect number of subscripts or subscript dimension range exceeded."  However diligence paid off!
      To run this code, take the video names commented below and create a videos.txt file in your script execution directory. You can put however many video names in this list. Thus the dynamic features of the code.
      Cheers!
      Jibberish
      #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <array.au3> #include <File.au3> #include <GUIConstantsEx.au3> Local $sMediaFile = @ScriptDir & "\videos.txt" ;~ Videos in videos.txt are: ;~ bbb_1080_60s.mp4 ;~ bbb_1080_60s_1.mp4 ;~ bbb_1080_60s_2.mp4 ;~ tos_4K_60s_HEVC.mp4 ;~ tos_4K_60s_HEVC_1.mp4 ;~ tos_4K_60s_HEVC_2.mp4 ;~ ;~ Additional videos can be added to this list. The functions are Dynamic. Dim $aMediaManifest Local $aArrayFile Local $aVideos Local $sVideoName Local $i ; MAIN ; Put the Video File Names into an Array _FileReadToArray($sMediaFile, $aArrayFile) Local $iVideoCount = UBound($aArrayFile) -1 ; Get the number of videos - 1 to prevent errors _ArrayDelete($aArrayFile, 0) ;Counter just gets in the way ; Move backwards through the array deleting the blank lines For $i = $iVideoCount - 1 To 0 Step -1 If $aArrayFile[$i] = "" Then _ArrayDelete($aArrayFile, $i) EndIf Next $aVideos = DisplayVideos($aArrayFile) $iVideoCount = UBound($aArrayFile) -1 _ArrayDisplay($aVideos) ; Display the checked videos ;~ End of MAIN ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; GUI to display Videos in checkboxes ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func DisplayVideos($aArrayFile) Local $iTop = -1 Local $iLeft = -1 Local $iWidth Local $iHeight = $iVideoCount * 30 Local $iL = 10 Local $iT = 10 Local $iRow = 0 Local $aVideo Local $iA = 0, $iB = 0 Local $sFill = "" $iMMCount = UBound($aArrayFile) $iMMNewCount = $iMMCount - 1 Local $aGUICheckbox[$iMMCount] Local $aCheckedVideos[$iMMCount] ; Put the Video File Names into an Array $hGUI = GUICreate("Video Checkbox", $iLeft, $iTop, $iWidth, $iHeight) GUICtrlCreateLabel("Videos", 180, $iT) $iT = $iT + 30 ; This is a great example of using arrays to create GUI check boxes or radio buttons For $i = 0 To $iMMNewCount Step 1 $sMP4Text = $aArrayFile[$i] $aGUICheckbox[$i] = GUICtrlCreateCheckbox($sMP4Text, 30, $iT) $iT += 30 Next $idClose1 = GUICtrlCreateButton("Start", $iL, $iT) GUISetState(@SW_SHOW) ; This section reads the checkboxes and puts the video names in an array in their original position ; in case this is important (as it is to me) ; This was the toughest part to code, and I found no samples online until I saw Melba23's sample here: ; https://www.autoitscript.com/forum/topic/119843-dynamic-gui-problem/#comment-832672 ; I got this working with only a little modification. THANK YOU MELBA23 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idClose1 For $i = 0 To $iMMNewCount Step 1 Switch GUICtrlRead($aGUICheckbox[$i]) Case $GUI_CHECKED $aCheckedVideos[$i] = $aArrayFile[$i] Case $GUI_UNCHECKED EndSwitch Next ExitLoop EndSwitch WEnd GUIDelete($hGUI) Return $aCheckedVideos EndFunc ;==>DisplayVideos