pintas Posted April 10, 2018 Share Posted April 10, 2018 (edited) I'm using MetroGUI UDF from BBs19 to make a nice script, but i cannot relate the control content to the control itself. I can find the ID (and even handle) but i can't get the content. The INI file is as follows: [Micro0001] Value0=B Value1=1 Value2=1 [Micro0002] Value0=B Value1=1 Value2=1 [Micro0003] Value0=E Value1=1 Value2=1 [Micro0004] Value0=B Value1=1 Value2=1 [Micro0005] Value0=F Value1=1 Value2=1 I'm trying to show the buttons text when i press the button, but i can't seem to find a way to do it. Can anyone point me in the right direction please? Also (another matter) is there a place where i can take a course of AutoIt? I seem to use it every now and then but never have the time to practice extensively... expandcollapse popup; =============================================================================================================================== ; Name ..........: MetroGUI UDF Example ; Version .......: v5.1 ; Author ........: BB_19 ; =============================================================================================================================== #include "MetroGUI-UDF\MetroGUI_UDF2.au3" #include "MetroGUI-UDF\_GUIDisable.au3" ; For dim effects when msgbox is displayed #include <Array.au3> $aArray = IniReadSectionNames(@ScriptDir&"\teste.ini") _ArrayDelete($aArray, 0) _ArrayDisplay($aArray) Global $WindowName = "GoncaPredict" Local $Form1 Local $iIndex Local $iTotButtons = UBound($aArray) Local $iNumPerRow = 5 Local $iButWidth = 49 Local $iButDepth = 30 Local $aButiD[$iTotButtons] _FirstGUI() Func _FirstGUI() _Metro_EnableHighDPIScaling() _SetTheme("DarkGray") $Form1 = _Metro_CreateGUI($WindowName, 1 + ($iButWidth + 1) * $iNumPerRow, 33 + Ceiling($iTotButtons / $iNumPerRow) * ($iButDepth + 1), -1, -1, 1) Local $iTotButtons = UBound($aArray) For $i = 0 To $iTotButtons - 1 $x = 1 + (($iButWidth + 1) * Mod($i, $iNumPerRow)) $y = 33 + (($iButDepth + 1) * Int($i / $iNumPerRow)) $aButiD[$i] = _Metro_CreateButton(StringTrimLeft($aArray[$i], 5), $x, $y, $iButWidth, $iButDepth) ConsoleWrite($aButiD[$i] & @LF) Next $Control_Buttons = _Metro_AddControlButtons(True, False, True, False, False) $GUI_CLOSE_BUTTON = $Control_Buttons[0] $GUI_MINIMIZE_BUTTON = $Control_Buttons[3] GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON _Metro_GUIDelete($Form1) Exit Case $GUI_MINIMIZE_BUTTON GUISetState(@SW_MINIMIZE, $Form1) Case $aButiD[0] To $aButiD[$iTotButtons -1] For $INDEX1 = 0 To $iTotButtons - 1 If $nMsg = $aButiD[$INDEX1] Then _GUIDisable($Form1, 0, 30) _Metro_MsgBox(0, "", "Value: " & $INDEX1, 250) _GUIDisable($Form1) $nMsg = "" EndIf Next EndSwitch WEnd EndFunc ;==>_FirstGUI Edited April 11, 2018 by pintas Link to comment Share on other sites More sharing options...
BrewManNH Posted April 10, 2018 Share Posted April 10, 2018 What do you mean by the Content? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
pintas Posted April 10, 2018 Author Share Posted April 10, 2018 (edited) 14 hours ago, BrewManNH said: What do you mean by the Content? Oh, sorry... I meant the text in the buttons, that is taken from the INI file. In a normal button, one can easily take the text from the button, but in these 'picture' buttons, and although it uses the text to create the buttons, it's using an array, and i can't set it to show a msgbox with the button text when i click on it. Edit: I changed the title. Edited April 11, 2018 by pintas Link to comment Share on other sites More sharing options...
Subz Posted April 11, 2018 Share Posted April 11, 2018 You need to use GuiCtrlRead to get the value of the button in your MsgBox GuiCtrlRead($aButiD[$INDEX1]) pintas 1 Link to comment Share on other sites More sharing options...
pintas Posted April 11, 2018 Author Share Posted April 11, 2018 (edited) Hi. Thanks for your reply. That unfortunately doesn't work. When i use the AU3 Info tool over a button, value 'Text' is empty because these buttons are actually pictures. Somehow i need to relate the array column to the control ID, or to attribute a text to the image button, which sounds more difficult. Edited April 11, 2018 by pintas Link to comment Share on other sites More sharing options...
BrewManNH Posted April 11, 2018 Share Posted April 11, 2018 When you set the text on the button, you should be able to know what you set it to shouldn't you? You have to code what to put in it during creation, or even during an update to the text, so just access that. pintas 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
pintas Posted April 11, 2018 Author Share Posted April 11, 2018 (edited) 36 minutes ago, BrewManNH said: When you set the text on the button, you should be able to know what you set it to shouldn't you? You have to code what to put in it during creation, or even during an update to the text, so just access that. The buttons are created according to SectionNames in an INI file generated by another script. I need to display the whole Section Name values. For example, i want to display the following values from the Section Name Micro0002: Value0=B Value1=1 Value2=1 The problem is that the Section Names are dynamic, and could be anything. If they were fixed, i could find a way around it, but they are computer names that vary. If i can get the name 'Micro0002' (in this case), i could display the respective section from the INI file. I already have the correct id ($INDEX1) but i need to relate it to the respective array column. I tried something like _Metro_MsgBox(0, "", "Value: " & $INDEX1 +1, 250) SOLVED! I was writing this and i found _ArrayToString. I just did this and it was solved: _Metro_MsgBox(0, "", "Value: " & _ArrayToString($aArray, @TAB, $INDEX1, $INDEX1), 250) Thank you so much for your help guys! Edited April 11, 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