Gui control, controling wrong editbox. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Zseni
Posts: 53
Joined: 03 Nov 2019, 19:44

Gui control, controling wrong editbox.

13 Mar 2020, 17:36

Hello :wave:

What the variables contain

Code: Select all

LineColor = FFD80C
TextColor = FFD80C
BackgroundColor = 333437
Gui with edit boxes

Code: Select all

;GUI
    Gui,S1: Add, Text, x5 y20, Lines color:
    Gui,S1: Add, Edit, x5 y35 w60 vLineColor  Disabled Center, %LineColor% 
    HB_Button.Push(New Buttons_1(x:=70, y:=32, w:=30, h:=30, window:="S1", Label:="LineColor", Text:="Set", Font:= ButtonFont, Font_Size:="10 Bold", Font_Color_Top:= ButtonTextColorTop, Font_Color_Bottom:= ButtonTextColorBottom, Background_Color:= ButtonBackgroundColor , y_Offset:=0, Type:="" ))
    
    Gui,S1: Add, Text, x5 y70, Text color:
    Gui,S1: Add, Edit, x5 y85 w60 vTextColor  Disabled Center, %TextColor% 
    HB_Button.Push(New Buttons_1(x:=70, y:=82, w:=30, h:=30, window:="S1", Label:="TextColor", Text:="Set", Font:= ButtonFont, Font_Size:="10 Bold", Font_Color_Top:= ButtonTextColorTop, Font_Color_Bottom:= ButtonTextColorBottom, Background_Color:= ButtonBackgroundColor , y_Offset:=0, Type:="" ))
    
    Gui,S1: Add, Text, x5 y120, Background color:
    Gui,S1: Add, Edit, x5 y135 w60 vBackgroundColor  Disabled Center, %BackgroundColor% 
    HB_Button.Push(New Buttons_1(x:=70, y:=132, w:=30, h:=30, window:="S1", Label:="BackgroundColor", Text:="Set", Font:= ButtonFont, Font_Size:="10 Bold", Font_Color_Top:= ButtonTextColorTop, Font_Color_Bottom:= ButtonTextColorBottom, Background_Color:= ButtonBackgroundColor , y_Offset:=0, Type:="" ))
What the labels call

Code: Select all

LineColor(){
    SetColorTheme(LineColor)
}
TextColor(){
    SetColorTheme(TextColor)
}
BackgroundColor(){
    SetColorTheme(BackgroundColor)
}
My Function

Code: Select all

SetColorTheme(Var){
     SetTimer,ToolTipFollowMouse, On
    GuiControl,S1:Enable,% Var
    GuiControl,S1:Focus,% Var
    ToolTip, Enter to Confirm
    Loop{
        If GetKeyState("Enter"){
            ToolTip,
            GUI,S1:Submit, NoHide
            GuiControl,S1:Disabled,% Var
            Gui,2:destroy
            Gui,3:destroy
            Gui,4:destroy
            Gui,5:destroy
            
            Gui,SubSetting:destroy
            Gui,S1:destroy
            
            Create_Main_Window() ;Gui 1
            Create_SubTop_Window() ;Gui 2
            Create_SubBottom_Window() ;Gui 3
            Create_SubLeft_Window() ;Gui 4
            Create_SubRight_Window() ;Gui 5
            
            Create_SubSetting_Window() ;Gui SubSeting
            Create_Setting1_Window() ;Gui S1
            break
            }
        sleep, 25
    }
    SetTimer,ToolTipFollowMouse, Off
return
}

My problem is that when the second label is called "TextColor" the first GUI Edit box changes. I set the edit box var to "TextColor" and the GUI control is also set to change the "TextColor" but instead, the GUI control changes the "LineColor" Edit box. I'm thinking this is because both var is = to "FFD80C", that's a guess I really don't know. can anyone help to fix it?
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Gui control, controling wrong editbox.  Topic is solved

13 Mar 2020, 17:51

You don't have much code here to work with, but...

Try setting your variables as global and when you are passing them to your function, pass them as a string, otherwise you are passing the contents of the variable rather than the name used for GuiControl

Code: Select all

SetColorTheme("LineColor")
User avatar
Zseni
Posts: 53
Joined: 03 Nov 2019, 19:44

Re: Gui control, controling wrong editbox.

13 Mar 2020, 18:06

Hellbent wrote:
13 Mar 2020, 17:51
You don't have much code here to work with, but...

Try setting your variables as global and when you are passing them to your function, pass them as a string, otherwise you are passing the contents of the variable rather than the name used for GuiControl

Code: Select all

SetColorTheme("LineColor")
Doing the ("Thing") Worked, the script is now working just how I wanted. Thnx a lot

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CrowexBR, Google [Bot], mebelantikjaya and 311 guests