AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Intellisense-like autoreplacement with multiple suggestions
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Thu Jan 14, 2010 5:52 am    Post subject: Reply with quote

Hi guys these wordlists may be of interest:

http://www.manythings.org/vocabulary/lists/l/

Found the link from another post talking about an autocomplete script.
Back to top
kakarukeys



Joined: 28 Sep 2009
Posts: 86

PostPosted: Thu Jan 14, 2010 6:57 am    Post subject: Re: more than 10 words Reply with quote

Very Happy The amount of feedback is on exponential increasing trend.
Some update:

@maniac
It can differentiate between c and c-bowl. Exclamation
But further testing showed it broke my 'add phrase to wordlist' shortcut.


rogal wrote:
Hi,

Thanks for the great script. I am trying version 1,2, and I found that if I have many items with the same first three characters, typingaid does not show them at all.

I don't know if this is a known problem. For example, I have about 35 items with "con," and when I type con, typingaid tooltip window does not show up.

Thanks,
Joon


I too don't seem to have this problem with the older TypingAid. I removed some chars from the list of chars excluded from input to support European accents. What could have happened is that you typed some chars before you typed 'con' somewhere else, and the memory of the extra chars before 'con' caused the program not to match with words starting with 'con'. Could you try:

[Space]con to see any words come up in a tooltip?
_________________
TypingAid autocompletion program made with AHK.
Back to top
View user's profile Send private message
maniac



Joined: 28 Aug 2009
Posts: 267

PostPosted: Thu Jan 14, 2010 1:31 pm    Post subject: Re: more than 10 words Reply with quote

kakarukeys wrote:

@maniac
It can differentiate between c and c-bowl. Exclamation


So I'm confused, is it working or not? Smile

Edit:
OK, I tested it and looked at the code. There is an issue... If you use a character with a value over 1000 it won't work right as the unicode value will be more than 3 characters long. C-bowl gets a value of 268. ASC returns the unicode value in this unicode version.

