_GUICtrlComboBox_AutoComplete auch für Inputs?

  • Hiho ich hätte gerne die Funktion _GUICtrlComboBox_AutoComplete für ein Input... gibts schon sowas?
    Desweiteren versteh ich dieses script auch garnet^^:

    Spoiler anzeigen
    [autoit]

    #include <GUIComboBox.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt('MustDeclareVars', 1)

    [/autoit] [autoit][/autoit] [autoit]

    $Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work

    [/autoit] [autoit][/autoit] [autoit]

    Global $hCombo

    [/autoit] [autoit][/autoit] [autoit]

    Example_Internal()
    Example_External()

    [/autoit] [autoit][/autoit] [autoit]

    Func Example_Internal()
    Local $hGUI

    [/autoit] [autoit][/autoit] [autoit]

    ; Create GUI
    $hGUI = GUICreate("(Internal) ComboBox Auto Complete", 400, 296)
    $hCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    ; Add files
    _GUICtrlComboBox_BeginUpdate ($hCombo)
    _GUICtrlComboBox_AddDir ($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate ($hCombo)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    [/autoit] [autoit][/autoit] [autoit]

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
    EndFunc ;==>Example_Internal

    [/autoit] [autoit][/autoit] [autoit]

    Func Example_External()
    Local $hGUI

    [/autoit] [autoit][/autoit] [autoit]

    ; Create GUI
    $hGUI = GUICreate("(External) ComboBox Auto Complete", 400, 296)
    $hCombo = _GUICtrlComboBox_Create ($hGUI, "", 2, 2, 396, 296)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    ; Add files
    _GUICtrlComboBox_BeginUpdate ($hCombo)
    _GUICtrlComboBox_AddDir ($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate ($hCombo)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    [/autoit] [autoit][/autoit] [autoit]

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
    EndFunc ;==>Example_External

    [/autoit] [autoit][/autoit] [autoit]

    Func _Edit_Changed()
    _GUICtrlComboBox_AutoComplete ($hCombo)
    EndFunc ;==>_Edit_Changed

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo
    If Not IsHWnd($hCombo) Then $hWndCombo = GUICtrlGetHandle($hCombo)
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word
    Switch $hWndFrom
    Case $hCombo, $hWndCombo
    Switch $iCode
    Case $CBN_CLOSEUP ; Sent when the list box of a combo box has been closed
    _DebugPrint("$CBN_CLOSEUP" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; no return value
    Case $CBN_DBLCLK ; Sent when the user double-clicks a string in the list box of a combo box
    _DebugPrint("$CBN_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; no return value
    Case $CBN_DROPDOWN ; Sent when the list box of a combo box is about to be made visible
    _DebugPrint("$CBN_DROPDOWN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; no return value
    Case $CBN_EDITCHANGE ; Sent after the user has taken an action that may have altered the text in the edit control portion of a combo box
    _DebugPrint("$CBN_EDITCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    _Edit_Changed()
    ; no return value
    Case $CBN_EDITUPDATE ; Sent when the edit control portion of a combo box is about to display altered text
    _DebugPrint("$CBN_EDITUPDATE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; no return value
    Case $CBN_ERRSPACE ; Sent when a combo box cannot allocate enough memory to meet a specific request
    _DebugPrint("$CBN_ERRSPACE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; no return value
    Case $CBN_KILLFOCUS ; Sent when a combo box loses the keyboard focus
    _DebugPrint("$CBN_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; no return value
    Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box
    _DebugPrint("$CBN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; no return value
    Case $CBN_SELENDCANCEL ; Sent when the user selects an item, but then selects another control or closes the dialog box
    _DebugPrint("$CBN_SELENDCANCEL" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; no return value
    Case $CBN_SELENDOK ; Sent when the user selects a list item, or selects an item and then closes the list
    _DebugPrint("$CBN_SELENDOK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; no return value
    Case $CBN_SETFOCUS ; Sent when a combo box receives the keyboard focus
    _DebugPrint("$CBN_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; no return value
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

    [/autoit] [autoit][/autoit] [autoit]

    Func _DebugPrint($s_text, $line = @ScriptLineNumber)
    ConsoleWrite( _
    "!===========================================================" & @LF & _
    "+======================================================" & @LF & _
    "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
    "+======================================================" & @LF)
    EndFunc ;==>_DebugPrint

    [/autoit]


    Bzw. 1. was der unterschied zwischen internal und external sein soll und was die Function WM_COMMAND bewirkt ausser das sie irgendwelche daten in die console schreibt^^

    Also das mit dem Input hab ich mir so vorgestellt wie das eig. auch mit der Combobox ist d.h. wenn man in die combobox explorer.exe schreiben will markiert er das was er vorschlägt auch gleich *geile sache*, nur ich bräuchte das ganze halt in einem Input und die Daten soll er aus einer Datei lesen

    Es geht hierbei um eine Datenbank aus den verschiedensten Namen
    Nachname Vorname1.Buchstabe
    Jede Zeile beispielsweise ein Name und wenn man dann in das Input zu schreiben beginnt sollte er auch vorschläge machen die markiert sind^^

    Omg hoffe ihr habt einigermaßen verstanden was ich will

    THX für euren Mühen schonmal :)

    //EDIT:
    Mir ist zwar eig. der Ansatz klar,
    1. muss die Datei nach dem entsprechenden, bereits eingegebenem String durchsucht werden
    2. muss der erstbeste gefundene String genommen und die Länge des strings - (minus) die länge des eingegebenen strings quasi rückwärts markiert werden
    nur wie coden??? gerade dann das mit dem markieren^^

    MFG FireFlyer

    *Paradox ist, wenn man sich im Handumdrehen den Fuss bricht* :D

    Einmal editiert, zuletzt von FireFlyer (1. März 2008 um 00:57)

  • Der Unterschied zwischen Internal und External ist:
    . - dass beim Internal die Combo mit GUICtrlCreateCombo erstellt wird und die Funcktionen dann mit der CTRLID funktionieren
    . - bei External wird mit _GUICtrlComboBox_Create die Combo erstellt, und dann mit dem davon zurückgegebenen Handle gearbeitet.

    Bei WM_COMMAND ist im Switch der Case $CBN_EDITCHANGE wichtig, da dort der update aufgerufen wird.

    Für die Umsetzung:
    Die möglichen Einträge in ein Array laden, das durchsuchen mit einer modifizierten _ArraySearch. Wenn gefunden, dann ins Edit eintragen.
    In der WM_COMMAND bruachst du den Case $EN_CHANGE
    Markieren: _GUICtrlEdit_SetSel($hWnd, StringLen($sEditText), StringLen($EntryArray[$ret]))

    //Edit: Nimm als vorlage doch die _GUICtrlComboBox_AutoComplete

  • also soweit hab ichs schonmal :D

    nur er nimmt das ja nicht zeichen für zeichen da der partial search auf True ist ...

    Spoiler anzeigen
    [autoit]

    Func autoausfuellen()
    Select
    Case WinActive($opts_namepgr[2]&" - Seite 1")
    $window = $opts_namepgr[2]&" - Seite 1"
    $state = ControlGetFocus($seite1)
    Case WinActive($opts_namepgr[2]&" - Seite 2")
    $window = $opts_namepgr[2]&" - Seite 2"
    $state = ControlGetFocus($seite2)
    Case WinActive($opts_namepgr[2]&" - Seite 3")
    $window = $opts_namepgr[2]&" - Seite 3"
    $state = ControlGetFocus($seite3)
    Case WinActive($opts_namepgr[2]&" - Seite 4")
    $window = $opts_namepgr[2]&" - Seite 4"
    $state = ControlGetFocus($seite4)
    Case Else
    $state = 0
    EndSelect
    If WinActive($opts_namepgr[2]&" - Seite 1") Or WinActive($opts_namepgr[2]&" - Seite 2") Or WinActive($opts_namepgr[2]&" - Seite 3") Or WinActive($opts_namepgr[2]&" - Seite 4") Then
    For $b = 1 To 80
    If _IsFocused($window, $array_inputs[$b][2]) Then
    $read_input2 = GUICtrlRead($array_inputs[$b][2])
    $pos = _ArraySearch($read_names, $read_input2, 0, 0, 0, True)
    If $pos <> -1 Then
    $1 = StringLen($read_input2)
    GUICtrlSetData($array_inputs[$b][2], $read_names[$pos])
    _GUICtrlEdit_SetSel($array_inputs[$b][2], $1, -1)
    EndIf
    EndIf
    Next
    EndIf
    EndFunc

    [/autoit]

    MFG FireFlyer

    *Paradox ist, wenn man sich im Handumdrehen den Fuss bricht* :D

  • Array Search anpassen... z.B.:

    Spoiler anzeigen
    [autoit]

    Func _ArraySearch_PartFromStart(Const ByRef $avArray, $vWhat2Find, $iStart = 0, $iEnd = 0, $iCaseSense = 0)
    Local $iCurrentPos, $iUBound, $iResult
    If Not IsArray($avArray) Then
    SetError(1)
    Return -1
    EndIf
    $iUBound = UBound($avArray) - 1
    If $iEnd = 0 Then $iEnd = $iUBound
    If $iStart > $iUBound Then
    SetError(2)
    Return -1
    EndIf
    If $iEnd > $iUBound Then
    SetError(3)
    Return -1
    EndIf
    If $iStart > $iEnd Then
    SetError(4)
    Return -1
    EndIf
    If Not ($iCaseSense = 0 Or $iCaseSense = 1) Then
    SetError(5)
    Return -1
    EndIf
    Local $vFindLen = StringLen($vWhat2Find)
    If $iCaseSense = 0 Then Local $vFindLower = StringLower($vWhat2Find)
    For $iCurrentPos = $iStart To $iEnd
    Select
    Case $iCaseSense = 0
    If $vFindLower = StringLower(StringLeft($avArray[$iCurrentPos],$vFindLen)) Then
    SetError(0)
    Return $iCurrentPos
    EndIf
    Case $iCaseSense = 1
    If $vWhat2Find = StringLeft($avArray[$iCurrentPos],$vFindLen) Then
    SetError(0)
    Return $iCurrentPos
    EndIf
    EndSelect
    Next
    SetError(6)
    Return -1
    EndFunc ;==>_ArraySearch

    [/autoit]
  • hehe danke propagandy, warum gibts das nicht längst schon als udf? :P

    So jetzt zum weiteren Problem bei dem ich wirklich ein Problem mit dem Programmieren selbst und nicht mit dem Coden habe, und zwar da das ganze ja in einer schleife läuft schreibt er das ganze ja immer wieder rein? Wie kann man das so stoppen das er nur reinschreibt sobald der user etwas ändert??? Ich hatte die idee mit _IsPressed aber ist das wirklich sinnvoll?
    Hier nochmal für die scroll-faulen der code :D

    Spoiler anzeigen
    [autoit]

    For $b = 1 To 80
    If _IsFocused($window, $array_inputs[$b][2]) Then
    $read_input2 = GUICtrlRead($array_inputs[$b][2])
    $pos = _ArraySearch_PartFromStart($read_names, $read_input2, 0, 0, 0) ;GEIL :D
    If $pos <> -1 And $read_names[$pos] <> 3 Then
    GUICtrlSetData($array_inputs[$b][2], $read_names[$pos])
    _GUICtrlEdit_SetSel($array_inputs[$b][2], StringLen($read_input2), -1)
    ExitLoop
    EndIf
    EndIf
    Next
    EndIf

    [/autoit]


    achso ja--> @progandy wenn das Input leer ist schreibt er ne 3 rein ka warum aber ich habs unterbunden^^ (If $read_names[$pos] <> 3 Then)

    MFG FireFlyer

    *Paradox ist, wenn man sich im Handumdrehen den Fuss bricht* :D

  • Mach so was:
    Du musst nur $hCombo mit deiner Input-Variable tauschen

    Spoiler anzeigen
    [autoit]

    $EntryArray = _FileListToArray(@WindowsDir , "*.exe")

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    [/autoit] [autoit][/autoit] [autoit]

    Func _GUICtrlInput_AutoComplete ($hCombo, ByRef $EntryArray)
    Local $ret, $sInputText, $sEditText
    ;If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

    If Not _IsPressed('08') And Not _IsPressed("2E") Then ;backspace pressed or Del
    $sEditText = GUICtrlRead($hWnd)
    If StringLen($sEditText) Then
    $ret = _ArraySearch_PartFromStart($EntryArray, $sEditText,1)
    If ($ret <> -1) Then
    GUICtrlSetData($hWnd, $EntryArray[$ret])
    _GUICtrlEdit_SetSel($hWnd, StringLen($sEditText), StringLen($EntryArray[$ret]))
    EndIf
    EndIf
    EndIf
    EndFunc ;==>_GUICtrlInput_AutoComplete

    [/autoit] [autoit][/autoit] [autoit]

    Func _Edit_Changed()
    _GUICtrlInput_AutoComplete ($hCombo,$EntryArray)
    EndFunc ;==>_Edit_Changed

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo = $hCombo
    If Not IsHWnd($hCombo) Then $hwndCombo = GUICtrlGetHandle($hCombo)
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word
    Switch $hWndFrom
    Case $hWndCombo
    Switch $iCode
    Case $EN_CHANGE
    _Edit_Changed()
    ; no return value
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

    [/autoit]


    Und beim $pos = _ArraySearch_PartFromStart($read_names, $read_input2, 0, 0, 0) ;GEIL :D
    muss die erste 0 auf 1, damit der erste Eintrag (die Anzahl der Elemente im Array) übersprungen wir:

    [autoit]

    $pos = _ArraySearch_PartFromStart($read_names, $read_input2, 1)

    [/autoit]

    ;GEIL :D

    Einmal editiert, zuletzt von progandy (3. März 2008 um 16:25)