pintas Posted April 6, 2018 Share Posted April 6, 2018 (edited) Hi, The code below creates buttons from an INI file 'Teste.ini'. I'm trying to change the color for specific buttons when Value0 of a section name is equal to B (for example). The SectionNames are buttons. And i need to somehow identify those buttons in the array so i can change their color, but i'm very confused... Can you guys help me out please? The INI file: [Button1] Value0=B Value1=1 Value2=1 [Button2] Value0=F Value1=1 Value2=1 [Button3] Value0=E Value1=1 Value2=1 [Button4] Value0=B Value1=1 Value2=1 The code: #include <GUIConstantsEx.au3> $optbar = IniReadSectionNames(@ScriptDir&"\teste.ini") local $ButtonBank $varStartHeight=0 $varStartHeight += 5 Dim $Button[4] GUICreate("Test") For $x = 1 To UBound($optbar) - 1 $Button[$x] = GUICtrlCreateButton($optbar[$x], $varStartHeight, 30, 55, 27) $varStartHeight += 60 Next GUISetState() While 1 $msg=GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Edited April 10, 2018 by pintas Link to comment Share on other sites More sharing options...
Danyfirex Posted April 7, 2018 Share Posted April 7, 2018 Hello. You could do this: #include <Array.au3> #include <GUIConstantsEx.au3> $optbar = IniReadSectionNames(@ScriptDir&"\teste.ini") ;~ _ArrayDisplay($optbar) local $ButtonBank $varStartHeight=0 $varStartHeight += 5 Dim $Button[4] GUICreate("Test") Local $sColor="" For $x = 1 To UBound($optbar) - 1 $Button[$x-1] = GUICtrlCreateButton($optbar[$x], $varStartHeight, 30, 55, 27) $sColor=IniRead(@ScriptDir&"\teste.ini",$optbar[$x],"Value0","") ConsoleWrite($sColor & @CRLF) If $sColor="B" Then GUICtrlSetBkColor($Button[$x-1],0x235464) EndIf If $sColor="F" Then GUICtrlSetBkColor($Button[$x-1],0xf53663) EndIf If $sColor="E" Then GUICtrlSetBkColor($Button[$x-1],0x473f6f) EndIf $varStartHeight += 60 Next GUISetState() While 1 $msg=GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
pintas Posted April 9, 2018 Author Share Posted April 9, 2018 (edited) Oh, thank you so much! Solved! Edited April 10, 2018 by pintas Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now