Simple textbox, submit with enter, in AutoHotKey

6,253

after a couple of minutes of reading autohotkey documentation Autohotkey GUI i create what i need

#SingleInstance, force
#o::
Gui, Add, Edit, vMyEdit -WantReturn
Gui, Add, Button, Default, OK
Gui, Show
return

Escape::
Gui, Destroy
return

GuiClose:
Gui, Destroy
return

ButtonOK:
Gui, Submit
SendInput <%MyEdit%>{Enter 2}</%MyEdit%>{Up}{Tab}
Gui, Destroy
Return

Also one can use an InputBox but i don't find how can subscribe the Escape key to kill the popup window, so i stick with this long but functional script.

Share:
6,253

Related videos on Youtube

mjsr
Author by

mjsr

Updated on September 17, 2022

Comments

  • mjsr
    mjsr over 1 year

    I never write an AutoHotKey script with a GUI, so I'm a little lost about how can I achieve what I want.

    I need that after pressing a hotkey opens a empty textbox that let me write anything until I press Enter. That key will close the textbox and somehow save that text in a variable.

  • martineau
    martineau about 13 years
    So, have you answered your original question?
  • martineau
    martineau about 13 years
    BTW, you don't need to "subscribe the Escape key" for an InputBox. Typing Esc does the same thing as pressing the Cancel button (and kills the popup window).
  • mjsr
    mjsr about 13 years
    @martineau your right, it doesn't work because i have running at the same time this other script, xD...thanks