Sign in to follow this  
Followers 0
webber

want to create an "autocomplete" pop up

20 posts in this topic

I am new to autoIT and would like to try to build an "autocomplete" popup as a project. I don't necessarily want to start from scratch and am sure others have gone down this road.

Links to any examples, (working or not), would be good to see.

thanks

Share this post


Link to post
Share on other sites



I had already done a search. Folks talk about it, but I never found any actual code examples .

<{POST_SNAPBACK}>

explain more of wat ur trying to accomplish.. is this like a pop up box that just says stuff or like a form u fill out ???

more info!


[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Share this post


Link to post
Share on other sites

explain more of wat ur trying to accomplish.. is this like a pop up box that just says stuff or like a form u fill out ???

more info!

<{POST_SNAPBACK}>

while working in an active window, pressing a hotkey would raise a popup window and display a cobo box. This box would list words pulled from a textfile or other source. The combo box list would jump to words for letters typed in.

Double clicking the word would paste it into the active window, and close the popup window..

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

while working in an active window, pressing a hotkey would raise a popup window and display a cobo box.  This box would list words pulled from a textfile or other source.  The combo box list would jump to words for letters typed in.

Double clicking the word would paste it into the active window, and close the popup window..

<{POST_SNAPBACK}>

GLOBAL $xx
HotKeySet("*insert hotkey here*,"killa()")
Func killa()
GuiCreate("pop up",200,200)
$xx = GuiCtrlCreateCombo("list",15,15,100,50)
EndFunc;==> killa()

*more adavanced autoit scripters insert filereadtoarray here*

GuiCtrlSetData($xx,*filereadarray*)

heh thats kinda not good but its a overview of what you might need..i have no clue how to make it jump to somewhere in the combo box by typing..

Edited by B3TA_SCR1PT3R

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Share this post


Link to post
Share on other sites

thanks, that's a start

Share this post


Link to post
Share on other sites

I am new to autoIT and would like to try  to build an "autocomplete" popup as a project.  I don't necessarily want to start from scratch and am sure others have gone down this road.

Links to any examples, (working or not), would be good to see.

thanks

<{POST_SNAPBACK}>

Do you mean something like this...?

http://www.autoitscript.com/forum/index.ph...opic=10408&st=0


Sapiente vince, rex, noli vincere ferro!

Share this post


Link to post
Share on other sites

here's an auto complete combo box, just make the modifications that you need.

Uses User Defined functions from the beta tho.

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Label,$Input,$Btn_Search,$Btn_ExactSearch,$Combo,$Btn_Exit
Dim $Status,$msg,$ret, $old_string=""

GuiCreate("ComboBox Find String", 392, 254)

$Label = GuiCtrlCreateLabel("Enter Search String", 20, 20, 120, 20)
$Input = GuiCtrlCreateInput("", 160, 20, 180, 20)
$Btn_Search = GuiCtrlCreateButton("Search", 160, 50, 90, 30)
$Btn_ExactSearch = GuiCtrlCreateButton("Exact Search", 255, 50, 90, 30)
$Combo = GuiCtrlCreateCombo("", 70, 100, 270, 21)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GuiSetState()
While 1
   $msg = GuiGetMsg()
    If $old_string <> GUICtrlRead($Combo) Then
        _AutoComplete($Combo)
        $old_string = GUICtrlRead($Combo)
    EndIf
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $Btn_Search
            If(StringLen(GUICtrlRead($Input)) > 0) Then
                $ret = _GUICtrlComboFindString($Combo,GUICtrlRead($Input))
                If($ret <> $CB_ERR) Then
                    GUICtrlSetData($Status,'Found "' & GUICtrlRead($Input) & '" at index: ' & $ret)
                Else
                    GUICtrlSetData($Status,'"' & GUICtrlRead($Input) & '" Not Found')
                EndIf
            EndIf
        Case $msg = $Btn_ExactSearch
            If(StringLen(GUICtrlRead($Input)) > 0) Then
                $ret = _GUICtrlComboFindString($Combo,GUICtrlRead($Input),1)
                If($ret <> $CB_ERR) Then
                    GUICtrlSetData($Status,'Found "' & GUICtrlRead($Input) & '" at index: ' & $ret)
                Else
                    GUICtrlSetData($Status,'"' & GUICtrlRead($Input) & '" Not Found')
                EndIf
            EndIf
    EndSelect
WEnd
Exit

Func _AutoComplete($Combo)
    Local $ret, $s_text, $s_data
    $s_data = GUICtrlRead($Combo)
    $ret = _GUICtrlComboFindString($Combo,GUICtrlRead($Combo))
    If($ret <> $CB_ERR) Then
        _GUICtrlComboGetLBText($Combo,$ret,$s_text)
        GUICtrlSetData($Combo,$s_text)
        _GUICtrlComboSetEditSel($Combo, StringLen($s_data), StringLen(GUICtrlRead($Combo)))
    EndIf
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

here's an auto complete combo box, just make the modifications that you need.

Uses User Defined functions from the beta tho.

#include <GuiConstants.au3>#include <GuiCombo.au3>Opt('MustDeclareVars',1)..........thanks , I'll study this. I'm new at autoIT, not using beta, and the sample throws some warnings, but I'll try to figure it out.


            
                


    Edited  by webber
    
    

            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
SmOke_N   

    
        
    
             198
    
        
    

        
            
                It's not what you know ... It's what you can prove!
            
            

            
                

    
        
    

            
            Moderators
            
                
            
            
                

    
        
    
             198
    
        
    

                16,152 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #13 · 
            Posted 
            
            
            
        
    

    


            
        
            Hey I must of screwed up the link I posted, that was not intended to be a burn, but now I don't even remember what I found.Anyway, gafrost has posted a nice option... and you'll find the beta is what most use to make their options work.  It's easily installable as was the 3.1.1 you installed.Here is the link (yes it's a real one.. sorry again does seem like I was trying to flame unintentionally)  http://www.autoitscript.com/forum/index.ph...opic=10256&st=0


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
            




  
  
    
    Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

  


        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
therks   

    
        
    
             3
    
        
    

        
            
                Witty quote
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             3
    
        
    

                2,130 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #14 · 
            Posted 
            
            
            
        
    

    


            
        
            Wow, that's really cool Gary. Only problem I can see is how the backspace works. For example, I put AutoIt and Autobot into the select, and as I typed A, u, t, o, I, etc, it was selecting AutoIt. Then I wanted to back up (to type Autobot), but when I hit backspace, nothing happens.
Not really examining the code (but having an idea on how it works), I really don't know what you could do to get around this.


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
            




  
  
    
    My AutoIt Stuff

  


        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
phillip123adams   

    
        
    
             0
    
        
    

        
            
                Universalist
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             0
    
        
    

                315 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #15 · 
            Posted 
            
            
            
        
    

    


            
        
            Wow, that's really cool Gary. Only problem I can see is how the backspace works. ...I really don't know what you could do to get around this.<{POST_SNAPBACK}>Don't give up!  Try this version.  It allows any number of backspces.  I commented the section that I replaced, and outdented the new section.#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt ('MustDeclareVars', 1)

Dim $Label, $Input, $Btn_Search, $Btn_ExactSearch, $Combo, $Btn_Exit
Dim $Status, $msg, $ret, $old_string = ""
Dim $New_String

GUICreate("ComboBox Find String", 392, 254)

$Label = GUICtrlCreateLabel("Enter Search String", 20, 20, 120, 20)
$Input = GUICtrlCreateInput("", 160, 20, 180, 20)
$Btn_Search = GUICtrlCreateButton("Search", 160, 50, 90, 30)
$Btn_ExactSearch = GUICtrlCreateButton("Exact Search", 255, 50, 90, 30)
$Combo = GUICtrlCreateCombo("", 70, 100, 270, 21)
GUICtrlSetData($Combo, "AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()

While 1
   $msg = GUIGetMsg()
;~  If $old_string <> GUICtrlRead($Combo) Then
;~     _AutoComplete($Combo)
;~     $old_string = GUICtrlRead($Combo)
;~  EndIf
;; Allow characters to be deleted without auto completing the result.
$New_String = GUICtrlRead($Combo)
If $old_string <> $New_String and StringLen($New_String) >= StringLen($old_string) Then
   _AutoComplete($Combo)
EndIf
$old_string = $New_String

   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
         ExitLoop
      Case $msg = $Btn_Search
         If (StringLen(GUICtrlRead($Input)) > 0) Then
            $ret = _GUICtrlComboFindString ($Combo, GUICtrlRead($Input))
            If ($ret <> $CB_ERR) Then
               GUICtrlSetData($Status, 'Found "' & GUICtrlRead($Input) & '" at index: ' & $ret)
            Else
               GUICtrlSetData($Status, '"' & GUICtrlRead($Input) & '" Not Found')
            EndIf
         EndIf
      Case $msg = $Btn_ExactSearch
         If (StringLen(GUICtrlRead($Input)) > 0) Then
            $ret = _GUICtrlComboFindString ($Combo, GUICtrlRead($Input), 1)
            If ($ret <> $CB_ERR) Then
               GUICtrlSetData($Status, 'Found "' & GUICtrlRead($Input) & '" at index: ' & $ret)
            Else
               GUICtrlSetData($Status, '"' & GUICtrlRead($Input) & '" Not Found')
            EndIf
         EndIf
   EndSelect
WEnd
Exit

Func _AutoComplete($Combo)
   Local $ret, $s_text, $s_data
   $s_data = GUICtrlRead($Combo)
   $ret = _GUICtrlComboFindString ($Combo, GUICtrlRead($Combo))
   If ($ret <> $CB_ERR) Then
      _GUICtrlComboGetLBText ($Combo, $ret, $s_text)
      GUICtrlSetData($Combo, $s_text)
      _GUICtrlComboSetEditSel ($Combo, StringLen($s_data), StringLen(GUICtrlRead($Combo)))
   EndIf
EndFunc  ;==>_AutoComplete

Phillip

Share this post


Link to post
Share on other sites

That'll work, just threw mine together real quick one-time for someone and never refined it. Updated my Snippet Bank.

Thanks,

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

That'll work, just threw mine together real quick one-time for someone and never refined it.  Updated my Snippet Bank.

Thanks,

Gary

<{POST_SNAPBACK}>

You're welcome gafrost. And, I knew you could work that little problem out if you gave it even a moments glance! I always enjoy, and study, your work.

Phillip

Share this post


Link to post
Share on other sites

Actually Phil, yours has an even worse reaction :\

As soon as I type an A, it types out AutoIt. I can backspace, sure, but if I had a difference between AutoIt and Anomaly and Animal, that's a lot of backspacing

(Type A), fills "AutoIt", (Backspace 5 times), (type N), fills "Anomaly", (Backspace 5 more times), (type I), fills "Animal", *done*

See what I mean?

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt ('MustDeclareVars', 1)

Dim $Label, $Input, $Btn_Search, $Btn_ExactSearch, $Combo, $Btn_Exit
Dim $Status, $msg, $ret, $old_string = ""

GUICreate("ComboBox Find String", 392, 254)

$Label = GUICtrlCreateLabel("Enter Search String", 20, 20, 120, 20)
$Input = GUICtrlCreateInput("", 160, 20, 180, 20)
$Btn_Search = GUICtrlCreateButton("Search", 160, 50, 90, 30)
$Btn_ExactSearch = GUICtrlCreateButton("Exact Search", 255, 50, 90, 30)
$Combo = GUICtrlCreateCombo("", 70, 100, 270, 21)
GUICtrlSetData($Combo, "AutoIt|v3|is|freeware|BASIC-like|scripting|language|Autobot|Animal")
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $Btn_Search
            If (StringLen(GUICtrlRead($Input)) > 0) Then
                $ret = _GUICtrlComboFindString ($Combo, GUICtrlRead($Input))
                If ($ret <> $CB_ERR) Then
                    GUICtrlSetData($Status, 'Found "' & GUICtrlRead($Input) & '" at index: ' & $ret)
                Else
                    GUICtrlSetData($Status, '"' & GUICtrlRead($Input) & '" Not Found')
                EndIf
            EndIf
        Case $msg = $Btn_ExactSearch
            If (StringLen(GUICtrlRead($Input)) > 0) Then
                $ret = _GUICtrlComboFindString ($Combo, GUICtrlRead($Input), 1)
                If ($ret <> $CB_ERR) Then
                    GUICtrlSetData($Status, 'Found "' & GUICtrlRead($Input) & '" at index: ' & $ret)
                Else
                    GUICtrlSetData($Status, '"' & GUICtrlRead($Input) & '" Not Found')
                EndIf
            EndIf
        Case Else
            _AutoComplete($Combo, $old_string)
    EndSelect
WEnd
Exit

Func _AutoComplete($Combo, ByRef $old_string)
    If _IsPressed('08') Then;backspace pressed
        $old_string = GUICtrlRead($Combo)
    Else
        If $old_string <> GUICtrlRead($Combo) Then
            Local $ret, $s_text, $s_data
            $s_data = GUICtrlRead($Combo)
            $ret = _GUICtrlComboFindString ($Combo, GUICtrlRead($Combo))
            If ($ret <> $CB_ERR) Then
                _GUICtrlComboGetLBText ($Combo, $ret, $s_text)
                GUICtrlSetData($Combo, $s_text)
                _GUICtrlComboSetEditSel ($Combo, StringLen($s_data), StringLen(GUICtrlRead($Combo)))
            EndIf
            $old_string = GUICtrlRead($Combo)
        EndIf
    EndIf
EndFunc  ;==>_AutoComplete

Func _IsPressed($hexKey)
; $hexKey must be the value of one of the keys.
; _IsPressed will return 0 if the key is not pressed, 1 if it is.
    
    Local $aR
    $hexKey = '0x' & $hexKey
    $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
    If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc  ;==>_IsPressed

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Awesome! That works perfectly Gary. I'm going to have to add this to my RunAs program.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0