 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
kakarukeys
Joined: 28 Sep 2009 Posts: 86
|
Posted: Thu Jan 07, 2010 1:25 pm Post subject: |
|
|
Ya, the tooltip could cover up the caret when the user is typing near the bottom. Away from the bottom, it works quite well. The user could readjust the tooltip position with a mouse click (but I forgot to mention this in the readme, let them figure out by themselves)
I see. Learners and dyslexic users usually don't put long phrases, productivity users may feel , but they have two versions to choose from.
Using your program with an empty wordlist to do some coding in notepad2, see how it goes. _________________ TypingAid autocompletion program made with AHK. |
|
| Back to top |
|
 |
Irfa Guest
|
Posted: Thu Jan 07, 2010 9:06 pm Post subject: |
|
|
| maniac wrote: | OK, I got around to getting my version back to a generic version - there are a LOT of changes (I did not thoroughly test that everything worked after stripping my custom code out, please let me know if you see any issues):
Changed the 10th item to number 0 rather than number 10 in the dropdown.
Changed the way the script waits for a window to be active again.
Added a workaround for an AHK bug which could cause keypresses to be interspersed in the autocompleted word.
Cleaned up code and reduced use of variables internally.
Words that you type will now be remembered and pop up at the end of the list until the script is restarted. If the words are typed more than 5x they will be remembered permanently and appended below a keyword ;LEARNEDWORDS;. They are ranked by typing frequency.
Tooltip now disappears when the line is changed (the word is NOT cleared).
|
I wanted to use this version with the 1.3MB dict that is above.
I added ;LEARNEDWORDS; at the top of the dict.
When i exited the script, it started doing something in Temp_wordlist
an cut the wordlist.txt to 82KB.
Can you fix it? |
|
| Back to top |
|
 |
