Skip to content

Commit

Permalink
- Lots of small fixes, including GUI fixes for instant replacements
Browse files Browse the repository at this point in the history
- Fix so windowsget thread no longer needed... instead, disable=1 with gui thread when necessary for preferences, no longer needed to monitor switching windows
- Implemented per-bundle on-the-fly newkeys
- add instant to the printable cheatsheet triggers
- More adds/fixes for instant replacement vs. triggers
- More bug fixes for the new method for sending modifiers
  • Loading branch information
adam committed Oct 16, 2007
1 parent 882c883 commit 8d1972c
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 78 deletions.
4 changes: 2 additions & 2 deletions TODO.txt
Expand Up @@ -11,9 +11,9 @@ Features/fixes for 0.6 release:
x Set focus on Preferences so On-the-fly shortcut doesn't immediately blank out to "None"

- Features:
- Define custom hotkey
- Define custom hotkey or implement "no trigger" replacements
- Integrate AHK autocorrect script
(Unless Dustin's new trigger method works, consider compiling autocorrect to .exe, storing it in resources, hiding from systray, and running separately when enabled, killing when disabled. The script doesn't play nice with the SC77 special char trigger)
- Can select bundle when creating new on-the-fly hotstring
x Disable via global hotkey?

Features/fixes for 0.5 release:
Expand Down
35 changes: 24 additions & 11 deletions includes/GUI/management_GUI.ahk
Expand Up @@ -22,16 +22,19 @@ GoSub,GetFileList
Bundles =
Loop,bundles\*,2
{
Bundles = %Bundles%|%A_LoopFileName%
thisBundle = %A_LoopFileName%
if (thisBundle != "Autocorrect")
{
Bundles = %Bundles%|%A_LoopFileName%
; Loop,bundles\%A_LoopFileName%\replacements\*.txt
; {
; thisReplacement:=Dehexify(A_LoopFileName)
; thisBundle = %thisBundle%%thisReplacement%|
; }
StringReplace, thisBundle, thisBundle, .txt,,All
StringReplace, thisBundle, thisBundle, %A_LoopFileName%,,
%A_LoopFileName% = %thisBundle%
StringReplace, thisBundle, thisBundle, .txt,,All
StringReplace, thisBundle, thisBundle, %A_LoopFileName%,,
%A_LoopFileName% = %thisBundle%
}
}
StringReplace, FileList, FileList, .txt,,All
StringTrimLeft,Bundles,Bundles,1
Expand All @@ -48,19 +51,22 @@ Gui,2: Add, DropDownList, Section ys vTextOrScript, Text||Script
Gui,2: Font, s12, Arial
Gui,2: Add, Edit, r12 W460 xs vFullText
Gui,2: Add, Text, xs,Trigger:
Gui,2: Add, Checkbox, vEnterCbox yp xp+65, Enter
Gui,2: Add, Checkbox, vTabCbox yp xp+65, Tab
Gui,2: Add, Checkbox, vSpaceCbox yp xp+60, Space
Gui,2: Add, Checkbox, gDisableChecks vEnterCbox yp xp+65, Enter
Gui,2: Add, Checkbox, gDisableChecks vTabCbox yp xp+65, Tab
Gui,2: Add, Checkbox, gDisableChecks vSpaceCbox yp xp+60, Space
Gui,2: Add, Checkbox, gDisableChecks vNoTrigCbox yp xp+80, Instant
Gui,2: Font, s8, Arial
Gui,2: Add,Button, w80 GPButtonSave xs+375 yp, &Save
IniRead,bundleCheck,texter.ini,Bundles,Default
Gui,2: Add, Checkbox, Checked%bundleCheck% vbundleCheck gToggleBundle xs+400 yp+50,Enabled
Gui,2: Add, Button, w80 Default GPButtonOK xs+290 yp+30,&OK
Gui,2: Add, Button, w80 xp+90 GPButtonCancel, &Cancel
Gui,2: Show, , Texter Management
GuiControl,2: Focus, Choice
Hotkey,IfWinActive, Texter Management
Hotkey,!p,Preferences
Hotkey,delete,Delete
;Hotkey,delete,Delete
Hotkey,^s,PButtonSave
Hotkey,IfWinActive
return

