Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions Source/Includes/Preferences File.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ ReadPreferences(RestoreDefaults = false,RestorePreferences = false)
global dft_ListBoxNotDPIAwareProgramExecutables
global dft_HelperWindowProgramExecutables
global dft_HelperWindowProgramTitles
global dft_Wordlist

global prefs_IncludeProgramExecutables
global prefs_IncludeProgramTitles
Expand Down Expand Up @@ -82,15 +83,28 @@ ReadPreferences(RestoreDefaults = false,RestorePreferences = false)
global prefs_ListBoxNotDPIAwareProgramExecutables
global prefs_HelperWindowProgramExecutables
global prefs_HelperWindowProgramTitles
global prefs_Wordlist

;g_PrefsFile is global so it works in Settings.ahk
global g_PrefsFile
global g_PrefsSections
global g_XY

g_PrefsFile = %A_ScriptDir%\Preferences.ini
Defaults = %A_ScriptDir%\Defaults.ini
LastState = %A_ScriptDir%\LastState.ini
global PathToUserFiles
global Wordlist
global WordlistFileName
global Default_Wordlist

PathToUserFiles = %A_MyDocuments%\TypingAid
IfNotExist, %PathToUserFiles%
FileCreateDir, %PathToUserFiles%

Default_Wordlist = %PathToUserFiles%\wordlist.txt


g_PrefsFile = %PathToUserFiles%\Preferences.ini
Defaults = %PathToUserFiles%\Defaults.ini
LastState = %PathToUserFiles%\LastState.ini

MaybeFixFileEncoding(g_PrefsFile,"UTF-16")
MaybeFixFileEncoding(Defaults,"UTF-16")
Expand Down Expand Up @@ -148,6 +162,7 @@ ReadPreferences(RestoreDefaults = false,RestorePreferences = false)
dft_HelperWindowProgramExecutables,prefs_HelperWindowProgramExecutables,HelperWindow,%SpaceVar%
dft_HelperWindowProgramTitles,prefs_HelperWindowProgramTitles,HelperWindow,%SpaceVar%
,XY,HelperWindow,%SpaceVar%
dft_Wordlist,prefs_Wordlist,Settings,%Default_Wordlist%
)

g_PrefsSections := Object()
Expand Down Expand Up @@ -191,6 +206,9 @@ ReadPreferences(RestoreDefaults = false,RestorePreferences = false)
}
}

wordlist = %prefs_wordlist%
SplitPath, wordlist, wordlistname

ValidatePreferences()
ParseTerminatingCharacters()

Expand Down Expand Up @@ -218,6 +236,8 @@ ReadPreferences(RestoreDefaults = false,RestorePreferences = false)
}

ConstructHelpStrings()



Return
}
Expand All @@ -233,6 +253,16 @@ ValidatePreferences()
global dft_ListBoxCharacterWidth, dft_ListBoxFontFixed, dft_ListBoxFontSize, dft_ListBoxMaxWidth, dft_ListBoxOffset, dft_ListBoxOpacity, dft_ListBoxRows
global prefs_NoBackSpace, prefs_NumPresses, prefs_SendMethod, prefs_ShowLearnedFirst, prefs_SuppressMatchingWord, prefs_TerminatingCharacters
global dft_NoBackSpace, dft_NumPresses, dft_SendMethod, dft_ShowLearnedFirst, dft_SuppressMatchingWord, dft_TerminatingCharacters
global dft_Wordlist, prefs_Wordlist

IfNotExist, %prefs_Wordlist%
{
IfNotEqual, prefs_Wordlist, %dft_Wordlist%
{
MsgBox, The file selected for words %prefs_wordlist% can't be accessed, reverting to default
prefs_Wordlist := dft_Wordlist
}
}