maniac
Joined: 28 Aug 2009 Posts: 267
|
Posted: Fri Jan 08, 2010 2:44 am Post subject: |
|
|
| Irfa wrote: | | maniac wrote: | OK, I got around to getting my version back to a generic version - there are a LOT of changes (I did not thoroughly test that everything worked after stripping my custom code out, please let me know if you see any issues):
Changed the 10th item to number 0 rather than number 10 in the dropdown.
Changed the way the script waits for a window to be active again.
Added a workaround for an AHK bug which could cause keypresses to be interspersed in the autocompleted word.
Cleaned up code and reduced use of variables internally.
Words that you type will now be remembered and pop up at the end of the list until the script is restarted. If the words are typed more than 5x they will be remembered permanently and appended below a keyword ;LEARNEDWORDS;. They are ranked by typing frequency.
Tooltip now disappears when the line is changed (the word is NOT cleared).
|
I wanted to use this version with the 1.3MB dict that is above.
I added ;LEARNEDWORDS; at the top of the dict.
When i exited the script, it started doing something in Temp_wordlist
an cut the wordlist.txt to 82KB.
Can you fix it? |
Well ;LEARNEDWORDS; should not be added manually. The script will add it automatically (unless you want it to rank your current words). I don't think it can really handle 1.3 MB of learned words, it has to do some sorting and the like which will probably crash AHK or seize up the resources on your computer for a long time. I would just let it append your learned words to the end of the list.
Edit:
Doing some testing.... it took like 1 minute to load up the script on my Q9550 at 3.6 GHz lol.
After I exited the script I had to sit there for about 10 minutes before it finished (this is on my 3.6 GHz Q9550). It does some strenuous processing to order the words in the file and that file is wayyy to big to have the learnedwords keyword at the beginning . I would recommend letting it only learn words not already in the wordlist. I didn't have any problems with it making the wordlist really small (it just removed the words less than 4 characters long). If you look in the task manager you can see that AutoHotKey.exe is still using CPU after it exit because it's doing all the processing to update the wordlist file.
Like I said before, this isn't really intended for such large lists of words.
I might be able to change the sorting to an insertion algorithm but I'm not really sure how much it would help (and I can't remember if that would actually help when exiting the script... it would help when updating the count for learnedwords but with your 1.3 MB wordlist I didn't see any CPU issues on my machine so I'm not sure it would help there).
Edit2:
Yeah, I looked at the code again, basically it does this:
On Start:
Create a comma separated list of learned words when parsing in the file.
While running:
Add new words to that comma separated list.
On Exiting:
Loop through the comma separated list, check the stored count (# of times typed) for each word, add that to a new comma separated list - SortWordList, in the form of:
###zWORD
where ### is the number of times typed, z is a delimiting character, and WORD is the actual word.
Then sort SortWordList in descending order.
Then it parses SortWordList and adds creates a file Temp_WordList.txt, and adds all the learned words to that. After it finishes adding all the words to that it copies the file to WordList.txt and deletes Temp_Wordlist.txt.
So basically unless someone can give me a more efficient way of creating a list in AHK rather than a Comma Separated list which requires parsing, I don't know how much I can do to speed it up (and I don't know if that's even where the performance hit is). |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Jan 08, 2010 1:53 pm Post subject: |
|
|
mmm long read, still hoping for that arrow feature.  |
|
| Back to top |
|
 |
maniac
Joined: 28 Aug 2009 Posts: 267
|
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Sat Jan 09, 2010 9:58 am Post subject: |
|
|
@maniac
Regarding the speed for large lists: I've had a quick peek at the script and noticed two things for reading and writing the wordlist which would be easy to change and will probably increase speed as it requires only 1 file read and one file write and not per line (e.g. 100.000 words = 100.000 file reads and file saves)
Change | Code: | ;reads list of words from file
Loop, Read, %A_ScriptDir%\Wordlist.txt
{
addword = %a_loopreadline%
Gosub, addwordtolist
} |
to
| Code: | ;reads list of words from file
FileRead, ParseWords, %A_ScriptDir%\Wordlist.txt
Loop, Parse, ParseWords, `n, `r
{
addword = %a_loopreadline%
Gosub, addwordtolist
}
ParseWords= ; free mem |
and the same happens with saving the words list, rather than
building one varialble in memory with the loop each word
seems to be written using fileappend on various locations
for example:
| Code: | Loop, Read, %A_ScriptDir%\Wordlist.txt, %A_ScriptDir%\Temp_WordList.txt
{
IfEqual, A_LoopReadLine, `;LEARNEDWORDS`;
SkipRest = 1
IfEqual, SkipRest,
FileAppend, %A_LoopReadLine%`n
} |
to
| Code: |
FileRead, ParseWords, %A_ScriptDir%\Wordlist.txt
Loop, Parse, ParseWords, `n, `r
{
IfEqual, A_LoopReadLine, `;LEARNEDWORDS`;
SkipRest = 1
IfEqual, SkipRest,
NewWordList .= A_LoopReadLine "`n"
} | and keep adding to that NewWordList variable until it is complete and write once with one fileappend.
Hotkeys could be condensed: | Code: | #MaxThreadsPerHotkey 1
$1::
$2::
$3::
$4::
$5::
$6::
$7::
$8::
$9::
$0::
key:=A_ThisHotkey
If (Key = 0)
key=10
Gosub, checkword
Return |
Speed up sending of long words and sentences by pasting clipboard
replace:
| Code: | BlockInput, On
SendInput, {BS %len%}{Raw}%sending% ; First do the backspaces, Then send word (Raw because we want the string exactly as in wordlist.txt)
BlockInput, Off |
with something like this, not sure if it works because or RAW so you may want to test it carefully or not apply it
| Code: | BlockInput, On
ClipboardSave:=ClipboardAll
Clipboard=
Clipboard:=sending
SendInput, {BS %len%}^v ; First do the backspaces, Then send word (Raw because we want the string exactly as in wordlist.txt)
Clipboard=
Clipboard:=ClipboardSave
ClipboardSave= ;free mem
BlockInput, Off |
In general the script uses many Gosub which could be replaced with functions although I don't know if that would increase or decrease the speed...
HTH _________________ AHK Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
maniac
Joined: 28 Aug 2009 Posts: 267
|
Posted: Sat Jan 09, 2010 12:41 pm Post subject: |
|
|
hugov, great, thanks for the tips, I will try them out on Monday.
There's a lot that I'm not familiar with about AHK so any tips are much appreciated.
Also, regarding saving the clipboard data... does that only save text or will it save non-text data like pictures and files as well? |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Jan 09, 2010 1:05 pm Post subject: |
|
|
| Hugo, do you know how to add arrow feature. This is when instead of looking for a number from 0-9, I just press arrow up or down. Like if my choice is number 9, I rather go UP (10) and UP (9). |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Sat Jan 09, 2010 1:28 pm Post subject: |
|
|
| maniac wrote: | | Also, regarding saving the clipboard data... does that only save text or will it save non-text data like pictures and files as well? |
| http://www.autohotkey.com/docs/misc/Clipboard.htm wrote: | | ClipboardAll contains everything on the clipboard, such as pictures and formatting. |
Re UP/DOWN keys, it won't work with the tooltip method used here you need a listbox or listview GUI. Isense has it for example but that only works with AHK commands at the moment, see
http://www.autohotkey.com/forum/topic12985.html
Other examples (not exactly like intellisense) but to illustrate the up/down
Listbox with incremental search by Boskoop
http://www.autohotkey.com/forum/viewtopic.php?t=2534
Incremental search for text to send
http://www.autohotkey.com/forum/viewtopic.php?t=6729
I use a modified versions of Boskoops version as my editor already supports autocompletion I only need it for longer sentences and this is where Kollektor shines... (but can become quite slow/sluggish when it comes to larger collections e.g. few thousand entries but I only have a few hundred per collection)
You could also hack away at the 320mph script which works with a listview which would also allow up/down and even pageup/pagedown  _________________ AHK Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
maniac
Joined: 28 Aug 2009 Posts: 267
|
Posted: Sat Jan 09, 2010 4:09 pm Post subject: |
|
|
Yeah, Isense is the example I had seen for the up/down. I just have no motivation to write the gui right now
Thanks for the info on the clipboard, I'll try that. That might fix the issues I have with capitalization sometimes too. |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Jan 10, 2010 11:32 am Post subject: |
|
|
| Oh, I pray maniac will have motivation soon. |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Sun Jan 10, 2010 12:19 pm Post subject: |
|
|
| Anonymous wrote: | | Oh, I pray maniac will have motivation soon. | Why don't you try yourself? (and don't tell me you are not a programmer, try replace the tooltip line with a gui is only a few lines of code, after that you can take it step further and add hotkeys for up/down and a gui submit after enter etc. break it down into little steps and who knows you just might make it yourself. If you wait for others it might never happen ...) _________________ AHK Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Jan 10, 2010 3:21 pm Post subject: |
|
|
| I don't know how tooltip works or how gui works. The most I've done is ::btw::by the way. It'll take twice the miracle me getting the arrow feature than you getting motivation. |
|
| Back to top |
|
 |
