Aassdd Posted February 27, 2008 Share Posted February 27, 2008 I have: $btn1 = g..button() $btn2 = g..button() $btn3 = g..button() And I want to set the same state to these controls avoiding this: GuiCtrlSetState($btn1, $gui_disable) GuiCtrlSetState($btn2, $gui_disable) GuiCtrlSetState($btn3, $gui_disable) Is it possible? Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 27, 2008 Share Posted February 27, 2008 I have: $btn1 = g..button() $btn2 = g..button() $btn3 = g..button() And I want to set the same state to these controls avoiding this: GuiCtrlSetState($btn1, $gui_disable) GuiCtrlSetState($btn2, $gui_disable) GuiCtrlSetState($btn3, $gui_disable) Is it possible? Store them in an array: expandcollapse popup#include <GuiConstants.au3> Opt("GuiOnEventMode", 1) Global $iButtonCnt = InputBox("Button Test", "How many buttons? (1 - 20):") If @error Then Exit $iButtonCnt = Number($iButtonCnt) If $iButtonCnt < 1 Or $iButtonCnt > 20 Then Exit Global $fColor = True Global $avButtons[$iButtonCnt + 1] = [$iButtonCnt] Global $hGUI = GUICreate("Button Test", 200, 10 + ($avButtons[0] * 40)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") For $n = 1 To $avButtons[0] $avButtons[$n] = GUICtrlCreateButton($n, 50, 10 + (($n - 1) * 40), 100, 30) GUICtrlSetOnEvent(-1, "_ButtonHit") Next AdlibEnable("_ToggleColor", 3000) GUISetState() While 1 Sleep(20) WEnd Func _Quit() Exit EndFunc Func _ButtonHit() MsgBox(64, "_ButtonHit()", "You clicked button: " & ControlGetText($hGUI, "", @GUI_CtrlId), 5) EndFunc Func _ToggleColor() Local $iColor = 0x0000FF $fColor = Not $fColor If $fColor Then $iColor = 0x00FF00 For $n = 1 To $avButtons[0] GUICtrlSetBkColor($avButtons[$n], $iColor) Next EndFunc Notice that in this demo, the script is working with any variable number of buttons. The _ToggleColor() function demonstrates accessing all of them in the array. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Aassdd Posted February 27, 2008 Author Share Posted February 27, 2008 Thank you so much, you are very helpful 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