Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Re-purposing Intellisense


  • Please log in to reply
4 replies to this topic
MagnumPII
  • Guests
  • Last active:
  • Joined: --
I am trying to repurpose Rajat's original Intellisense for AHK commands as it is the best auto-replace tool I have found yet for typing. It works great if the first word that you type is in the dictionary file, but as soon as you type a word not in the file it stops working until you reload the script.

Any ideas about what I need to modify? Here is the script:

SetKeyDelay, 0 
SetBatchLines, 5ms 
CoordMode, ToolTip, Relative 
AutoTrim, Off 

;_______________________________________ 

;    CONFIGURATIONS 

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

ETitle = 

;Minimum word length to make a guess 

WLen = 3 


; Press F4 to complete command ind
; Escape & Enter clear command 

; Gets path to AutoHotkey 
; RegRead, AHKPATH, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Run\Command, 
; StringGetPos, POS, AHKPATH, \AutoHotkey.exe 
; StringLeft, AHKPATH, AHKPATH, %POS%
; StringReplace, AHKPATH, AHKPATH, ",, A 

;reads command syntaxes 
Loop, Read, C:\Wordlist.txt
{ 
   tosend = %a_loopreadline% 

   StringReplace, tosend, tosend, }, +], a 
   StringReplace, tosend, tosend, {, +[, a 
   StringReplace, tosend, tosend, #, {#}, a 
   StringReplace, tosend, tosend, ``n, {enter}, a 
   StringReplace, tosend, tosend, ``t, {tab}, a 
   StringReplace, tosend, tosend, ``b, {bs}, a 

   cmd%a_index% = %toSend% 
} 

Loop 
{ 
   ;Editor window check 
   WinGetActiveTitle, ATitle 
   IfNotInString, ATitle, %ETitle% 
   { 
      ToolTip 
      Setenv, Word, 
      sleep, 500 
      Continue 
   }
    
   ;Get one key at a time 
   Input, chr, L1 V, {enter}{Space}{F4}{bs}{esc} 
   EndKey = %errorlevel% 
    
   ;Blanks word reserve 
;   ifequal, EndKey, Endkey:Enter, Setenv, Word, 
;   ifequal, EndKey, Endkey:Escape, Setenv, Word, 
;   ifequal, EndKey, Endkey:Space, Setenv, Word, 
    
   ;Backspace clears last letter 
   ifequal, EndKey, Endkey:BackSpace, StringTrimRight, Word, Word, 1 
   ifnotequal, EndKey, Endkey:BackSpace, Setenv, Word, %word%%chr% 
    
   ;Wait till minimum letters
   StringLen, len, Word 
   IfLess, len, %wlen% 
   { 
      ToolTip 
      Continue 
   } 

   ;Match part-word with command
   Num = 
   Match = 
   Loop 
   { 
      IfEqual, cmd%a_index%,, Break 
      StringLen, len, word 
      StringLeft, check, cmd%a_index%, %len% 
      IfEqual, word, %check% 
      { 
         num = %a_index% 
         break 
      } 
   } 
    
   ;If no match then clear Tip 
   IfEqual, Num, 
   { 
      ToolTip 
      Continue 
   } 
    
   ;Show matched command 
   StringTrimLeft, match, cmd%num%, 0 
   display_y = %A_CaretY% 
   display_y -= 20 ; Move tooltip up a little so as not to hide the caret. 
   IfNotEqual, Word,,ToolTip, %match%, %A_CaretX%, %display_y% 
   
   ;Complete command 
   IfNotEqual, Word,, IfEqual, EndKey, Endkey:Space
   { 
      StringLen, len, Word 
      Send, {BackSpace}
      Send, {BS %len%}%match% 
      Send, {Space}
      Word = 
      ToolTip 
   } 
   ;Blanks word reserve 
;   ifequal, EndKey, Endkey:Enter, Setenv, Word, 
;   ifequal, EndKey, Endkey:Escape, Setenv, Word, 
;   ifequal, EndKey, Endkey:Space, Setenv, Word, 

}


Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
try un-commenting last 3 lines

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


MagnumPII
  • Guests
  • Last active:
  • Joined: --

try un-commenting last 3 lines


Rajat - thanks for your response - this is a great script by the way, and I've been trying to get it to work for more simple text entry purposes for a couple of weeks now.

I tried uncommenting those lines, but still have the same problem. When beginning to type for example, "individual", I will get the tooltip match after typing "ind" and can hit space to complete. However, if I type "For an individual", I will not get the autocomplete tooltip, and the only way to get it back short of reloading the script, is to backspace over the entire "For an individual" and then it will work again. It's like the script is tracking the characters I type that are not in the wordlist file, and backspacing that many times again is the only way it again searches the file. Is there a way to have it again start searching for matches after pressing the Spacebar?

- thanks for your help

timtyler
  • Members
  • 17 posts
  • Last active: Jan 25 2007 02:49 PM
  • Joined: 01 Jan 2007

try un-commenting last 3 lines


Rajat - thanks for your response - this is a great script by the way, and I've been trying to get it to work for more simple text entry purposes for a couple of weeks now.

I tried uncommenting those lines, but still have the same problem. When beginning to type for example, "individual", I will get the tooltip match after typing "ind" and can hit space to complete. However, if I type "For an individual", I will not get the autocomplete tooltip, and the only way to get it back short of reloading the script, is to backspace over the entire "For an individual" and then it will work again


The following script fixes that problem:

SetKeyDelay, 0
SetBatchLines, 5ms
CoordMode, ToolTip, Relative
AutoTrim, Off

; +---------------+
; | CONFIGURATION |
; +---------------+

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

ETitle =

;Minimum word length to make a guess

WLen = 3

; Press Space to complete command and
; Escape & Enter to clear

; Gets path to AutoHotkey
RegRead, AHKPATH, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Run\Command,
StringGetPos, POS, AHKPATH, \AutoHotkey.exe
StringLeft, AHKPATH, AHKPATH, %POS%
StringReplace, AHKPATH, AHKPATH, ",, A

;reads command syntaxes
Loop, Read, %AHKPATH%auto_complete.txt
{
   tosend = %a_loopreadline%

   StringReplace, tosend, tosend, }, +], a
   StringReplace, tosend, tosend, {, +[, a
   StringReplace, tosend, tosend, #, {#}, a
   StringReplace, tosend, tosend, ``n, {enter}, a
   StringReplace, tosend, tosend, ``t, {tab}, a
   StringReplace, tosend, tosend, ``b, {bs}, a

   cmd%a_index% = %toSend%
}

Loop
{
   ;Editor window check
   WinGetActiveTitle, ATitle
   IfNotInString, ATitle, %ETitle%
   {
      ToolTip
      Setenv, Word,
      sleep, 500
      Continue
   }

   ;Get one key at a time
   Input, chr, L1 V, {enter}{Space}{F4}{bs}{esc}
   EndKey = %errorlevel%

   ;Blanks word reserve
   ifequal, EndKey, Endkey:Enter, Setenv, Word,
   ifequal, EndKey, Endkey:Escape, Setenv, Word,

   ;Backspace clears last letter
   ifequal, EndKey, Endkey:BackSpace, StringTrimRight, Word, Word, 1
   ifnotequal, EndKey, Endkey:BackSpace, Setenv, Word, %word%%chr%

   ;Wait till minimum letters
   StringLen, len, Word
   IfLess, len, %wlen%
   {
      ToolTip
      Continue
   }

   ;Match part-word with command
   Num =
   Match =
   Loop
   {
      IfEqual, cmd%a_index%,, Break
      StringLen, len, word
      StringLeft, check, cmd%a_index%, %len%
      IfEqual, word, %check%
      {
         num = %a_index%
         break
      }
   }

   ;If no match then clear Tip
   IfEqual, Num,
   {
      ifequal, EndKey, Endkey:Space, Setenv, Word,
      ToolTip
      Continue
   }

   ;Show matched command
   StringTrimLeft, match, cmd%num%, 0
   display_y = %A_CaretY%
   display_y -= 20 ; Move tooltip up a little so as not to hide the caret.
   IfNotEqual, Word,,ToolTip, %match%, %A_CaretX%, %display_y%

   ;Complete command
   IfNotEqual, Word,, IfEqual, EndKey, Endkey:Space
   {
      StringLen, len, Word
      Send, {BackSpace}
      Send, {BS %len%}%match%
      Send, {Space}
      Word =
      ToolTip
   }

   ;Blanks word reserve
   ifequal, EndKey, Endkey:Enter, Setenv, Word,
   ifequal, EndKey, Endkey:Escape, Setenv, Word,
   ifequal, EndKey, Endkey:Space, Setenv, Word,
}

blank_word:
  Setenv, Word,
  return

Note: You need an auto_complete.txt file for it to work, one word per line.

IMO, this has the potential to be an /extremely/ useful script.

However it still needs some tidying up.

Has this functionality been done better elsewhere?

If not can I encourage some experts to adopt this script,
and help improve it?

Wishlist:
* ToolTip has a menu of possible auto-completions, which turns into a
real menu if you press 'down';
* Mouse clicks, arrow keys etc cancel the current word;
* Tracking of insertion point changes using left and right arrow;
* Use of recent typing history (in addition to word file) for completions.
--
__________
|im |yler http://timtyler.org/...tim@tt1lock.org Remove lock to reply.

timtyler
  • Members
  • 17 posts
  • Last active: Jan 25 2007 02:49 PM
  • Joined: 01 Jan 2007
This thread also seems relevant:

Intellisense-like autoreplacement with multiple suggestions
http://www.autohotke...m/topic667.html
--
__________
|im |yler http://timtyler.org/...tim@tt1lock.org Remove lock to reply.