autohotkey搜索部分匹配

问题描述 投票:2回答:1

有人可以帮助我的代码搜索部分匹配。我似乎被困在这里。

我想只键入组合框中的前几个字母,点击回车,并存储我输入的任何变量。然后我想在我的列表中检查我的变量,找到与我输入的匹配的最接近的名称。这成为新的变量。我该怎么做呢?

#singleInstance, Force

list =
(
Phone Numbers
Important People
Modification
Traffic Data
Tasks
Tracker
)
Gui, +alwaysontop
Gui +Delimiter`n
Gui, Add, ComboBox, vMyVar w200 h110 CHOOSE1 sort, % LIST
Gui, Add, Button, gGO Default x+5 w60 h20 , GO
Gui, show, y200, What do you want now?!
return

; Type first couple letters in box hit enter

GO:
Gui, Submit, nohide
Loop, parse, List, `n
{
; Search LIST for nearest match
;First partial match found
; MyVar := "A_loopfield"
MsgBox % InStr(A_loopfield, DoThis)
}

if MyVar = Phone Numbers
; Msgbox or Function ETC..
list combobox match autohotkey
1个回答
1
投票

尝试

#singleInstance, Force

list =
(
Phone Numbers
Important People
Modification
Traffic Data
Tasks
Tracker
)
Gui, +alwaysontop
Gui +Delimiter`n
Gui, Add, ComboBox, vMyVar w200 h110 CHOOSE1 sort, % LIST
Gui, Add, Button, gGO Default x+5 w60 h20 , GO
Gui, show, y200, What do you want now?!
return

; Type first couple letters in box hit enter

GO:
Gui, Submit, nohide
GuiControlGet, text_typed,, ComboBox1
StringLen, length, text_typed ; retrieves the count of how many characters are  in the text typed
Loop, parse, List, `n
{
    If (SubStr(A_LoopField, 1, length) = text_typed)
    {
        GuiControl, Choose, MyVar, %A_LoopField%
        If (A_LoopField = "Phone Numbers")
            MsgBox, Item 1
        ; ...
        If (A_LoopField = "Traffic Data")
            MsgBox, Item 6
                break   
    }
}
return
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.