 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
maniac
Joined: 28 Aug 2009 Posts: 196
|
Posted: Thu Sep 17, 2009 11:59 am Post subject: |
|
|
Here's the full script (I had it in my previous post too, just without the fix for the cursor moving vertically... why didn't you use that?)... The reason it didn't work for your wordlist is that you were using the original version from the first post. The version I made can handle your 1.3 MB (!!) wordlist. My modifications take the time to run this from 20+% cpu down to 2% on my X2 4200+ even with your wordlist, and the words pop up right away.
2 press version:
| 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
; 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
;reads list of words from file
Loop, Read, %A_ScriptDir%\Wordlist.txt
{
StringLeft, Base, a_loopreadline, %wlen%
Base := ConvertWordToAscii(Base)
basenum%Base%++
pos := basenum%Base%
cmd%Base%%pos% = %a_loopreadline%
}
SetTimer, Winchanged, 100
Loop
{
;Editor window check
WinGetActiveTitle, ATitle
WinGet, A_id, ID, %ATitle%
IfNotInString, ATitle, %ETitle%
{
ToolTip
Setenv, Word,
sleep, 500
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%
{
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
{
ifequal, chr, @
{
Gosub,clearallvars
Setenv, Word, %chr%
Continue
} else {
Setenv, Word, %word%%chr%
}
} else Gosub,clearallvars
;Wait till minimum letters
StringLen, len, Word
IfLess, len, %wlen%
{
ToolTip
Continue
}
;Match part-word with command
Num =
Match =
singlematch = 0
number = 0
StringLeft, baseword, Word, %wlen%
baseword := ConvertWordToAscii(baseword)
Loop
{
IfEqual, cmd%baseword%%a_index%,, Break
IfEqual, number, 10
Break
StringLen, chars, Word
StringLeft, strippedcmd, cmd%baseword%%a_index%, %chars%
ifequal, strippedcmd, %Word%
{
number ++
singlematch := cmd%baseword%%a_index%
match = %match%%number%. %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%
MaxY := PosY + SizeY
ToolTipSizeY := (number * 12)
ToolTipPosY := A_CaretY+14
if ((ToolTipSizeY + ToolTipPosY) > MaxY)
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::
key=1
Gosub, checkword
Return
$2::
key=2
Gosub, checkword
Return
$3::
key=3
Gosub, checkword
Return
$4::
key=4
Gosub, checkword
Return
$5::
key=5
Gosub, checkword
Return
$6::
key=6
Gosub, checkword
Return
$7::
key=7
Gosub, checkword
Return
$8::
key=8
Gosub, checkword
Return
$9::
key=9
Gosub, checkword
Return
$0::
key=10
Gosub, checkword
Return
; If hotkey was pressed, check wether there's a match going on and send it, otherwise send the number(s) typed
checkword:
clearword=1
Suspend, on ; Suspend hotkeys so that they don't interfere with the second press
; 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%
{
if key =10
key = 0
SendInput,%key%
Gosub,clearallvars
Suspend, off
Return
}
IfNotEqual, OldCaretY, %A_CaretY%
{
if key =10
key = 0
SendInput,%key%
Gosub,clearallvars
Suspend, off
Return
}
if word= ; only continue if word is not empty
{
if key =10
key = 0
SendInput,%key%
Setenv, Word, %key%
clearword=0
Gosub,clearallvars
Suspend, off
Return
}
ifequal, singlematch%key%, ; only continue singlematch is not empty
{
if key =10
key = 0
SendInput,%key%
Setenv, Word, %word%%key%
clearword=0
Gosub,clearallvars
Suspend, off
Return
}
; 2nd press to confirm replacement
Input, keyagain, L1 I T0.5, 1234567890
; msgbox, ErrorLevel=%ErrorLevel% ; UNCOMMENT FOR TESTING 2ND PROBLEM DISCUSSED IN POST
; If there is a timeout, abort replacement, send key and return
IfEqual, ErrorLevel, Timeout
{
if key =10
key = 0
SendInput, %key%
Setenv, Word, %word%%key%
clearword=0
Gosub,clearallvars
Suspend, off
Return
}
; Make sure it's an EndKey, otherwise abort replacement, send key and return
IfNotInString, ErrorLevel, EndKey:
{
if key =10
key = 0
SendInput, %key%%keyagain%
Setenv, Word, %word%%key%%keyagain%
clearword=0
Gosub,clearallvars
Suspend, off
Return
}
; If the 2nd key is NOT the same 1st trigger key, abort replacement and send keys
if key =10
key = 0
IfNotInString,ErrorLevel, %key%
{
StringTrimLeft, keyagain, ErrorLevel, 7
SendInput, %key%%keyagain%
Setenv, Word, %word%%key%%keyagain%
clearword=0
Gosub,clearallvars
Suspend, off
Return
}
; SEND THE WORD!
if key =0
key = 10
sending := singlematch%key%
StringLen, len, Word
SendInput, {BS %len%}{Raw}%sending% ; First do the backspaces, Then send word (Raw because we want the string exactly as in wordlist.txt)
Gosub,clearallvars
Suspend, off
Return
; This is to blank all vars related to matches, tooltip and (optionally) word
clearallvars:
Ifequal,clearword,1,Setenv,word,
ToolTip
; Clear all singlematches
Loop, 10
{
singlematch%a_index% =
}
sending =
key=
match=
clearword=1
OldCaretY=
Return
ConvertWordToAscii(Base)
{
StringUpper, Base, Base
StringLen, Len, Base
Loop, %Len%
{
Transform, Letter, Asc, %Base%
StringLen, LetterLen, Letter
IfLess, %LetterLen%, 3
{
Amt := 3-LetterLen
Loop, %Amt%
{
Letter = 0%Letter%
}
}
New = %New%%Letter%
StringTrimLeft, Base, Base, 1
}
Return New
} |
1 press version:
| 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
; 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
;reads list of words from file
Loop, Read, %A_ScriptDir%\Wordlist.txt
{
StringLeft, Base, a_loopreadline, %wlen%
Base := ConvertWordToAscii(Base)
basenum%Base%++
pos := basenum%Base%
cmd%Base%%pos% = %a_loopreadline%
}
SetTimer, Winchanged, 100
Loop
{
;Editor window check
WinGetActiveTitle, ATitle
WinGet, A_id, ID, %ATitle%
IfNotInString, ATitle, %ETitle%
{
ToolTip
Setenv, Word,
sleep, 500
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%
{
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
{
ifequal, chr, @
{
Gosub,clearallvars
Setenv, Word, %chr%
Continue
} else {
Setenv, Word, %word%%chr%
}
} else Gosub,clearallvars
;Wait till minimum letters
StringLen, len, Word
IfLess, len, %wlen%
{
ToolTip
Continue
}
;Match part-word with command
Num =
Match =
singlematch = 0
number = 0
StringLeft, baseword, Word, %wlen%
baseword := ConvertWordToAscii(baseword)
Loop
{
IfEqual, cmd%baseword%%a_index%,, Break
IfEqual, number, 10
Break
StringLen, chars, Word
StringLeft, strippedcmd, cmd%baseword%%a_index%, %chars%
ifequal, strippedcmd, %Word%
{
number ++
singlematch := cmd%baseword%%a_index%
match = %match%%number%. %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%
MaxY := PosY + SizeY
ToolTipSizeY := (number * 12)
ToolTipPosY := A_CaretY+14
if ((ToolTipSizeY + ToolTipPosY) > MaxY)
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::
key=1
Gosub, checkword
Return
$2::
key=2
Gosub, checkword
Return
$3::
key=3
Gosub, checkword
Return
$4::
key=4
Gosub, checkword
Return
$5::
key=5
Gosub, checkword
Return
$6::
key=6
Gosub, checkword
Return
$7::
key=7
Gosub, checkword
Return
$8::
key=8
Gosub, checkword
Return
$9::
key=9
Gosub, checkword
Return
$0::
key=10
Gosub, checkword
Return
; If hotkey was pressed, check wether there's a match going on and send it, otherwise send the number(s) typed
checkword:
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%
{
if key =10
key = 0
SendInput,%key%
Gosub,clearallvars
Return
}
IfNotEqual, OldCaretY, %A_CaretY%
{
if key =10
key = 0
SendInput,%key%
Gosub,clearallvars
Return
}
if word= ; only continue if word is not empty
{
if key =10
key = 0
SendInput,%key%
Setenv, Word, %key%
clearword=0
Gosub,clearallvars
Return
}
ifequal, singlematch%key%, ; only continue singlematch is not empty
{
if key =10
key = 0
SendInput,%key%
Setenv, Word, %word%%key%
clearword=0
Gosub,clearallvars
Return
}
; SEND THE WORD!
if key =0
key = 10
sending := singlematch%key%
StringLen, len, Word
SendInput, {BS %len%}{Raw}%sending% ; First do the backspaces, Then send word (Raw because we want the string exactly as in wordlist.txt)
Gosub,clearallvars
Return
; This is to blank all vars related to matches, tooltip and (optionally) word
clearallvars:
Ifequal,clearword,1,Setenv,word,
ToolTip
; Clear all singlematches
Loop, 10
{
singlematch%a_index% =
}
sending =
key=
match=
clearword=1
OldCaretY=
Return
ConvertWordToAscii(Base)
{
StringUpper, Base, Base
StringLen, Len, Base
Loop, %Len%
{
Transform, Letter, Asc, %Base%
StringLen, LetterLen, Letter
IfLess, %LetterLen%, 3
{
Amt := 3-LetterLen
Loop, %Amt%
{
Letter = 0%Letter%
}
}
New = %New%%Letter%
StringTrimLeft, Base, Base, 1
}
Return New
} |
But um, 109,538 words is a little overkill isn't it? That's about 1/5th of the words in the english language, lol. My wordlist, for example, is ~1,400 words. Most of the time you'd use an autoreplacer like this for commonly typed words, not the entire dictionary . |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Sep 17, 2009 12:53 pm Post subject: |
|
|
Oh it's nice now. It's not lagging. Oh so my dictionary is not complete? Oh I need the complete version. hehe. Thanks for this maniac.  |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Sep 28, 2009 1:00 am Post subject: |
|
|
| Hi. I'm thinking, is it possible to change or add as feature, of using up and down or left and right arrow keys to choose? I would like to use arrows than struggle finding the correct number. Thanks. |
|
| Back to top |
|
 |
maniac
Joined: 28 Aug 2009 Posts: 196
|
Posted: Mon Sep 28, 2009 11:32 am Post subject: |
|
|
| Anonymous wrote: | | Hi. I'm thinking, is it possible to change or add as feature, of using up and down or left and right arrow keys to choose? I would like to use arrows than struggle finding the correct number. Thanks. |
It could be, but the way the dropdown is presented will have to change. I have thought of changing it but have not taken the time.
A working example can be found in this program:
http://www.autohotkey.com/forum/viewtopic.php?t=12985&start=0 |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Sep 28, 2009 2:59 pm Post subject: |
|
|
| I'll just wait when you have time to get to it 'cause I'm no scripter by any means. Thanks. |
|
| Back to top |
|
 |
kakarukeys
Joined: 28 Sep 2009 Posts: 86
|
Posted: Mon Nov 30, 2009 3:15 am Post subject: Update |
|
|
I updated maniac's script (1-press version).
The full TypingAid program, script and many word-lists: the technical terms in some expertise can be downloaded from here..
Here are the changes:
1. Deleted the word 'Intellitype' which is MS$ brand name, we don't want to get any letter from their lawyers.
2. Added a welcome splash text
3. Deleted chars , ' from the excluded list, these two chars are crucial for certain technical terms and the input of some languages with accents
(the line after the comment ;Get one key at a time)
4. changed ToolTipPosY, so that the tooltip will not block typing on some windows version.
5. Added code by Asaptrad, so that you can now add phrase to wordlist.txt immediately by highlighting the phrase and press Ctrl + Shift + C.
6. Changed how autocompletion is done, now it completes the phrase from where the user has stopped.
7. Tested on some keyboard layouts and inputs.
| Code: |
; Typing aid
; Press 1 to 0 keys to autocomplete the word upon suggestion
; (0 will match suggestion 10)
; - Jordi S
; Heavily modified by:
; - Maniac
; modified by:
; - Asaptrad
; - Artwinauto.com
;___________________________________________
SplashTextOn,400,100,,TypingAid Program version 1.0 from Artwinauto.com. Credits: Jordi S, Maniac, Asaptrad @ AutoHotKey Forum
Sleep, 3000
SplashTextOff
; CONFIGURATIONS
; 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
;reads list of words from file
Loop, Read, %A_ScriptDir%\Wordlist.txt
{
StringLeft, Base, a_loopreadline, %wlen%
Base := ConvertWordToAscii(Base)
basenum%Base%++
pos := basenum%Base%
cmd%Base%%pos% = %a_loopreadline%
}
SetTimer, Winchanged, 100
Loop
{
;Editor window check
WinGetActiveTitle, ATitle
WinGet, A_id, ID, %ATitle%
IfNotInString, ATitle, %ETitle%
{
ToolTip
Setenv, Word,
sleep, 500
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%
{
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
{
ifequal, chr, @
{
Gosub,clearallvars
Setenv, Word, %chr%
Continue
} else {
Setenv, Word, %word%%chr%
}
} else Gosub,clearallvars
;Wait till minimum letters
StringLen, len, Word
IfLess, len, %wlen%
{
ToolTip
Continue
}
;Match part-word with command
Num =
Match =
singlematch = 0
number = 0
StringLeft, baseword, Word, %wlen%
baseword := ConvertWordToAscii(baseword)
Loop
{
IfEqual, cmd%baseword%%a_index%,, Break
IfEqual, number, 10
Break
StringLen, chars, Word
StringLeft, strippedcmd, cmd%baseword%%a_index%, %chars%
ifequal, strippedcmd, %Word%
{
number ++
singlematch := cmd%baseword%%a_index%
match = %match%%number%. %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%
MaxY := PosY + SizeY
ToolTipSizeY := (number * 12)
ToolTipPosY := A_CaretY+24
if ((ToolTipSizeY + ToolTipPosY) > MaxY)
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::
key=1
Gosub, checkword
Return
$2::
key=2
Gosub, checkword
Return
$3::
key=3
Gosub, checkword
Return
$4::
key=4
Gosub, checkword
Return
$5::
key=5
Gosub, checkword
Return
$6::
key=6
Gosub, checkword
Return
$7::
key=7
Gosub, checkword
Return
$8::
key=8
Gosub, checkword
Return
$9::
key=9
Gosub, checkword
Return
$0::
key=10
Gosub, checkword
Return
^+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
; If hotkey was pressed, check wether there's a match going on and send it, otherwise send the number(s) typed
checkword:
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%
{
if key =10
key = 0
SendInput,%key%
Gosub,clearallvars
Return
}
IfNotEqual, OldCaretY, %A_CaretY%
{
if key =10
key = 0
SendInput,%key%
Gosub,clearallvars
Return
}
if word= ; only continue if word is not empty
{
if key =10
key = 0
SendInput,%key%
Setenv, Word, %key%
clearword=0
Gosub,clearallvars
Return
}
ifequal, singlematch%key%, ; only continue singlematch is not empty
{
if key =10
key = 0
SendInput,%key%
Setenv, Word, %word%%key%
clearword=0
Gosub,clearallvars
Return
}
; SEND THE WORD!
if key =0
key = 10
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)
Gosub,clearallvars
Return
; This is to blank all vars related to matches, tooltip and (optionally) word
clearallvars:
Ifequal,clearword,1,Setenv,word,
ToolTip
; Clear all singlematches
Loop, 10
{
singlematch%a_index% =
}
sending =
key=
match=
clearword=1
OldCaretY=
Return
ConvertWordToAscii(Base)
{
StringUpper, Base, Base
StringLen, Len, Base
Loop, %Len%
{
Transform, Letter, Asc, %Base%
StringLen, LetterLen, Letter
IfLess, %LetterLen%, 3
{
Amt := 3-LetterLen
Loop, %Amt%
{
Letter = 0%Letter%
}
}
New = %New%%Letter%
StringTrimLeft, Base, Base, 1
}
Return New
}
|
_________________ TypingAid autocompletion program made with AHK. |
|
| Back to top |
|
 |
maniac
Joined: 28 Aug 2009 Posts: 196
|
Posted: Wed Dec 02, 2009 1:05 pm Post subject: |
|
|
Hey Kakarukeys, nice, but my only request is that you change the term "freeware" on your site here:
http://www.artwinauto.com/downloads/typing-programs/typingaid.html
to "free software". Freeware implies that the program is typically closed source. See: http://en.wikipedia.org/wiki/Freeware#Criteria
Thanks,
Maniac
P.S.
I also have a version of this script which learns words as you type them (you have to type them 5x in one session of the script to learn them permanently). If I get around to modifying it to a more generic version of the script I may post it here. Right now it's only implemented in the one for the proprietary programming language I use at work. |
|
| Back to top |
|
 |
kakarukeys
Joined: 28 Sep 2009 Posts: 86
|
Posted: Wed Dec 02, 2009 1:33 pm Post subject: Ok |
|
|
It's done.
 _________________ TypingAid autocompletion program made with AHK. |
|
| Back to top |
|
 |
maniac
Joined: 28 Aug 2009 Posts: 196
|
Posted: Wed Dec 02, 2009 2:57 pm Post subject: |
|
|
| Great, thanks! |
|
| Back to top |
|
 |
kakarukeys
Joined: 28 Sep 2009 Posts: 86
|
Posted: Tue Dec 22, 2009 7:14 am Post subject: |
|
|
Calling all TypingAid developers to help!
Suggested improvement and/or bug fixes from user feedback sent to me:
1. supporting c-bowl character č (see picture), which is critical in some Bosnian languages:
http://www.artwinauto.com/files/c-bow.jpg
2. detect caret position correctly in FireFox browser. (HARD!)
3. change tooltip display: 10. to 0. (people mistakenly tried to press 1 followed by 0 to get the 10th suggestion)
4. option to adjust the font size of the tooltip? (current size is difficult to read for some disabled persons)
TypingAid 1.1 version
| Code: | ; Typing aid
; Press 1 to 0 keys to autocomplete the word upon suggestion
; (0 will match suggestion 10)
; - Jordi S
; Heavily modified by:
; - Maniac
; modified by:
; - Asaptrad
; - Artwinauto.com
;___________________________________________
SplashTextOn,400,100,,TypingAid Program version 1.1 from Artwinauto.com. Credits: Jordi S, Maniac, Asaptrad @ AutoHotKey Forum
Sleep, 3000
SplashTextOff
; CONFIGURATIONS
; 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
;reads list of words from file
Loop, Read, %A_ScriptDir%\Wordlist.txt
{
StringLeft, Base, a_loopreadline, %wlen%
Base := ConvertWordToAscii(Base)
basenum%Base%++
pos := basenum%Base%
cmd%Base%%pos% = %a_loopreadline%
}
SetTimer, Winchanged, 100
Loop
{
;Editor window check
WinGetActiveTitle, ATitle
WinGet, A_id, ID, %ATitle%
IfNotInString, ATitle, %ETitle%
{
ToolTip
Setenv, Word,
sleep, 500
Continue
}
;Get one key at a time
Input, chr, L1 I 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%
{
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
{
ifequal, chr, @
{
Gosub,clearallvars
Setenv, Word, %chr%
Continue
} else {
Setenv, Word, %word%%chr%
}
} else Gosub,clearallvars
;Wait till minimum letters
StringLen, len, Word
IfLess, len, %wlen%
{
ToolTip
Continue
}
;Match part-word with command
Num =
Match =
singlematch = 0
number = 0
StringLeft, baseword, Word, %wlen%
baseword := ConvertWordToAscii(baseword)
Loop
{
IfEqual, cmd%baseword%%a_index%,, Break
IfEqual, number, 10
Break
StringLen, chars, Word
StringLeft, strippedcmd, cmd%baseword%%a_index%, %chars%
ifequal, strippedcmd, %Word%
{
number ++
singlematch := cmd%baseword%%a_index%
match = %match%%number%. %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%
MaxY := PosY + SizeY
ToolTipSizeY := (number * 12)
ToolTipPosY := A_CaretY+24
if ((ToolTipSizeY + ToolTipPosY) > MaxY)
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::
key=1
Gosub, checkword
Return
$2::
key=2
Gosub, checkword
Return
$3::
key=3
Gosub, checkword
Return
$4::
key=4
Gosub, checkword
Return
$5::
key=5
Gosub, checkword
Return
$6::
key=6
Gosub, checkword
Return
$7::
key=7
Gosub, checkword
Return
$8::
key=8
Gosub, checkword
Return
$9::
key=9
Gosub, checkword
Return
$0::
key=10
Gosub, checkword
Return
^+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
; If hotkey was pressed, check wether there's a match going on and send it, otherwise send the number(s) typed
checkword:
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%
{
if key =10
key = 0
SendInput,%key%
Gosub,clearallvars
Return
}
IfNotEqual, OldCaretY, %A_CaretY%
{
if key =10
key = 0
SendInput,%key%
Gosub,clearallvars
Return
}
if word= ; only continue if word is not empty
{
if key =10
key = 0
SendInput,%key%
Setenv, Word, %key%
clearword=0
Gosub,clearallvars
Return
}
ifequal, singlematch%key%, ; only continue singlematch is not empty
{
if key =10
key = 0
SendInput,%key%
Setenv, Word, %word%%key%
clearword=0
Gosub,clearallvars
Return
}
; SEND THE WORD!
if key =0
key = 10
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)
Gosub,clearallvars
Return
; This is to blank all vars related to matches, tooltip and (optionally) word
clearallvars:
Ifequal,clearword,1,Setenv,word,
ToolTip
; Clear all singlematches
Loop, 10
{
singlematch%a_index% =
}
sending =
key=
match=
clearword=1
OldCaretY=
Return
ConvertWordToAscii(Base)
{
StringUpper, Base, Base
StringLen, Len, Base
Loop, %Len%
{
Transform, Letter, Asc, %Base%
StringLen, LetterLen, Letter
IfLess, %LetterLen%, 3
{
Amt := 3-LetterLen
Loop, %Amt%
{
Letter = 0%Letter%
}
}
New = %New%%Letter%
StringTrimLeft, Base, Base, 1
}
Return New
} |
After I put TypingAid on my blog, I'm overwhelmed by the amount of responses. At least two projects found very meaningful use of the program.
One is from CASABIO NGO, who said they are using TypingAid to input some very lengthy species name onto their computers.
Another one is from a Dr from a Bosnia university who said he can help Dyslexia students with TypingAid.
I hope some continued improvement on the program can be maintained, as there is a a noble reason for doing so: it contributes to some humanitarian efforts. _________________ TypingAid autocompletion program made with AHK. |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Dec 22, 2009 10:36 am Post subject: |
|
|
| Still looking for that upper up/down feature. |
|
| Back to top |
|
 |
maniac
Joined: 28 Aug 2009 Posts: 196
|
Posted: Tue Dec 22, 2009 3:31 pm Post subject: |
|
|
It's great that you've gotten a lot of response!
1. This program only supports the ascii charset. The C-bowl character is outside the ascii charset. If AHK itself even supports it, the script would require a lot of rewriting as the pseudo-hash I implemented relies on the ascii charset. A quick test... try it with the original script Jordi posted since his doesn't use the hashing.
3. The following is a quick and easy fix:
| Code: | number ++
singlematch := cmd%baseword%%a_index%
match := match . Mod(number,10) . ". " . singlematch . "`n"
singlematch%number% = %singlematch% |
4. I think you'd have to do something with GUI's.
| Anonymous wrote: | | Still looking for that upper up/down feature. |
Sorry, I just haven't had the time/motivation to get around to it. |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Dec 22, 2009 5:25 pm Post subject: |
|
|
Yeah, it's an old post. Glad to see a few are interested. I guess I'll just wait until somebody can put in the feature of like using the arrow up/down. If possible like instead of pressing 9 for the 9th item, I just arrow down to last item (10th) then arrow up to the 9th.
Thanks in advance. |
|
| Back to top |
|
 |
kakarukeys
Joined: 28 Sep 2009 Posts: 86
|
Posted: Wed Dec 23, 2009 10:44 am Post subject: |
|
|
| Anonymous wrote: | Yeah, it's an old post. Glad to see a few are interested. I guess I'll just wait until somebody can put in the feature of like using the arrow up/down. If possible like instead of pressing 9 for the 9th item, I just arrow down to last item (10th) then arrow up to the 9th.
Thanks in advance. |
Isn't this slower? the right hand left its position and tap the arrow keys multiple times and return to its position.
compared to just tap the number key once and continue typing _________________ TypingAid autocompletion program made with AHK. |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Dec 23, 2009 11:08 am Post subject: |
|
|
| I think it's faster to use the arrow key when the item is near the top and near the bottom than have to look for the number. I like the arrow feature added not replace the tapping. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|