Hi
magicinmath,
magicinmath wrote:Is it possible to remove the window buttons, minimize, maximize and close?
Code: Select all
Gui +Resize -SysMenu ; -MinimizeBox -MaximizeBox ; uncomment both last options if you don't want the window to be minimizable/maximizable (pressing Windows+Down/Up)
magicinmath wrote:Does gui need to ExitApp in order to close the gui window?
No. See especially
Gui, Destroy command:
magicinmath wrote:Why do I get an error if I try to run it a second time?
Your hotkey add a ListBox with the OPTION associated output variable without having destroying it before, yet the same variable cannot be used for more than one control. Use instead:
...or put this line:
Code: Select all
Gui Add, ListBox, vOPTION x15 y17 w100, 1||2|3
above your hotkey; this way your hotkey will only shows again the gui, not recreating each time the same control.
Also, if you intend to have a more complex gui, with other controls, you should check whether or not your listbox is actually the focused control before lunching the
GetListBoxValue label on Enter key press.
Code: Select all
OnWM_KEYDOWN(wParam, lParam, msg, hWnd) {
If (wParam == 13) {
GuiControlGet, focusedControl, Focus
if (focusedControl == "ListBox1")
GoSub GetListBoxValue
}
}
Hope this helps.
EDIT: Or you can do it even more easely using the
+Default button option:
Code: Select all
Gui, Add, Edit, w200, test
Gui Add, ListBox, vOPTION x45 y70 w100, 1||2|3
Gui, Add, Button, +Default gGetListBoxValue x-10 y-10 w5 h5, ; +/-Default. Creates a push button with a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely option.
!i::
Gui -SysMenu
Gui Show, AutoSize, %A_Space%
return
GetListBoxValue:
GuiControlGet, focusedControl, Focus
if (focusedControl == "ListBox1")
{
Gui Submit
; Gui, Destroy
MsgBox %OPTION%
}
return