What this means is that each character would need 10 characters in the variable name for the hash, not 3 (and that's only for UTF-8 ). This could be lowered to 8 by using HEX instead of DEC, but we could lower it even more by converting it to a 36 base system (0-Z). That would save a lot on the number of characters required to represent a single unicode character.

Maybe it would be better to switch to a delimited method for hashing rather than a fixed # of characters.
Back to top
View user's profile Send private message
kakarukeys



Joined: 28 Sep 2009
Posts: 86

PostPosted: Thu Jan 14, 2010 3:50 pm    Post subject: Re: more than 10 words Reply with quote

maniac wrote:
kakarukeys wrote:

@maniac
It can differentiate between c and c-bowl. Exclamation


So I'm confused, is it working or not? Smile

Edit:
OK, I tested it and looked at the code. There is an issue... If you use a character with a value over 1000 it won't work right as the unicode value will be more than 3 characters long. C-bowl gets a value of 268. ASC returns the unicode value in this unicode version.

What this means is that each character would need 10 characters in the variable name for the hash, not 3 (and that's only for UTF-8 ). This could be lowered to 8 by using HEX instead of DEC, but we could lower it even more by converting it to a 36 base system (0-Z). That would save a lot on the number of characters required to represent a single unicode character.

Maybe it would be better to switch to a delimited method for hashing rather than a fixed # of characters.


Mad Sounds complex to me. The bottom line is ? That c-bowl is luckily within the range where 3-char hashing works. A change is needed for recognition of more characters, I don't know what other languages might need that, perhaps Asian languages. I believe it can be sorted out in future. Very Happy

Some comments on TypingAid here:

Quote:

A Simple Uncomplicated Program

There’s nothing to configure, so maybe my grandma can also use this to cut short her typing. The program needs no installation and is completely portable from one system to the next.

http://www.makeuseof.com/tag/typingaid-%E2%80%93-a-simple-auto-complete-tool-to-speed-boost-your-typing/

Quote:

Please let me know if you are aware of these issues and solutions
to them. Other than these, the program is absolutely amazing. The fact that I don't have administrative privileges on my computer at work makes the program ideal, as I don't have to install it to use it. Thanks, and I appreciate your free software!


Some users reported a few difficult issues to me that either are time-consuming or need installation of new software/keyboard to test. So as not to complicate things on hand (we have an older TypingAid, a Unicode TypingAid and a learning TypingAid). I'll post them here if I couldn't solve myself.

EDIT: I will try to submit a manuscript to a major programming language conference (PyCon 2010) in local area to see if I can be selected to talk on the conference. I will talk about TypingAid and BlitzType projects (my own), hopefully bring some exposure to AHK tool and how TypingAid could help people with learning difficulties.
_________________
TypingAid autocompletion program made with AHK.
Back to top
View user's profile Send private message
maniac



Joined: 28 Aug 2009
Posts: 267

PostPosted: Thu Jan 14, 2010 7:36 pm    Post subject: Reply with quote

From your website:
Quote:
2. Using the Control-Shift-C shortcut sometimes copies the new phrase
onto the end of the last phrase in the .txt document instead of making it the
next entry.

I have not looked at your code... but maybe you're just inserting a `n instead of `r`n when writing the file? Some text editors may not see just a linefeed as a new character. They would need a Carriage Return/Line Feed (CR/LF).

Actually I see your issue:

Code:
FileAppend, %text%`n, wordlist.txt


Should probably be

Code:
FileAppend, `n%text%, wordlist.txt


See if that fixes it.


That's pretty cool about the conference thing, let us know if anything comes of it.
Back to top
View user's profile Send private message
maniac



Joined: 28 Aug 2009
Posts: 267

PostPosted: Fri Jan 15, 2010 2:13 pm    Post subject: Reply with quote

hugov wrote:
Rather than hasing each word individually character by character why not hash the entire wordlist in one go, here is some code to get you started

and take it from there


Really the only reason I convert to ASCII codes is because some characters cannot be part of a variable name. Looking at your code I would have to search the string for every possible character that could be used in a word.

Also, the performance on that is questionable (I guess it depends on how efficient ConvertWordToAscii is). StringReplace would (I assume) use a linear search to find all matches. There are 52 characters in your list, which means 52 separate linear searches.

Given a 100,000 word list and cropping all words to 3 characters ahead of time, that's 52 calls to ConvertWordToAscii and 52 linear searches over 400,000 (500,000? depends if it reads in CR/LF or if it just preserves the LF) characters each. Considering we want to add Unicode support that number 52 would get huge. And actually, numbers can be part of the words too if read in from the wordlist which would cause an infinite loop >.> (at least without any special modifications).

My current algorithm calls ConvertWordToAscii 300,000 times (for a 100,000 word list), independent of the number of possible values each character can have.

Thanks for the suggestion and I'll continue to think about it....



I did some more testing, and I got the file read time down to less than 10 seconds when reading in the wordlist. I made a few small changes, but what really sped it up is that I disabled the duplicate check when actually reading the wordlist file (it is still enabled when adding new words to the file while typing).

So now it takes under 10 seconds to start the script and under 15 seconds to exit... I consider this fairly acceptable for a 100,000 word list. Faster is always better though Smile.

Code:
;  Intellitype: typing aid
;  Press 1 to 0 keys to autocomplete the word upon suggestion
;  (0 will match suggestion 10)
;                                  - Jordi S
;                               Heavily modified by:
;                               Maniac
;___________________________________________

;    CONFIGURATIONS

#NoEnv
SetBatchLines, 20ms
ListLines Off

OnExit, SaveScript

; Editor Window Recognition
; (make it blank to make the script seek all windows)
ETitle =

;Minimum word length to make a guess
WLen = 3
keyagain=
key=
clearword=1
;Gosub,clearallvars   ; clean vars from start

; Press 1 to 0 keys to autocomplete the word upon suggestion
; (0 will match suggestion 10)
;_______________________________________

CoordMode, ToolTip, Relative
AutoTrim, Off

WordListDone = 0

;reads list of words from file
FileRead, ParseWords, %A_ScriptDir%\Wordlist.txt
Loop, Parse, ParseWords, `n, `r
{
   AddWordToList(A_LoopField)
}
ParseWords =

SetTimer, Winchanged, 100

GoSub, ReverseWordNums
WordlistDone = 1

Loop
{
   ;Editor window check
    WinGetActiveTitle, ATitle
    WinGet, A_id, ID, %ATitle%
    IfNotInString, ATitle, %ETitle%
    {
      ToolTip
      Setenv, Word,
      WinWaitActive, %ETitle%
      Continue
  }
   
   ;Get one key at a time
   Input, chr, L1 V,{enter}{space}.;`,:¿?¡!'"()]{}{}}{bs}{{}{esc}{tab}{Home}{End}{PgUp}{PdDn}{Up}{Dn}{Left}{Right}
   EndKey = %errorlevel%
   ; If active window has different window ID from before the input, blank word
   ; (well, assign the number pressed to the word)   
   WinGetActiveTitle, ATitle
   WinGet, A_id2, ID, %ATitle%
   IfNotEqual, A_id, %A_id2%
   {
      Gosub,clearallvars
      Setenv, Word, %chr%
      Continue
   }
   
   ifequal, OldCaretY,
        OldCaretY = %A_CaretY%
   ifnotequal, OldCaretY, %A_CaretY%
   {
      ; add the word if switching lines
      AddWordToList(Word)
         Gosub,clearallvars
         Setenv, Word, %chr%
         Continue
         
   }

   OldCaretY=%A_CaretY%
   
      ;Backspace clears last letter
   ifequal, EndKey, Endkey:BackSpace
   {
      StringLen, len, Word
      IfNotEqual, len, 0
      {
         ifequal, len, 1   
         {
            Gosub,clearallvars
         } else {
                  StringTrimRight, Word, Word, 1
                }     
      }
   } else ifequal, EndKey, Max
         {
            Setenv, Word, %word%%chr%
         } else {
                  ;addword = %Word%
                  ;Gosub, addwordtolist
                  AddWordToList(Word)
                  Gosub, clearallvars     
                }
   
   ;Wait till minimum letters
   IF ( StrLen(Word) < wlen )
   {
      ToolTip,
      Continue
   }
   
   ;Match part-word with command
   Num =
   Match =
   singlematch = 0
   number = 0
   StringLeft, baseword, Word, %wlen%
   baseword := ConvertWordToAscii(baseword,1)
   Loop
   {
      IfEqual, zword%baseword%%a_index%,, Break
      IfEqual, number, 10
         Break
      if ( SubStr(zword%baseword%%a_index%, 1, StrLen(Word)) = Word )
      {
         number ++
         singlematch := zword%baseword%%a_index%
         match .= Mod(number,10) . ". " . singlematch . "`n"
         singlematch%number% = %singlematch%
           
         Continue           
      }
   }
   
   ;If no match then clear Tip
   IfEqual, Match,
   {
      clearword=0
      Gosub,clearallvars
      Continue
   }
   
   ;Show matched command
   StringTrimRight, match, match, 1        ; Get rid of the last linefeed
   WinGetActiveTitle, ATitle
   WinGetPos, , PosY, , SizeY, %ATitle%
   ToolTipSizeY := (number * 12)
   ToolTipPosY := A_CaretY+14
   if ((ToolTipSizeY + ToolTipPosY) > (PosY + SizeY))
       ToolTipPosY := (A_CaretY - 14 - ToolTipSizeY)
   IfNotEqual, Word,,ToolTip, %match%, %A_CaretX%, %ToolTipPosY%
   ; +14 Move tooltip down a little so as not to hide the caret.
}

