在AutoHotKey中,我希望有类似InputBox的东西,除了文本输入是多行的。 (比如textarea)。
我希望有两个按钮,“Ok”和“Cancel”,我希望它们都有加速器。 我希望这个代码是一个函数的形式,我可以从其他热键调用,以便随时获取多行用户输入。 我希望能够设置显示对话框时显示的默认文本。 如果按下取消按钮,我希望函数返回null或空字符串。 我想要Esc键使对话框关闭,就像按下取消按钮一样(并且不退出整个脚本)。 我希望对话框显示在屏幕的中央,并使用Windows通常用于对话框的字体。
In AutoHotKey, I want to have something like InputBox except that the text input is multiline. (i.e. like a textarea).
I want there to be two buttons, "Ok" and "Cancel", and I want them both to have accelerators. I want this code to be in the form of a function that I can call from other hotkeys to get multiline user input whenever I want. I want to be able to set the default text shown when the dialog is shown. I want the function to return null or empty string if the cancel button was pressed. I want the Esc key to cause the dialog to be closed as if the cancel button was pressed (and not exit the entire script). I want the dialog to show in the center of the screen, and to use the font that Windows usually uses for dialogs.
最满意答案
尝试这个
!1:: MsgBox % MultiLineInputBox("Hello World:", "stuff, more stuff", "Custom Caption") return MultiLineInputBox(Text:="", Default:="", Caption:="Multi Line Input Box"){ static ButtonOK:=ButtonCancel:= false if !MultiLineInputBoxGui{ Gui, MultiLineInputBox: add, Text, r1 w600 , % Text Gui, MultiLineInputBox: add, Edit, r10 w600 vMultiLineInputBox, % Default Gui, MultiLineInputBox: add, Button, w60 gMultiLineInputBoxOK , &OK Gui, MultiLineInputBox: add, Button, w60 x+10 gMultiLineInputBoxCancel, &Cancel MultiLineInputBoxGui := true } GuiControl,MultiLineInputBox:, MultiLineInputBox, % Default Gui, MultiLineInputBox: Show,, % Caption SendMessage, 0xB1, 0, -1, Edit1, A while !(ButtonOK||ButtonCancel) continue if ButtonCancel return Gui, MultiLineInputBox: Submit, NoHide Gui, MultiLineInputBox: Cancel return MultiLineInputBox ;---------------------- MultiLineInputBoxOK: ButtonOK:= true return ;---------------------- MultiLineInputBoxGuiEscape: MultiLineInputBoxCancel: ButtonCancel:= true Gui, MultiLineInputBox: Cancel return }try this
!1:: MsgBox % MultiLineInputBox("Hello World:", "stuff, more stuff", "Custom Caption") return MultiLineInputBox(Text:="", Default:="", Caption:="Multi Line Input Box"){ static ButtonOK:=ButtonCancel:= false if !MultiLineInputBoxGui{ Gui, MultiLineInputBox: add, Text, r1 w600 , % Text Gui, MultiLineInputBox: add, Edit, r10 w600 vMultiLineInputBox, % Default Gui, MultiLineInputBox: add, Button, w60 gMultiLineInputBoxOK , &OK Gui, MultiLineInputBox: add, Button, w60 x+10 gMultiLineInputBoxCancel, &Cancel MultiLineInputBoxGui := true } GuiControl,MultiLineInputBox:, MultiLineInputBox, % Default Gui, MultiLineInputBox: Show,, % Caption SendMessage, 0xB1, 0, -1, Edit1, A while !(ButtonOK||ButtonCancel) continue if ButtonCancel return Gui, MultiLineInputBox: Submit, NoHide Gui, MultiLineInputBox: Cancel return MultiLineInputBox ;---------------------- MultiLineInputBoxOK: ButtonOK:= true return ;---------------------- MultiLineInputBoxGuiEscape: MultiLineInputBoxCancel: ButtonCancel:= true Gui, MultiLineInputBox: Cancel return }更多推荐
发布评论