maniac
Joined: 28 Aug 2009 Posts: 267
|
Posted: Mon Jan 11, 2010 2:44 pm Post subject: |
|
|
OK, it seems to be faster when reading in the file. It's probably faster when saving too but I'm on a different, much slower pc, so I'm not really sure.
One thing I find weird is that on my PC right now it's only using 25% cpu (dual core, so 50% of one core)... this seems really low to me, it seems AHK is limiting the processing speed or something... is that correct?
I changed a few of the gosubs to functions as functions seem better to me anyway. I'm not really sure if it changed the speed any.
The clipboard thing did not work right. It only seemed to sometimes paste in the value, other times it just left the text blank. I have left the clipboard code commented in case anyone wants to try playing with it. I changed it from ^v to {Ctrl Down}v{Ctrl Up} as I couldn't get ^v to work at all.
Thanks,
Maniac
| 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)
OnExit, SaveScript
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 := 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
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%
{
BlockInput, On
SendInput,%key%
BlockInput, Off
Gosub,clearallvars
Return
}
IfNotEqual, OldCaretY, %A_CaretY% ;Make sure we are still on the same line
{
BlockInput, On
SendInput,%key%
BlockInput, Off
Gosub,clearallvars
Return
}
ifequal, Word, ; only continue if word is not empty
{
BlockInput, On
SendInput,%key%
BlockInput, Off
Setenv, Word, %key%
clearword=0
Gosub,clearallvars
Return
}
ifequal, singlematch%WordIndex%, ; only continue singlematch is not empty
{
BlockInput, On
SendInput,%key%
BlockInput, Off
Setenv, Word, %word%%key%
clearword=0
Gosub,clearallvars
Return
}
Local sending
Local len
Local ClipboardSave
; SEND THE WORD!
if key =0
key = 10
sending := singlematch%WordIndex%
StringLen, len, Word
; Update Typed Count
UpdateWordCount(sending)
BlockInput, On
SendInput, {BS %len%}{RAW}%sending% ; First do the backspaces, Then send word (Raw because we want the string exactly as in wordlist.txt)
; below doesn't seem to work right, it randomly sends blank values to SendInput
; ClipboardSave:=ClipboardAll
; Clipboard =
; Clipboard = %sending%
; SendInput, {BS %len%}{Ctrl Down}v{Ctrl Up} ; First do the backspaces, Then send word (Raw because we want the string exactly as in wordlist.txt)
; Clipboard =
; Clipboard = %ClipboardSave%
BlockInput, Off
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 we are not reading the wordlist file, use the following characters in the terminate list
CharTerminateList = 1,2,3,4,5,6,7,8,9,0
else CharTerminateList =
if addword contains %CharTerminateList% ;if one of the chars in the word is in the terminate list, don't add it
{
addword =
CharTerminateList =
Return
}
CharTerminateList =
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)
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
{
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 = %LearnedWords%,%addword%
}
zCount%CountWord% := LearnedWordsCount++ ;increment the count and store the Weight of the LearnedWord in reverse order (will be inverted later)
}
} else { ; If this is an on-the-fly learned word
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 = %LearnedWords%,%addword%
}
}
; Increment the counter for each hash
zbasenum%Base%++
pos := zbasenum%Base%
; Set the hashed value to the word
zword%Base%%pos% = %addword%
pos =
} Else {
IfEqual, WordListDone, 1 ;if we've already typed the word and we've loaded the wordlist increment the count
{
UpdateWordCount(addword)
}
}
Return
}
; 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
IfEqual, WordList, ;if we have no words in our wordlist, start it - prefix all words with (Count"z")
{
WordList := zCount%ConvertWord% . "z" . CountWord
} Else { ;else append to the wordlist
WordList := WordList . "," . zCount%ConvertWord% . "z" . CountWord
}
}
}
ifnotequal, Wordlist, ;If we have no words to process, don't
{
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, % StrLen(Base)
{
New := New . PadZeros(Asc(Base),3)
StringTrimLeft, Base, Base, 1
}
Return New
}
PadZeros(Word,Length)
{
; Pad a string out to Length numbers of 0's
StringLen, WordLen, Word
IfLess, WordLen, Length
{
Loop, % (Length - WordLen)
{
Word := "0" . Word
}
}
Return Word
}
SaveScript:
; Add all the standard words to the tempwordlist
FileRead, ParseWords, %A_ScriptDir%\Wordlist.txt
Loop, Parse, ParseWords, `n, `r
{
IfEqual, A_LoopField, `;LEARNEDWORDS`;
SkipRest = 1
IfEqual, SkipRest,
TempWordList .= A_LoopField "`n"
}
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
{
IfEqual, SortWordList,
{
SortWordList := zCount%SortWord% . "z" . A_LoopField
} else {
SortWordList := SortWordList . "," . zCount%SortWord% . "z" . A_LoopField
}
}
}
Sort, SortWordList, N R D, ; Sort numerically, comma delimiter
IfNotEqual, SortWordList, ; If SortWordList exists write to the file, otherwise don't.
{
TempWordList .= "`;LEARNEDWORDS`;`n"
FirstTimeLoop = 1
Loop, Parse, SortWordList, `,
{
StringTrimLeft, AppendWord, A_LoopField, InStr(A_LoopField,"z") ;Strip (Number,"z") from beginning
IfEqual, FirstTimeLoop, ;If we are not in our first time through the loop append a new line before the word
{
AppendWord = `n%AppendWord%
} else {
FirstTimeLoop =
}
TempWordList .= AppendWord
}
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
|
|
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Mon Jan 11, 2010 3:00 pm Post subject: |
|
|
| maniac wrote: | | The clipboard thing did not work right. It only seemed to sometimes paste in the value, other times it just left the text blank. I have left the clipboard code commented in case anyone wants to try playing with it. I changed it from ^v to {Ctrl Down}v{Ctrl Up} as I couldn't get ^v to work at all. | Try adding clipwait, 0 above the paste command. my guess is that it takes a short while before the clipboard gets the content so it pastes to fast.
Re speed: I think you will really start to notice the difference for very long lists e.g. 25000 lines but there is probably no difference when you have 100 words/lines in wordslist.txt _________________ AHK Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| 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
|