[AHK] 调用函数动态生成ListBox窗口

需求背景

动态生成向导对话框,由用户选一个选项,类似做选择题。

运行效果

AHK v1 代码

if(A_ScriptFullPath=A_LineFile)
	MsgBox % ListBox("窗口标题", "这是一个生成listbox的Demo", "a|b|c|d|",3) 
return
;-------------------------------------------------------------------------------
ListBox(Title := "", Prompt := "", List := "", Select := 0) {
;-------------------------------------------------------------------------------
    ; show a custom input box with a ListBox control
    ; return the text of the selected item
    ;
    ; Title is the title for the GUI
    ; Prompt is the text to display
    ; List is a pipe delimited list of choices
    ; Select (if present) is the index of the preselected item
    ;---------------------------------------------------------------------------

    static Result ; used as a GUI control variable

    ; create GUI
    Gui, ListBox: New, +LastFound, %Title%
    Gui, -MinimizeBox
    Gui, Margin, 30, 18
    Gui, Add, Text,, %Prompt%
    Gui, Add, ListBox, w190 r10 vResult Choose%Select%, %List%
    Gui, Add, Button, w80 Default, &OK
    Gui, Add, Button, x+m wp, &Cancel

    ; main loop
    Gui, Show
    WinWaitClose
    Return, Result


    ;-----------------------------------
    ; event handlers
    ;-----------------------------------
    ListBoxButtonOK: ; "OK" button, {Enter} pressed
        Gui, Submit ; get Result from GUI
        Gui, Destroy
    Return

    ListBoxButtonCancel: ; "Cancel" button
    ListBoxGuiClose:     ; {Alt+F4} pressed, [X] clicked
    ListBoxGuiEscape:    ; {Esc} pressed
        Result := "ListBoxCancel"
        Gui, Destroy
    Return
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值