I intend to destroy the GUI, create a new one, and show it.
However, instead of that, it doesn't destroy the GUI; it keeps showing another GUI on top of another if I keep pressing F1.
Code: Select all
#Requires AutoHotkey v2.0
mode_GUI := Gui()
mode := "morning"
create_GUI(name_GUI, text) {
name_GUI.destroy()
name_GUI := GUI()
name_GUI.Add("Text",, text)
name_GUI.show()
}
f1:: {
global mode
mode == "morning" ? mode := "good evening" : mode := "morning"
create_GUI(mode_GUI, mode)
return
}
Code below is what I'm trying to achieve, but I don't like to hardcode GUI variable. I want to be able to pass other GUI variable.
Code: Select all
#Requires AutoHotkey v2.0
mode_GUI := Gui()
mode := "morning"
create_GUI(text) {
global mode_GUI
mode_GUI.destroy()
mode_GUI := GUI()
mode_GUI.Add("Text",, text)
mode_GUI.show()
}
f1:: {
global mode
mode == "morning" ? mode := "good evening" : mode := "morning"
create_GUI(mode)
return
}