I'm trying to make a GUI window with an Edit control inside that will automatically resize to fit the GUI. How can I get the current dimensions of the GUI window?
Here's my code:
#Requires AutoHotkey 2.0
ResizeWindow(*) {
EditBox.Opt("w" TextBoxGUI.Width " h" TextBoxGUI.Height) ; Here's the issue
}
TextBoxGUI := Gui("+Resize", "TextBox GUI")
TextBoxGUI.OnEvent("Size", ResizeWindow)
TextBoxGUI.SetFont("s15 Norm", "Lexend")
EditBox := TextBoxGUI.Add("Edit", "x0 y0 w500 h600")
TextBoxGUI.Show("w500 h600")
I have edited the codes as follows.
There is also a sample code for this on the autohotkey help page.
https://www.autohotkey.com/docs/v2/lib/Gui.htm#ExEditor
#Requires AutoHotkey 2.0
TextBoxGUI := Gui("+Resize", "TextBox GUI")
TextBoxGUI.OnEvent("Size", ResizeWindow)
TextBoxGUI.SetFont("s15 Norm", "Lexend")
EditBox := TextBoxGUI.Add("Edit", "x0 y0 w500 h600")
TextBoxGUI.Show("w500 h600")
ResizeWindow(GuiObj, MinMax, Width, Height) {
if MinMax = -1 ; The window has been minimized. No action needed.
return
EditBox.Move(,,Width,Height)
}