GuiControl, Disable, % var

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
inseption86
Posts: 205
Joined: 19 Apr 2018, 00:24

GuiControl, Disable, % var

17 Dec 2019, 08:33

Hi guys, the buttons are locked only on the first tab, but how to make sure that the rest are blocked

Code: Select all


Gui, +ToolWindow +AlwaysOnTop
Gui, Add, Tab2,   vTAB,`         2         |         3         |         4         | 

loop 3
{
Gui, Tab, %A_index%
Loop
{
    FileReadLine, line, S:\Смирнов\1_smen.txt, %A_Index%
    if ErrorLevel
        break
Gui, Add, Button,  gGetName, %line%
}

Gui, Add, Text , w0 h0 x+10 y190

Loop
{
    FileReadLine, line, S:\Смирнов\2_smen.txt, %A_Index%
    if ErrorLevel
        break
Gui, Add, Button,  gGetName, %line%
}
Gui, Add, Text, x450 y5  h104  0x11 
}

Gui, Show, 
return

getname:

GuiControlGet, var,, % A_GuiControl
GuiControl, Disable, % var

just me
Posts: 9459
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: GuiControl, Disable, % var

17 Dec 2019, 11:30

If you use the control's text/caption as ControlID AHK will always use the first control with that text even if not currently visible. So use unique vName variables as IDs for your buttons (-> https://www.autohotkey.com/docs/commands/Gui.htm#Events).

For example:

Code: Select all

; ...
Loop 3
{
   TabNum := A_Index
   Gui, Tab, %TabNum%
   Loop
   {
      FileReadLine, Line, S:\Смирнов\1_smen.txt, %A_Index%
      If (ErrorLevel)
         Break
      Gui, Add, Button, gGetName vBtn%TabNum%%A_Index%, %Line%
}
Gui, Add, Text , w0 h0 x+10 y190
; ...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Joey5, ShatterCoder, Xaucy and 188 guests