Removed Areas > AutoHotkey
Hide Gui Buttons previously created
(1/1)
justice:
In a loop I create a bunch of buttons with the following code:
Code:
--- Code: Autohotkey ---Gui, Add, Button, gButtonDestinationSelect HWNDButtonDestinationSelect%a_index%, %ButtonLabel%
Later on I want to hide/disable all these buttons using GuiControlGet, Hide but I'm not able to 'point' to these buttons, could anyone write a quick example?
skwire:
GuiControlGet doesn't handle hiding/showing/disabling/enabling of buttons. GuiControl does. Consider this example:
--- Code: Autohotkey ---Loop, 6{ Gui, Add, Button, vmyButton%A_Index%, Click me}Gui, Show Sleep, 1500 ; Small delay to show form before changes. Loop, 6{ If ( Mod( A_Index, 2 ) = 1 ) ; Hide odd-numbered buttons. { GuiControl, Hide, myButton%A_Index% } Else ; Disable even-numbered buttons. { GuiControl, Disable, myButton%A_Index% } Sleep, 500 ; Small delay to show changes happening.} Return ; End of auto-execute section. GuiClose:GuiEscape:{ ExitApp}Return
justice:
Thanks, sorry that was lazy typing I meant GuiControl. However, my buttons to not have variables assigned to them for a specific reason I cannot remember why, is there a way to do it without?
skwire:
In regards to GuiControl -- you have two choices if you don't have variable names assigned to the buttons.
* You can use the "classname + instance number" combo. Button1, Button2, etc. I would advise against this method since that enumeration will change if you add other buttons before you add those looped buttons.
* You can use the text of the button itself. Obviously, the text would need to be unique for each button (which I don't think it is in your case).
justice:
Got it to work :) Great.
--- Code: Autohotkey ---Errorlevel =GuiControl,Enable,btn1%a_index% If ErrorLevel Gui, Add, Button, vbtn1%a_index%, %ButtonLabel% Else { GuiControl,Text,btn1%a_index%,%ButtonLabel% GuiControl,Show,btn1%a_index% }I'm still not sure why I removed the variables initially, so will do serious testing.. Thanks so much skwire :) sometimes AHK just lacks a simple example.
Navigation
[0] Message Index
Go to full version