It occurs to me to keep g2 in RAM and just show/hide it... Should I do that, or do you guys think the approach below is all-good?
Code: Select all
#SingleInstance
#Requires AutoHotkey v2+
; multi gui test
g1 := Gui()
g1.add('text',, 'click for on-demand gui')
g1.add('button', 'w300', 'make').OnEvent('click', makeg2)
g1.Show()
g2 := 0 ; Initialize g2 as null
makeg2(*)
{ ; Check if g2 exists and is an object, then destroy it
global g2
if (IsObject(g2))
g2.Destroy()
g2 := Gui()
g2.add('text',, 'this is gui 2')
g2butt := g2.add('button', 'w200', 'okay')
g2butt.OnEvent('click', alldone)
g2.Show()
}
alldone(*)
{ g2.Destroy()
MsgBox('thank you')
}