mikeyww wrote: ↑24 Apr 2023, 08:26
Code: Select all
#Requires AutoHotkey v2.0
MoveM := Gui(, 'Buttons')
b1 := MoveM.AddButton('w230 Default', 1), b1.OnEvent('Click', btn_Click)
b2 := MoveM.AddButton('wp' , 2), b2.OnEvent('Click', btn_Click)
b3 := MoveM.AddButton('wp' , 3), b3.OnEvent('Click', btn_Click)
MoveM.Show
btn_Click(btn, info) {
MsgBox btn.Text, 'You pressed', 64
b3.Opt('+Default')
b3.Focus
}
Thank you for your answer.
I create my GUI dynamically.
This is a part of my code:
Code: Select all
for j, m in n {
if j > 2
{
label := StartVal . m
default := MFocusLast = label ? "Default" : ""
link := MoveM.Add("Button", "x+5 " . "v" . label . " " . default, m)
link.OnEvent("Click", MoveStarter.Bind(label, "Normal"))
}
}
I read MFocusLast value from an ini file.
And when I close the GUI, MFocusLast value is written in an ini file.
I had no problems when I reload the GUI every time after clicking a button, but I decided not to reload the script every time, but minimize and restore the GUI, but MFocusLast is no longer updated every time.