if prefs_Length is not integer
{
Expand Down Expand Up @@ -308,7 +338,7 @@ ValidatePreferences()
if prefs_SuppressMatchingWord not in On,Off
prefs_SuppressMatchingWord := dft_SuppressMatchingWord

if prefs_SendMethod not in 1,2,3,1C,2C,3C,4C
if prefs_SendMethod not in 1,2,3,1C,2C,3C,4C,4
prefs_SendMethod := dft_SendMethod

;SendPlay does not work when not running as Administrator, switch to SendInput
Expand Down Expand Up @@ -500,6 +530,7 @@ SavePreferences(PrefsToSave)
Return
}


ConstructHelpStrings()
{
global
Expand Down
13 changes: 13 additions & 0 deletions Source/Includes/Sending.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,19 @@ SendFull(SendValue,ForceBackspace=false)
Return
}

IfEqual, prefs_SendMethod, 4
{
if (BackSpaceWord)
{
sending = {BS %BackSpaceLen%}%SendValue%
} Else {
sending = %SendValue%
}
SendEvent, %sending% ; First do the backspaces, Then send word (Raw because we want the string exactly as in wordlist.txt)
Return
}


ClipboardSave := ClipboardAll
Clipboard =
Clipboard := SendValue
Expand Down
31 changes: 29 additions & 2 deletions Source/Includes/Settings.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ ConstructGui()
; Must be global for colors to function, colors will not function if static
global Menu_VisitForum

; Adding path to wordlist
global prefs_Wordlist


Menu_CaseCorrection=
Menu_ArrowKeyMethodOptionsText=

Expand Down Expand Up @@ -216,8 +220,8 @@ ConstructGui()


