AutoHotKey:具有多行输入的InputBox(AutoHotKey: InputBox with multiline input)

编程入门 行业动态 更新时间:2024-10-21 23:03:15
AutoHotKey:具有多行输入的InputBox(AutoHotKey: InputBox with multiline input)

在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 }

更多推荐

本文发布于:2023-08-01 02:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1353777.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有多   AutoHotKey   InputBox   input   multiline

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!