Sign in to follow this  
Followers 0
PBM

Is word/phrase autocompletion in other applications feasible?

3 posts in this topic

Hi,

This is my first post to this forum.

I have been searching for a word completion program similar to IntelliComplete <http://www.flashpeak.com/icomp/> and now am considering writing one with AutoIt. IntelliComplete monitors your keystrokes and suggests words and phrases as you type, and learns new vocabulary as you go.

IntelliComplete has not been updated for several years, and does not work well for me with some applications such as MS Access. The developer of IntelliComplete provides a free text editor called IntelliEdit <http://www.flashpeak.com/inted/inted.htm> which is good, but limited (the Delete key does not work, for example). In any case, I'd like something that works in other applications.

Any comments? Has anyone written an autocompletion program? Any insight on to this program's feasibility with AutoIt?

Patrick

Share this post


Link to post
Share on other sites



Hi

There are many shortcomings (can't delete the word, only autocomplete at end of editbox), but here is an example. Run the script, open notepad and start typing.....see what happens

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>


Global $lastinput, $lasttext
$sInitial_Data = "Alpha|Bravo|Charlie|Delta|Echo|Foxtrot|Golf|Hotel|India|Juliet|Kilo|Lima|Mike|November|Oscar|Papa|Quebec|Romeo|Sierra|Tango|Uniform|Victor|Whiskey|X-ray|Zulu"
$array = StringSplit($sInitial_Data, "|")

While 1
Sleep(250)
if WinActive("[class:Notepad]","") and $lastinput <> WinGetText("[CLASS:Notepad]", "") then AutoComplete()
WEnd 

Func AutoComplete()
    $text = ControlGetText("[CLASS:Notepad]", "", "Edit1")
    $cr=StringInStr($text,@lf,0,-1)
    $space=StringInStr($text," ",0,-1)
    if $cr<$space then
        $lastinput =StringRight($text,StringLen($text)-$space)
    Else
        $lastinput =StringRight($text,StringLen($text)-$cr)
            ConsoleWrite($lastinput&@CRLF)
    EndIf
    For $i = 1 To $array[0]; number of items in array
        If StringLeft($array[$i], StringLen($lastinput)) = $lastinput and $lastinput<>"" and $text<>$lasttext Then 
            ControlSend("[CLASS:Notepad]", "", "Edit1", StringRight($array[$i],stringlen($array[$i])-stringlen($lastinput)))
            $lasttext=ControlGetText("[CLASS:Notepad]", "", "Edit1")
        
            ExitLoop
        EndIf
Next

EndFunc

Share this post


Link to post
Share on other sites

Hi,

you came up with another way of monitoring what the user is typing - I had thought of two ways. The first was with HotKeySet, and I assume _IsPressed could be used somehow as well.

I had written a simple script to read digits aloud as they are typed using HotKeySet and thought something similar might be feasible; something like this non-working script:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>

Global $lastinput, $lasttext
$sInitial_Data = "abiding|absolutely|acceptances|acquisitions|adamant|adequately|administratively|adorning|agrees|alkaline" ; This would be in a growing, sorted file.
$array = StringSplit($sInitial_Data, "|")

HotKeySet("a","LowerCaseA")
HotKeySet("A","UpperCaseA")
; . . . set up to monitor all letters
HotKeySet("!{ESC}", "ExitProgram")

While 1
     Sleep(250)
WEnd

Func LowerCaseA()
     HotKeySet("a") ; Disable HotKeySet temporarily
     Send("a")
     AutoComplete("a")
     HotKeySet("a","LowerCaseA") ; Reassign the Hotkey so this macro will work again.
EndFunc

Func UpperCaseA()
     HotKeySet("A")
     Send("A")
     AutoComplete("A")
     HotKeySet("A","UpperCaseA")
EndFunc

Func AutoComplete()
     ;If starting a new word, display a numbered list of words ($sInitial_Data) that start with that letter.
     ;If continuing a word, display only words that start with that sequence.
     ;The user can ignore the list and continue typing, or select an item from the list by number or by
     ;using the arrow keys. 
EndFunc

Func ExitProgram()
     Exit
EndFunc

Are there more ways to monitor keystrokes?

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