; Timed function to detect change of focus (and remove tooltip when changing active window)
Winchanged:
   WinGetActiveTitle, ATitle
   WinGet, A_id3, ID, %ATitle%
   IfNotEqual, A_id, %A_id3%
   {
      ToolTip ,
   } else {
            ; If we are in the correct window, and OldCaretY is set, clear the tooltip if not in the same line
            IfInString, ATitle, %ETitle%
            {
               IfNotEqual, OldCaretY,
               {
                  IfNotEqual, OldCaretY, %A_CaretY%   
                  {
                     ToolTip,
                  }
               }
            }
         }
   Return
   
; Key definitions for autocomplete (0 to 9)
#MaxThreadsPerHotkey 1
$1::
$2::
$3::
$4::
$5::
$6::
$7::
$8::
$9::
$0::
CheckWord(A_ThisHotkey)
Return

; If hotkey was pressed, check wether there's a match going on and send it, otherwise send the number(s) typed
CheckWord(Key)
{
   global
   Local ATitle
   Local A_id2
   Local WordIndex
   
   StringRight, Key, Key, 1 ;Grab just the number pushed, trim off the "$"
   
   IfEqual, Key, 0
   {
      WordIndex = 10
   } else {
            WordIndex = %Key%
         } 
   
   clearword=1

   ; If active window has different window ID from before the input, blank word
   ; (well, assign the number pressed to the word)
   WinGetActiveTitle, ATitle
   WinGet, A_id2, ID, %ATitle%
   IfNotEqual, A_id, %A_id2%
   {
      SendInput,%key%
      Gosub,clearallvars
      Return
   }
     
   IfNotEqual, OldCaretY, %A_CaretY% ;Make sure we are still on the same line
      {
         SendInput,%key%
         Gosub,clearallvars
         Return
      }

   ifequal, Word,        ; only continue if word is not empty
   {
      SendInput,%key%
      Setenv, Word, %key%
      clearword=0
      Gosub,clearallvars
      Return
   }
         
   ifequal, singlematch%WordIndex%,   ; only continue singlematch is not empty
      {
         SendInput,%key%
         Setenv, Word, %word%%key%
         clearword=0
         Gosub,clearallvars
         Return
      }

   Local sending
   Local len
   Local ClipboardSave
   ; SEND THE WORD!
   sending := singlematch%WordIndex%
   StringLen, len, Word
   ; Update Typed Count
   UpdateWordCount(sending)   
   SendPlay, {BS %len%}{Raw}%sending% ; First do the backspaces, Then send word (Raw because we want the string exactly as in wordlist.txt)
   ; below works but uses clipboard
   ;ClipboardSave:=ClipboardAll
   ;Clipboard = %sending%
   ;SendPlay, {BS %len%}^v ; First do the backspaces, Then send word (Raw because we want the string exactly as in wordlist.txt)
   ;Clipboard = %ClipboardSave%
   Gosub,clearallvars
   Return
}