Gui, MenuGui:Add, GroupBox, x%MenuGroup3of3BoxX% y%MenuRowY% w%MenuThreeColGroupWidth% h%MenuRowHeight% , Send Method
Menu_SendMethodOptionsText=1 - Default (Type)|2 - Fast (Type)|3 - Slow (Type)|4 - Default (Paste)|5 - Fast (Paste)|6 - Slow (Paste)|7 - Alternate method
Menu_SendMethodOptionsCode=1|2|3|1C|2C|3C|4C
Menu_SendMethodOptionsText=1 - Default (Type)|2 - Fast (Type)|3 - Slow (Type)|4 - Default (Paste)|5 - Fast (Paste)|6 - Slow (Paste)|7 - Alternate method|8 - Raw Off
Menu_SendMethodOptionsCode=1|2|3|1C|2C|3C|4C|4
Loop, parse, Menu_SendMethodOptionsCode, |
{
If (prefs_SendMethod = A_LoopField)
Expand Down Expand Up @@ -271,6 +275,19 @@ ConstructGui()
Gui, MenuGui:Font, cGreen
Gui, MenuGui:Add, Text, x%MenuGroup3of3HelpX% y%MenuRowHelpY% vhelpinfo_AutoSpace gHelpMe, %MenuGuiHelpIcon%
Gui, MenuGui:Font, cBlack

MenuRowY := MenuRowY + MenuRowHeight + MenuSeparatorY
MenuRowHelpY := MenuRowY - MenuHelpIndentY
MenuRowEditY := MenuRowY + MenuEditIndentY

;WordlistFile

Gui, MenuGui:Add, GroupBox, x%MenuGroup1BoxX% y%MenuRowY% w%MenuOneColGroupWidth% h%MenuRowHeight% , Wordlist to load words from
Gui, MenuGui:Add, Edit, x%MenuGroup1EditX% y%MenuRowEditY% w%MenuOneColEditWidthEdit% r1 vprefs_Wordlist gEditValue, %prefs_Wordlist%
Gui, MenuGui:Add, Button, x%MenuOneColEditButton% yp w130 gSetWordlistFile, Edit
Gui, MenuGui:Font, cGreen
;Gui, MenuGui:Add, Text, x%MenuGroup1of1HelpX% y%MenuRowHelpY% vhelpinfo_HelperWindowProgramExecutables gHelpMe, %MenuGuiHelpIcon%
Gui, MenuGui:Font, cBlack

Gui, MenuGui:Tab, 2 ; listbox ---------------------------------------------------------

Expand Down Expand Up @@ -679,6 +696,16 @@ SetHelpProcess:
GetList("prefs_HelperWindowProgramExecutables",1)
Return

SetWordlistFile:
FileSelectFile, SelectedFile, 3, , Open a file, Text Documents (*.txt)
if SelectedFile =
Return
else
GuiControl, Text, prefs_Wordlist, %SelectedFile%
Menu_ValueChanged := true
Menu_ChangedPrefs["prefs_Wordlist"] := prefs_Wordlist
Return

GetList(TitleType,GetExe)
{
global Menu_GetExe
Expand Down
31 changes: 16 additions & 15 deletions Source/Includes/Wordlist.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ ReadWordList()
;mark the wordlist as not done
g_WordListDone = 0

WordlistFileName = wordlist.txt

Wordlist = %A_ScriptDir%\%WordlistFileName%
WordlistLearned = %A_ScriptDir%\WordlistLearned.txt
global PathToUserFiles
global Wordlist
global WordlistFileName

WordlistLearned = %PathToUserFiles%\WordlistLearned.txt

MaybeFixFileEncoding(Wordlist,"UTF-8")
MaybeFixFileEncoding(WordlistLearned,"UTF-8")

g_WordListDB := DBA.DataBaseFactory.OpenDataBase("SQLite", A_ScriptDir . "\WordlistLearned.db" )
g_WordListDB := DBA.DataBaseFactory.OpenDataBase("SQLite", PathToUserFiles . "\WordlistLearned.db" )

if !g_WordListDB
{
msgbox Problem opening database '%A_ScriptDir%\WordlistLearned.db' - fatal error...
msgbox Problem opening database '%PathToUserFiles%\WordlistLearned.db' - fatal error...
exitapp
}

Expand Down Expand Up @@ -417,23 +418,23 @@ MaybeUpdateWordlist()
{
StringTrimRight, TempWordList, TempWordList, 2

FileDelete, %A_ScriptDir%\Temp_WordlistLearned.txt
FileAppendDispatch(TempWordList, A_ScriptDir . "\Temp_WordlistLearned.txt")
FileCopy, %A_ScriptDir%\Temp_WordlistLearned.txt, %A_ScriptDir%\WordlistLearned.txt, 1
FileDelete, %A_ScriptDir%\Temp_WordlistLearned.txt
FileDelete, %PathToUserFiles%\Temp_WordlistLearned.txt
FileAppendDispatch(TempWordList, PathToUserFiles . "\Temp_WordlistLearned.txt")
FileCopy, %PathToUserFiles%\Temp_WordlistLearned.txt, %PathToUserFiles%\WordlistLearned.txt, 1
FileDelete, %PathToUserFiles%\Temp_WordlistLearned.txt

; Convert the Old Wordlist file to not have ;LEARNEDWORDS;
IfEqual, g_LegacyLearnedWords, 1
{
TempWordList =
FileRead, ParseWords, %A_ScriptDir%\Wordlist.txt
FileRead, ParseWords, %PathToUserFiles%\Wordlist.txt
LearnedWordsPos := InStr(ParseWords, "`;LEARNEDWORDS`;",true,1) ;Check for Learned Words
TempWordList := SubStr(ParseWords, 1, LearnedwordsPos - 1) ;Grab all non-learned words out of list
ParseWords =
FileDelete, %A_ScriptDir%\Temp_Wordlist.txt
FileAppendDispatch(TempWordList, A_ScriptDir . "\Temp_Wordlist.txt")
FileCopy, %A_ScriptDir%\Temp_Wordlist.txt, %A_ScriptDir%\Wordlist.txt, 1
FileDelete, %A_ScriptDir%\Temp_Wordlist.txt
FileDelete, %PathToUserFiles%\Temp_Wordlist.txt
FileAppendDispatch(TempWordList, PathToUserFiles . "\Temp_Wordlist.txt")
FileCopy, %PathToUserFiles%\Temp_Wordlist.txt, %PathToUserFiles%\Wordlist.txt, 1
FileDelete, %PathToUserFiles%\Temp_Wordlist.txt
}
}
}
Expand Down