As a new poster in this board, I want to firstly say a huge "thank you" to its community that helped me thousands of times in coping with my poor scripting skills.
Secondly, I beseech you to help me as I have a problem that I can't seem to solve : I have a Gui1 that contains a button that duplicates Gui1 to Gui++. Gui1 and Gui++ are almost the same, Gui1 has a button that Gui++ hasn't. I can therefor have dozens of Guis that will serve me as stickynotes for a bigger project.
The GOSUB generating Gui++ is the same as Gui1 creation code and I find it difficult to have to update both codes everytime I change for say a button width or a font color.
What I would like you to help me with is by optimizing the Guis creation code that follows:
Code: Select all
#SingleInstance,Force
; ===============================================
; Variables
; ===============================================
; Main UI settings
; ===============================================
Gui_Name := 1 ; to number Gui ids
GuiMain_Xpos := 1000 ; used by duplicate window and forthcoming location function
GuiMain_Ypos := 100 ; used by duplicate window and forthcoming location function
; ===============================================
; Main Gui layout
; ===============================================
Gui, %Gui_Name%: +Caption +Border
Gui, %Gui_Name%: Color, cFFFFFF
Gui, %Gui_Name%: Add, Text, x10 y10, [Instance%Gui_Name%]
Gui, %Gui_Name%: Add, Button, Section xp y+10 w100 h25 gButton_NewWindow, New Window
Gui, %Gui_Name%: Add, Button, -Tabstop ys wp hp gButton_Settings, Settings
Gui, %Gui_Name%: Add, Button, ys wp hp gGuiClose, &Close
Gui, %Gui_Name%: Show, x%GuiMain_Xpos% y%GuiMain_Ypos% w340 h70, Test
Return
; ===============================================
;Labels
; ===============================================
;New popup
; ===============================================
Button_NewWindow:
Gui_Name++
WinGetPos, Xpos, Ypos,, %Gui_Name%
Xpos := Xpos + 50
Ypos := Ypos + 25
#SingleInstance off
Gui, %Gui_Name%: +AlwaysOnTop +LastFound +Caption +Border
Gui, %Gui_Name%: New
Gui, %Gui_Name%: Color, cFFFFFF
Gui, %Gui_Name%: Add, Text, x10 y10, [Instance%Gui_Name%]
Gui, %Gui_Name%: Add, Button, Section xp y+10 w100 h25 gButton_NewWindow, New Window
Gui, %Gui_Name%: Add, Button, -Tabstop ys wp hp hidden gButton_Settings, Settings
Gui, %Gui_Name%: Add, Button, ys wp hp gGuiClose_New, &Close
Gui, %Gui_Name%: Show, x%Xpos% y%Ypos% w340 h70, Test
Return
GuiClose:
ExitApp
Return
GuiClose_New:
WinGetTitle, Title, A
PostMessage, 0x112, 0xF060,,, %Title%
Return
Button_Settings:
Return
; ===============================================
;Functions
; ===============================================