; This is to blank all vars related to matches, tooltip and (optionally) word
clearallvars:
      Ifequal,clearword,1
      {
         Setenv,word,   
         OldCaretY=
      }
      ToolTip
      ; Clear all singlematches
      Loop, 10
      {
         singlematch%a_index% =
      }
      sending =
      key=
      match=
      clearword=1
      Return

AddWordToList(AddWord)
{
   global
   Local CharTerminateList
   Local Base
   Local AddWordInList
   Local CountWord
   Local pos

   Ifequal, Addword,  ;If we have no word to add, skip out.
      Return
   if ( Substr(addword,1,1) = ";" ) ;If first char is ";", clear word and skip out.
   {
      IfEqual, wordlistdone, 0 ;If we are still reading the wordlist file and we come across ;LEARNEDWORDS; set the LearnedWordsCount flag
      {
         IfEqual, AddWord, `;LEARNEDWORDS`;
            LearnedWordsCount=0
      }
      addword =
      Return
   }
   
   ifequal, wordlistdone, 1
   {
         if addword contains 1,2,3,4,5,6,7,8,9,0
            Return
   }
   IF ( StrLen(addword) <= wlen ) ; don't add the word if it's not longer than the minimum length
   {
      addword =
      Return
   }

   Base := ConvertWordToAscii(SubStr(addword,1,wlen),1)
   IfEqual, WordListDone, 0 ;if this is read from the wordlist
   {
      IfNotEqual,LearnedWordsCount,  ;if this is a stored learned word
      {
         CountWord := ConvertWordToAscii(addword,0)
         IfEqual, LearnedWords,     ;if we haven't learned any words yet, set the LearnedWords list to the new word
         {
            LearnedWords = %addword% 
         } else {   ;otherwise append the learned word to the list
                  LearnedWords .= "," . addword
               }
         zCount%CountWord% := LearnedWordsCount++    ;increment the count and store the Weight of the LearnedWord in reverse order (will be inverted later)
      }
      IncrementCounterAndAddWord(Base,AddWord)
     
   } else { ; If this is an on-the-fly learned word
            AddWordInList =
            Loop ;Check to see if the word is already in the list, case sensitive
            {
               IfEqual, zword%base%%a_index%,, Break
               if ( zword%base%%a_index% == AddWord )
               {
                  AddWordInList = 1
                  Break
               }           
               Continue           
            }
           
            IfEqual, AddWordInList, ; if the word is not in the list
            {
               CountWord := ConvertWordToAscii(addWord,0)
               zCount%CountWord% = 1   ;set the count to one as it's the first time we typed it
               IfEqual, LearnedWords,    ;if we haven't learned any words yet, set the LearnedWords list to the new word
               {
                  LearnedWords = %addword% 
               } else {   ;otherwise append the learned word to the list
                        LearnedWords .= "," . addword
                     }
               IncrementCounterAndAddWord(Base,AddWord)
            } else {
                     UpdateWordCount(addword) ;Increment the word count if it's already in the list
                  }
         }
   
   Return
}

