autohotkey搜索部分匹配

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了autohotkey搜索部分匹配相关的知识,希望对你有一定的参考价值。

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

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

#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..
答案

尝试

#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

以上是关于autohotkey搜索部分匹配的主要内容,如果未能解决你的问题,请参考以下文章

AutoHotkey批量L版代码转H2的vim脚本(不完整版)

everything + autohotkey的配合使用

notepad++中如何让autohotkey 代码高亮

选择Windows自动化脚本语言。 AutoIt vs Autohotkey [关闭]

带有哈希片段的锚未导航到匹配的 id

正则表达式匹配特定的 URL 片段而不是所有其他 URL 可能性