2017-12-21 17 views
2

Kann jemand mit meinem Code bei der Suche nach einer Teilübereinstimmung helfen. Ich halte mich hier fest.autohotkey Suche nach einer Teilübereinstimmung

Ich möchte nur die ersten paar Buchstaben in eine Combo-Box eingeben, Enter drücken und alles, was ich als Variable eingegeben habe, speichern. Dann möchte ich meine Variable gegen meine Liste nach dem nächsten Namen überprüfen, der dem entspricht, was ich eingegeben habe. Das wird die neue Variable. Wie mache ich das?

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

Antwort

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 
+1

Hey, das ist ausgezeichnet Versuchen. Ich mag auch die GuiControl. Ich habe nicht einmal daran gedacht, das zu benutzen. Schöne Berührung. –

+1

Können Sie mich upvote? Ich brauche nur noch einen Ruf, damit ich andere verbessern kann. –