IncrementCounterAndAddWord(Base,AddWord)
{
   global
   local pos
   ; Increment the counter for each hash
   zbasenum%Base%++       
   pos := zbasenum%Base%
   ; Set the hashed value to the word
   zword%Base%%pos% = %addword%
}
   
; This sub will reverse the read numbers since now we know the total number of words
ReverseWordNums:
LearnedWordsCount+=4
Loop,parse,LearnedWords, `,
{
   AsciiWord := ConvertWordToAscii(A_LoopField,0)
   zCount%AsciiWord% := LearnedWordsCount - zCount%AsciiWord%
}

AsciiWord =
LearnedWordsCount =

Return

UpdateWordCount(word)
{
; If the Count for the word already exists - ie if it's a learned word, increment it, else don't.
   local CountWord := ConvertWordToAscii(word,0)
   IfNotEqual, zCount%CountWord%,
   {
      zCount%CountWord%++ 
      local WordBase
      StringLeft, WordBase, word, %wlen% ;find the pseudohash for the word
      WordBase := ConvertWordToAscii(WordBase,1)
      Local ConvertWord =
      Local LowIndex =
      Local WordList =
      Loop
      {
         ifequal, zword%WordBase%%A_Index%, ;Break the loop if no more words to read for the hash
            Break
         CountWord := zword%WordBase%%A_Index% ;Set CountWord to the current Word position
         ConvertWord := ConvertWordToAscii(CountWord,0) ; Find the Ascii equivalent of the word
         IfNotEqual, zCount%ConvertWord%,  ;If there's no count for this word do nothing
         {
            IfEqual, LowIndex,
               LowIndex = %A_Index% ;If this is the first word we've found with a count set this as our starting position
               
            WordList .= "," . zCount%ConvertWord% . "z" . CountWord ;prefix all words with (zCount"z")
         }
      }
     
      ifnotequal, Wordlist, ;If we have no words to process, don't
      {
         StringTrimLeft, WordList, WordList, 1
         Sort, WordList, N R D, ;Sort the wordlist by order of
         
         LowIndex-- ;A_Index starts at 1 so this value needs to be decremented
         Local IndexPos =
         Loop, Parse, WordList, `,
         {
            IndexPos := LowIndex + A_Index ;Set the current word we are processing to the starting pos plus word position
            StringTrimLeft, CountWord, A_LoopField, InStr(A_LoopField,"z") ;Strip (Number,"z") from beginning
            zword%WordBase%%IndexPos% = %CountWord% ; update the word in the list
           
         }
      }
   }
   Return
}
     
ConvertWordToAscii(Base,Caps)
{
; Return the word in Ascii numbers padded to length 3 per character
; Capitalize the string if NoCaps is not set
   IfEqual, Caps, 1
      StringUpper, Base, Base
   Loop, Parse, Base
   {
      New .= SubStr("00" . Asc(A_LoopField),-2)
   }
Return New
}
   
SaveScript:
; Add all the standard words to the tempwordlist
FileRead, ParseWords, %A_ScriptDir%\Wordlist.txt
LearnedwordsPos := InStr(ParseWords, "`;LEARNEDWORDS`;",true,1) ;Check for Learned Words
IfNotEqual, LearnedwordsPos, 0
{
   TempWordList := SubStr(ParseWords, 1, LearnedwordsPos - 1) ;Grab all non-learned words out of list
} else {
         TempWordList := ParseWords
      }
ParseWords =
; Parse the learned words and store them in a new list by count if their total count is greater than 5.
; Prefix the word with the count and "z" for sorting
Loop, Parse, LearnedWords, `,
{
   SortWord := ConvertWordToAscii(A_LoopField,0)
   
   IfGreaterOrEqual, zCount%SortWord%, 5
   {
      SortWordList .= "," . zCount%SortWord% . "z" . A_LoopField
   }
}

StringTrimLeft, SortWordList, SortWordList, 1 ;remove extra starting comma

Sort, SortWordList, N R D, ; Sort numerically, comma delimiter

IfNotEqual, SortWordList, ; If SortWordList exists write to the file, otherwise don't.
{
   TempWordList .= "`;LEARNEDWORDS`;`r`n"
   Loop, Parse, SortWordList, `,
   {
      StringTrimLeft, AppendWord, A_LoopField, InStr(A_LoopField,"z") ;Strip (Number,"z") from beginning
      TempWordList .= AppendWord . "`r`n"
   }
   StringTrimRight, TempWordList, TempWordList, 2
   
   FileDelete, %A_ScriptDir%\Temp_Wordlist.txt
   FileAppend, %TempWordList%, %A_ScriptDir%\Temp_Wordlist.txt ;Only update the file if we have learned words
   FileCopy, %A_ScriptDir%\Temp_Wordlist.txt, %A_ScriptDir%\Wordlist.txt, 1
   FileDelete, %A_ScriptDir%\Temp_Wordlist.txt
}

