加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – AutoHotKey:带多行输入的InputBox

发布时间:2020-12-14 01:59:34 所属栏目:Windows 来源:网络整理
导读:在AutoHotKey中,我希望有类似InputBox的东西,除了文本输入是多行的. (比如textarea). 我希望有两个按钮,“Ok”和“Cancel”,我希望它们都有加速器.我希望这个代码是一个函数的形式,我可以从其他热键调用,以便随时获取多行用户输入.我希望能够设置显示对话框
在AutoHotKey中,我希望有类似InputBox的东西,除了文本输入是多行的. (比如textarea).

我希望有两个按钮,“Ok”和“Cancel”,我希望它们都有加速器.我希望这个代码是一个函数的形式,我可以从其他热键调用,以便随时获取多行用户输入.我希望能够设置显示对话框时显示的默认文本.如果按下取消按钮,我希望函数返回null或空字符串.我希望Esc键使对话框关闭,就像按下取消按钮一样(并且不退出整个脚本).我希望对话框显示在屏幕的中央,并使用Windows通常用于对话框的字体.

解决方法

试试这个

!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,Edit,r10 w600 vMultiLineInputBox,% Default
        Gui,Button,w60 gMultiLineInputBoxOK,&OK
        Gui,w60 x+10 gMultiLineInputBoxCancel,&Cancel
        MultiLineInputBoxGui := true
    }
    GuiControl,MultiLineInputBox:,MultiLineInputBox,% Default
    Gui,MultiLineInputBox: Show,% Caption
    SendMessage,0xB1,-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
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读