Expand Down Expand Up @@ -112,7 +118,7 @@ Gosub,BuildActive
return

ADD:
EnableTriggers(false)
;EnableTriggers(false)
GoSub,Newkey
IfWinExist,Add new hotstring...
{
Expand All @@ -122,7 +128,7 @@ IfWinExist,Add new hotstring...
GoSub,ListBundle
StringReplace, CurrentBundle, CurrentBundle,|%RString%|,|%RString%||
GuiControl,,Choice,|%CurrentBundle%
EnableTriggers(true)
;EnableTriggers(true)
GoSub,ShowString
return

Expand Down Expand Up @@ -165,6 +171,7 @@ else
FileRead,enter,%ReadFrom%bank\enter.csv
FileRead,tab,%ReadFrom%bank\tab.csv
FileRead,space,%ReadFrom%bank\space.csv
FileRead,notrig,%ReadFrom%bank\notrig.csv

if ActiveChoice in %enter%
{
Expand All @@ -184,6 +191,12 @@ if ActiveChoice in %space%
}
else
GuiControl,,SpaceCbox,0
if ActiveChoice in %notrig%
{
GuiControl,,NoTrigCbox,1
}
else
GuiControl,,NoTrigCbox,0
FileRead, Text, %ReadFrom%replacements\%ActiveChoice%.txt
IfInString,Text,::scr::
{
Expand All @@ -205,7 +218,7 @@ If Choice <>
SaveToDir = Bundles\%CurrentBundle%\
else
SaveToDir =
PSaveSuccessful := SaveHotstring(Choice, FullText, IsScript, SaveToDir, SpaceCbox, TabCbox, EnterCbox)
PSaveSuccessful := SaveHotstring(Choice, FullText, IsScript, SaveToDir, SpaceCbox, TabCbox, EnterCbox, NoTrigCbox)
}
else
{
Expand Down
37 changes: 31 additions & 6 deletions includes/GUI/newkey_GUI.ahk
@@ -1,7 +1,27 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Implementation and GUI for on-the-fly creation ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
NEWKEY:
Bundles=
Loop,bundles\*,2
{
thisBundle = %A_LoopFileName%
if (thisBundle != "Autocorrect")
{
Bundles = %Bundles%%A_LoopFileName%|
StringReplace, thisBundle, thisBundle, .txt,,All
StringReplace, thisBundle, thisBundle, %A_LoopFileName%,,
%A_LoopFileName% = %thisBundle%
}
}
if A_GuiControl = + ;;;; MAYBE CHANGE THIS TO IfWinExist,Texter Management
{
GuiControlGet,CurrentBundle,,BundleTabs
StringReplace,Bundles,Bundles,%CurrentBundle%,$
StringSplit,Bundles,Bundles,$
; MsgBox,%Bundles1% %Bundles2%
; msgbox %currentbundle%
; msgbox,%bundles2%
Bundles = %Bundles1%%CurrentBundle%|%Bundles2%
}
else
CurrentBundle =
if (CurrentBundle != "") and (CurrentBundle != "Default")
Expand All @@ -12,20 +32,24 @@ Gui,1: Destroy
IniRead,EnterBox,texter.ini,Triggers,Enter
IniRead,TabBox,texter.ini,Triggers,Tab
IniRead,SpaceBox,texter.ini,Triggers,Space
IniRead,NoTrigBox,texter.ini,Triggers,NoTrig
Gui,1: font, s12, Arial
Gui,1: +owner2 +AlwaysOnTop -SysMenu +ToolWindow ;suppresses taskbar button, always on top, removes minimize/close
Gui,1: Add, Text,x10 y20, Hotstring:
Gui,1: Add, Edit, x13 y45 r1 W65 vRString,
Gui,1: Add, Edit, x100 y45 r4 W395 vFullText, Enter your replacement text here...
Gui,1: Add, Text,x115,Trigger:
Gui,1: Add, Checkbox, vEnterCbox yp x175 Checked%EnterBox%, Enter
Gui,1: Add, Checkbox, vTabCbox yp x242 Checked%TabBox%, Tab
Gui,1: Add, Checkbox, vSpaceCbox yp x305 Checked%SpaceBox%, Space
Gui,1: Add, Checkbox, gDisableChecks vEnterCbox yp x175 Checked%EnterBox%, Enter
Gui,1: Add, Checkbox, gDisableChecks vTabCbox yp x242 Checked%TabBox%, Tab
Gui,1: Add, Checkbox, gDisableChecks vSpaceCbox yp x305 Checked%SpaceBox%, Space
Gui,1: Add, Checkbox, gDisableChecks vNoTrigCbox yp x388 Checked%NoTrigBox%, Instant
Gui,1: font, s8, Arial
Gui,1: Add, Button,w80 x320 default,&OK
Gui,1: Add, Button,w80 xp+90 GButtonCancel,&Cancel
Gui,1: font, s12, Arial
Gui,1: Add,DropDownList,x100 y15 vTextOrScript, Text||Script
Gui,1: Add,DropDownList,x100 y15 w100 vTextOrScript, Text||Script
Gui,1: Add, Text,x315 y19, Bundle:
Gui,1: Add,DropDownList,x370 y15 w125 vBundle,Default||%Bundles%
Gui,1: Add,Picture,x0 y105,%TexterPNG%
Gui 2:+Disabled
Gui,1: Show, W500 H200,Add new hotstring...
Expand All @@ -41,14 +65,15 @@ ButtonOK:
Gui,1: Submit, NoHide
Gui 1:+OwnDialogs
hexRString:=hexify(RString)
if (Bundle != "") and (Bundle != "Default")
AddToDir = Bundles\%Bundle%\
IfExist, %A_ScriptDir%\%AddToDir%replacements\%hexRString%.txt
{
MsgBox,262144,Hotstring already exists, A replacement with the text %RString% already exists. Would you like to try again?
return
}
IsScript := (TextOrScript == "Script")

if SaveHotstring(RString, FullText, IsScript, AddToDir, SpaceCbox, TabCbox, EnterCbox)
if SaveHotstring(RString, FullText, IsScript, AddToDir, SpaceCbox, TabCbox, EnterCbox, NoTrigCbox)
{
Gui 2:-Disabled
Gui,1: Submit
Expand Down
3 changes: 3 additions & 0 deletions includes/GUI/preferences_GUI.ahk
Expand Up @@ -45,6 +45,9 @@ Gui,3: Add,Text,x25 y100,Hours saved: %time_saved% (assuming 400 cha
Gui 2:+Disabled
Gui,3: Show,,Texter Preferences
GuiControl,3: Focus, Tabs
Disable=1
WinWaitClose, Texter Preferences
Disable=
Return

SETTINGSOK:
Expand Down
2 changes: 1 addition & 1 deletion includes/functions/InsSpecKeys.ahk
@@ -1,4 +1,4 @@
#IfWinActive,Texter Management
#IfWinActive, ahk_class AutoHotkeyGUI
Ins & LWin::
Ins & Rwin::
SendRaw,#
Expand Down
4 changes: 4 additions & 0 deletions includes/functions/addtobank.ahk
Expand Up @@ -2,6 +2,10 @@ AddToBank(HotString, Bundle, Trigger)
{
;HotString:=Dehexify(HotString)
BankFile = %Bundle%bank\%trigger%.csv
IfNotExist %BankFile%
{
FileAppend,, %BankFile%
}
FileRead, Bank, %BankFile%
if HotString not in %Bank%
{
Expand Down
61 changes: 36 additions & 25 deletions includes/functions/buildactive.ahk
@@ -1,7 +1,5 @@
BuildActive:
activeBundles =
FileDelete,Active\replacements\*
FileDelete,Active\bank\*
Loop,bundles\*,2
{
IniRead,activeCheck,texter.ini,Bundles,%A_LoopFileName%
Expand All @@ -11,35 +9,49 @@ Loop,bundles\*,2
IniRead,activeCheck,texter.ini,Bundles,Default
if activeCheck = 1
activeBundles = %activeBundles%Default
Loop,Parse,activeBundles,CSV
if skipfirst <>
{
; MsgBox,%A_LoopField%
if A_LoopField = Default
FileDelete,Active\replacements\*
FileDelete,Active\bank\*
Loop,Parse,activeBundles,CSV
{
FileCopy,replacements\*.txt,Active\replacements
FileRead,tab,bank\tab.csv
FileAppend,%tab%,Active\bank\tab.csv
FileRead,space,bank\space.csv
FileAppend,%space%,Active\bank\space.csv
FileRead,enter,bank\enter.csv
FileAppend,%enter%,Active\bank\enter.csv
if A_LoopField = Default
{
FileCopy,replacements\*.txt,Active\replacements
FileRead,tab,bank\tab.csv
FileAppend,%tab%,Active\bank\tab.csv
FileRead,space,bank\space.csv
FileAppend,%space%,Active\bank\space.csv
FileRead,enter,bank\enter.csv
FileAppend,%enter%,Active\bank\enter.csv
FileRead,notrig,bank\notrig.csv
FileAppend,%notrig%,Active\bank\notrig.csv
}
; else if A_LoopField = Autocorrect
; {
;
; }
else
{
FileCopy,Bundles\%A_LoopField%\replacements\*.txt,active\replacements
FileRead,tab,Bundles\%A_LoopField%\bank\tab.csv
FileAppend,%tab%,active\bank\tab.csv
FileRead,space,Bundles\%A_LoopField%\bank\space.csv
FileAppend,%space%,active\bank\space.csv
FileRead,enter,Bundles\%A_LoopField%\bank\enter.csv
FileAppend,%enter%,active\bank\enter.csv
FileRead,notrig,Bundles\%A_LoopField%\bank\notrig.csv
FileAppend,%notrig%,active\bank\notrig.csv
}
; IfExist active\replacements\wc.txt
; MsgBox,%A_LoopFileName% put me here
}
else
{
FileCopy,Bundles\%A_LoopField%\replacements\*.txt,active\replacements
FileRead,tab,Bundles\%A_LoopField%\bank\tab.csv
FileAppend,%tab%,active\bank\tab.csv
FileRead,space,Bundles\%A_LoopField%\bank\space.csv
FileAppend,%space%,active\bank\space.csv
FileRead,enter,Bundles\%A_LoopField%\bank\enter.csv
FileAppend,%enter%,active\bank\enter.csv
}
; IfExist active\replacements\wc.txt
; MsgBox,%A_LoopFileName% put me here
}
skipfirst=1
FileRead, EnterKeys, %A_WorkingDir%\Active\bank\enter.csv
FileRead, TabKeys, %A_WorkingDir%\Active\bank\tab.csv
FileRead, SpaceKeys, %A_WorkingDir%\Active\bank\space.csv
FileRead, NoTrigKeys, %A_WorkingDir%\Active\bank\notrig.csv
ActiveList =
HotStrings= | ; added this variable for Dustin's new trigger method... need to sometime check and see if ActiveList is necessary
Loop, Active\replacements\*.txt
Expand All @@ -49,5 +61,4 @@ Loop, Active\replacements\*.txt
HotStrings = %HotStrings%%This_HotString%|
}
StringReplace, ActiveList, ActiveList, .txt,,All

return
3 changes: 3 additions & 0 deletions includes/functions/bundles.ahk
Expand Up @@ -145,6 +145,7 @@ if ErrorLevel = 0
Gui,8: Add, Checkbox, vEnterCbox x30, Enter
Gui,8: Add, Checkbox, vTabCbox yp xp+65, Tab
Gui,8: Add, Checkbox, vSpaceCbox yp xp+60, Space
Gui,8: Add, Checkbox, vNoTrigCbox yp xp+60, Instant
Gui,8: Add,Button, x180 Default w80 GCreateBank,&OK
Gui, 8: Show,,Set default triggers
}
Expand All @@ -159,6 +160,8 @@ if TabCbox = 1
FileAppend,%bundleCollection%,bundles\%BundleName%\bank\tab.csv
if SpaceCbox = 1
FileAppend,%bundleCollection%,bundles\%BundleName%\bank\space.csv
if NoTrigCbox = 1
FileAppend,%bundleCollection%,bundles\%BundleName%\bank\notrig.csv
MsgBox,4,Enable %BundleName% bundle?,Would you like to enable the %BundleName% bundle?
IfMsgBox,Yes
{
Expand Down
6 changes: 6 additions & 0 deletions includes/functions/printablelist.ahk
Expand Up @@ -11,12 +11,15 @@ Loop, replacements\*.txt
FileRead, entertrig, bank\enter.csv
FileRead, tabtrig, bank\tab.csv
FileRead, spacetrig, bank\space.csv
FileRead, notrig, bank\notrig.csv
If hs in %entertrig%
trig = Enter
If hs in %tabtrig%
trig = %trig% Tab
If hs in %spacetrig%
trig = %trig% Space
If hs in %notrig%
trig = %trig% Instant
StringReplace, rp, rp, <,&lt;,All
StringReplace, rp, rp, >,&gt;,All
hs := DeHexify(hs)
Expand All @@ -36,12 +39,15 @@ Loop,bundles\*,2
FileRead, entertrig, bundles\%thisBundle%\bank\enter.csv
FileRead, tabtrig, bundles\%thisBundle%\bank\tab.csv
FileRead, spacetrig, bundles\%thisBundle%\bank\space.csv
FileRead, notrig, bundles\%thisBundle%\bank\notrig.csv
If hs in %entertrig%
trig = Enter
If hs in %tabtrig%
trig = %trig% Tab
If hs in %spacetrig%
trig = %trig% Space
If hs in %notrig%
trig = %trig% Instant
StringReplace, rp, rp, <,&lt;,All
StringReplace, rp, rp, >,&gt;,All
hs := DeHexify(hs)
Expand Down
17 changes: 14 additions & 3 deletions includes/functions/savehotstring.ahk
@@ -1,16 +1,18 @@
SaveHotstring(HotString, Replacement, IsScript, Bundle, SpaceIsTrigger, TabIsTrigger, EnterIsTrigger)
SaveHotstring(HotString, Replacement, IsScript, Bundle, SpaceIsTrigger, TabIsTrigger, EnterIsTrigger, NoTrigger)
{
global EnterCSV
global TabCSV
global SpaceCSV
global NoTrigCSV
global EnterKeys
global TabKeys
global SpaceKeys
global NoTrigKeys
HotString:=Hexify(HotString)
successful := false
if (!EnterIsTrigger AND !TabIsTrigger AND !SpaceIsTrigger)
if (!EnterIsTrigger AND !TabIsTrigger AND !SpaceIsTrigger AND !NoTrigger)
{
MsgBox,262144,Choose a trigger,You need to choose a trigger in order to save a hotstring replacement.
MsgBox,262144,Choose a trigger,You need to choose a trigger method in order to save a hotstring replacement.
}
else if (HotString <> "" AND Replacement <> "")
{
Expand All @@ -23,6 +25,7 @@ global SpaceKeys
IniWrite,%SpaceIsTrigger%,texter.ini,Triggers,Space
IniWrite,%TabIsTrigger%,texter.ini,Triggers,Tab
IniWrite,%EnterIsTrigger%,texter.ini,Triggers,Enter
IniWrite,%NoTrigger%,texter.ini,Triggers,NoTrig

FileDelete, %A_ScriptDir%\%Bundle%replacements\%HotString%.txt
FileAppend,%Replacement%,%A_ScriptDir%\%Bundle%replacements\%HotString%.txt
Expand Down Expand Up @@ -51,6 +54,14 @@ global SpaceKeys
{
DelFromBank(HotString, Bundle, "space")
}
if NoTrigger
{
AddToBank(HotString, Bundle, "notrig")
}
else
{
DelFromBank(HotString, Bundle, "notrig")
}
}
GoSub,BuildActive
return successful
Expand Down

0 comments on commit 8d1972c

Please sign in to comment.