ExitApp


KakaruKeys, at this point I think we need to look into merging my script and TypingAid. We'll need some parameters to disable/enable word learning (for those who want to use long phrases rather than just words) and to control which characters trigger a new word. We might want to consider a preferences file and possibly even a preferences gui (a file is easy but I'm not sure I care to write a GUI atm).

Then the next step will be proper unicode support.
Back to top
View user's profile Send private message
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Fri Jan 15, 2010 2:28 pm    Post subject: Reply with quote

maniac wrote:
My current algorithm calls ConvertWordToAscii 300,000 times (for a 100,000 word list), independent of the number of possible values each character can have.
Perhaps you miss the point of what I'm trying to say. ConvertWordToAscii is not very smart: it parses letter by letter, so rather than 300,000 calls you can reduce that dramatically even if you parse it a few hundred times for all possible characters. 300,000 v few hundred mmmm what would be faster Smile

Granted, wordlist.txt is an easy format to use, but if you were to design your own format the 10 seconds would be reduced to less than a second for even larger lists for loading and saving as well. Arrays would seem useful but you have to find one that doesn't rely on loops.

[lib] SimpleArray - short, fast, string array functions - v3
http://www.autohotkey.com/forum/topic35041.html

would allow you to store/save all variables in one string array making loading and saving a matter of seconds.

I'm tempted to build my own version from the ground up just to satisfy my curiosity, but I won't Wink
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
maniac



Joined: 28 Aug 2009
Posts: 267

PostPosted: Fri Jan 15, 2010 3:51 pm    Post subject: Reply with quote

hugov wrote:
Perhaps you miss the point of what I'm trying to say. ConvertWordToAscii is not very smart: it parses letter by letter, so rather than 300,000 calls you can reduce that dramatically even if you parse it a few hundred times for all possible characters. 300,000 v few hundred mmmm what would be faster Smile

I know what you are trying to say, but linear searches are expensive. I'm not convinced how much faster it would be, even if we could get over the limitation of having to know all characters beforehand.

I removed all calls to ConvertWordToAscii from the script and removed all non-alpha characters from the 100,000 word list and the time went from 5 seconds to 2. Calls to ConvertWordToAscii account for about half the load time.

hugov wrote:
Granted, wordlist.txt is an easy format to use, but if you were to design your own format the 10 seconds would be reduced to less than a second for even larger lists for loading and saving as well.


To give you an idea where I'm looking at this from, I use this for programming. I have only 1600 words in my list and its unlikely to get much larger, so my motivation for making it handle huge lists isn't very big Wink. I find the text word format easy to work with (I actually use another program to manage my wordlist since parts of my wordlist can change if parts of the language I write in change).

Quote:
Arrays would seem useful but you have to find one that doesn't rely on loops.

[lib] SimpleArray - short, fast, string array functions - v3
http://www.autohotkey.com/forum/topic35041.html

would allow you to store/save all variables in one string array making loading and saving a matter of seconds.

I'm tempted to build my own version from the ground up just to satisfy my curiosity, but I won't Wink


If I have time later I'll look more at the array functions people have written, thanks.
Back to top
View user's profile Send private message
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Fri Jan 15, 2010 4:36 pm    Post subject: Reply with quote

Best would be no hashing Smile Anyway good luck ...

Edit: You should post your script in the scripts & functions section so you can update the first post with new updates, it must be a nightmare for people jumping into this thread to find the latest/best version.
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
kakarukeys



Joined: 28 Sep 2009
Posts: 86

PostPosted: Fri Jan 15, 2010 5:15 pm    Post subject: Reply with quote

Smile Here are the changes I incorporated into the very original program

Comparing using WinMerge, TypingAid 1.3 with the 1-press version (first post on page 2, that was the script just before 1.0, it will be nice to version the new script 2.0)

1.
Code:

;  Typing aid


removed "Intellitype" because it's Microsoft's trademark.

2. Credits
Code:

;                                  - Maniac
;                                  - hugov
;                                  - kakarukeys
;                                  - Asaptrad


3. Splash screen. I put it when I distribute TypingAid on my site. Not necessary for a script on AHK forum.

4.
Code:

MouseX = 0
MouseY = 0
Helper_id =
CoordMode, Mouse, Relative

~LButton::
MouseGetPos, MouseX, MouseY
Return

^+h::
Gui, Add, Text,,Tooltip appears here
Gui, Show
WinGet, Helper_id, ID,,Tooltip appears here
WinSet, AlwaysOnTop, On, ahk_id %Helper_id%
return

HCaretX()
{
    global
    WinGetPos, HelperX,,,, ahk_id %Helper_id%
    WinGetPos, X,,,, A
    if HelperX !=
    {
        if X !=
        {
            return HelperX - X
        }
    }
    if A_CaretX < 14
    {
        if MouseX != 0
        {
            return MouseX
        }
    }
    return A_CaretX
}

HCaretY()
{
    global
    WinGetPos,,HelperY,,, ahk_id %Helper_id%
    WinGetPos,, Y,,, A
    if HelperY !=
    {
        if Y !=
        {
            return HelperY - Y
        }
    }
    if A_CaretX < 14
    {
        if MouseY != 0
        {
            return MouseY + 20
        }
    }
    return A_CaretY
}



All %A_CaretY% changed to HCaretY()
All %A_CaretX% changed to HCaretX()

This is to try to get closer to caret in some programs. Not a satisfactory solution, as one reported It does block the text input. I am still pouring through pages of Mozilla documentation to find a way to hack into Firefox. No fruitful results so far

Updated: This will fix the postition problem once and for all. Press Ctrl+Shift+H will open a helper window. Tooltips will appear at its position. Closing the helper window, tooltip will appear at the caret or last-mouse-click position.

5.
Code:

   Input, chr, L1 V,{enter}{space}.`:¿?¡!()]{}{}}{bs}{{}{esc}{tab}{Home}{End}{PgUp}{PdDn}{Up}{Dn}{Left}{Right}


removed ;,'"
'" are crucial for accents
; is commonly in some keyboard layouts to represent a valid character
, is used in chemical names


6.
Code:

match := match . Mod(number,10) . ". " . singlematch . "`n"


10. -> 0.

7.
Code:

ToolTipPosY := A_CaretY+14


14 is rather small, 24 is nicer

8.
Code:

^+c::
text =
ClipBoard =
Sleep, 100
SendInput, ^c
Sleep, 200
text = %Clipboard%

found = 0

Loop, Read, wordlist.txt
{
   If text = %A_LoopReadLine%
   found = 1
}

If found = 0
FileAppend, %text%`n, wordlist.txt

Reload
Sleep 200

Return


add phrase to wordlist (i haven't used your suggestion, I think it's a matter of whether the user left a blank line at the bottom of the wordlist)

9.
Code:

   sending := SubStr(singlematch%key%, len+1)
   StringLen, len, Word   
   SendInput, {Raw}%sending% ; Send word (Raw because we want the substring exactly as in wordlist.txt)



didn't know why not to use this.

Let me know if any of these is broken.
_________________
TypingAid autocompletion program made with AHK.


Last edited by kakarukeys on Sat Jan 16, 2010 6:54 am; edited 4 times in total
Back to top
View user's profile Send private message
kakarukeys



Joined: 28 Sep 2009
Posts: 86

PostPosted: Fri Jan 15, 2010 5:25 pm    Post subject: Reply with quote

Quote:

KakaruKeys, at this point I think we need to look into merging my script and TypingAid. We'll need some parameters to disable/enable word learning (for those who want to use long phrases rather than just words) and to control which characters trigger a new word. We might want to consider a preferences file and possibly even a preferences gui (a file is easy but I'm not sure I care to write a GUI atm).

Then the next step will be proper unicode support.


Nice plan. I prefer a preferences file, afterall, AHK uses a preference file. It's like a tradition. I use a GUI in my python program, it's not a fun thing to code. Perhaps GUI in AHK is easier with all event handling taken care of?
_________________
TypingAid autocompletion program made with AHK.
Back to top
View user's profile Send private message
maniac



Joined: 28 Aug 2009
Posts: 267

PostPosted: Fri Jan 15, 2010 7:22 pm    Post subject: Reply with quote

hugov wrote:
Best would be no hashing Smile Anyway good luck ...

Edit: You should post your script in the scripts & functions section so you can update the first post with new updates, it must be a nightmare for people jumping into this thread to find the latest/best version.


Thanks, no hashing would be ideal, but if you've tried the script from the first post you'll see why it's necessary, at least with the current list implementation Wink .

Yep, after we get everything consolidated we'll set one up, thanks.

kakarukeys wrote:
Quote:

KakaruKeys, at this point I think we need to look into merging my script and TypingAid. We'll need some parameters to disable/enable word learning (for those who want to use long phrases rather than just words) and to control which characters trigger a new word. We might want to consider a preferences file and possibly even a preferences gui (a file is easy but I'm not sure I care to write a GUI atm).

Then the next step will be proper unicode support.


Nice plan. I prefer a preferences file, afterall, AHK uses a preference file. It's like a tradition. I use a GUI in my python program, it's not a fun thing to code. Perhaps GUI in AHK is easier with all event handling taken care of?


Not sure, I've looked at some GUI code and it didn't look all that bad but I didn't really study it.

Sometime next week I'll look into patching your changes in and TypingAid 2.0 (?) will be ready to go? Maybe Smile
Back to top
View user's profile Send private message
stressbaby



Joined: 17 Aug 2009
Posts: 131

PostPosted: Sat Jan 16, 2010 1:06 pm    Post subject: Search entire word for char match? Reply with quote

If I may jump in with a question...

I'm looking for a version of this script to use as a helper for a module in our electronic medical record software. I don't need to check against a huge word list, but only perhaps 400-500 items (which represent the names of lab tests and xrays in our system). However, it would be helpful to our staff if the script searched the entire word/line, rather than just the first 2-3 characters. For example, typing "Abdomen" would filter to "Xray Abdomen" and "CT Abdomen" and "Ultrasound Abdomen."

Is there a version that does this?

Thanks.
Back to top
View user's profile Send private message
kakarukeys



Joined: 28 Sep 2009
Posts: 86

PostPosted: Sat Jan 16, 2010 1:32 pm    Post subject: Re: Search entire word for char match? Reply with quote

stressbaby wrote:
If I may jump in with a question...

I'm looking for a version of this script to use as a helper for a module in our electronic medical record software. I don't need to check against a huge word list, but only perhaps 400-500 items (which represent the names of lab tests and xrays in our system). However, it would be helpful to our staff if the script searched the entire word/line, rather than just the first 2-3 characters. For example, typing "Abdomen" would filter to "Xray Abdomen" and "CT Abdomen" and "Ultrasound Abdomen."

Is there a version that does this?

Thanks.


I'm afraid some tweaking is needed to enable that kind of matching. Are these terms abundant in your word set? Is this phenomenon common in the industry?
_________________
TypingAid autocompletion program made with AHK.
Back to top
View user's profile Send private message
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Sat Jan 16, 2010 1:41 pm    Post subject: Re: Search entire word for char match? Reply with quote

stressbaby wrote:
However, it would be helpful to our staff if the script searched the entire word/line, rather than just the first 2-3 characters. For example, typing "Abdomen" would filter to "Xray Abdomen" and "CT Abdomen" and "Ultrasound Abdomen."
If you want something that works out of the box you may want to have a look at Kollektor by Boskoop http://www.autohotkey.com/forum/viewtopic.php?t=2534 - you can download it in this post http://www.autohotkey.com/forum/viewtopic.php?p=63610#63610 see link to zip file http://file.autohotkey.net/Boskoop/Kollektor.zip - it will search within the entire sentence. The one disadvantage it has compared to typingaid is that you have to press a hotkey before you start searching but to be honest for me that is the alure, it is there when you need it rather than getting in the way (my editor has autocompletion already so I only need it for code snippets, codes I can't remember). I have a version (not for public release in it current state) that would also allow you to find "Xray Abdomen" by typing
xr ab
ray do
x men
etc, any combination of letters in words that are part of a sentence

Let me know if that is of interest and I'll hack up a new Kollektor ++ version to add to Boskoops' thread.
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
Page 6 of 10

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group