-
Notifications
You must be signed in to change notification settings - Fork 84
/
management_GUI.ahk
228 lines (215 loc) · 6.04 KB
/
management_GUI.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Implementation and GUI for management ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MAINWINTOOLBAR:
Menu, ToolsMenu, Add, P&references..., Preferences
Menu, MgmtMenuBar, Add, &Tools, :ToolsMenu
Menu, BundlesMenu, Add, &Export, Export
Menu, BundlesMenu, Add, &Import, Import
Menu, BundlesMenu, Add, &Add, AddBundle
Menu, BundlesMenu, Add, &Remove, DeleteBundle
Menu, MgmtMenuBar, Add, &Bundles, :BundlesMenu
Menu, HelpMenu, Add, &Basic Use, BasicUse
Menu, HelpMenu, Add, Ad&vanced Use, Scripting
Menu, HelpMenu, Add, &Homepage, Homepage
Menu, HelpMenu, Add, &About..., About
Menu, MgmtMenuBar, Add, &Help, :HelpMenu
Gui,2: Menu, MgmtMenuBar
return
MANAGE:
Gui,2: Destroy
Gosub,MAINWINTOOLBAR
GoSub,GetFileList
Bundles =
Loop,bundles\*,2
{
Bundles = %Bundles%|%A_LoopFileName%
thisBundle = %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, FileList, FileList, .txt,,All
StringTrimLeft,Bundles,Bundles,1
Gui,2: Default
Gui,2: Font, s12, Arial
Gui,2: Add,Tab,x5 y5 h390 w597 vBundleTabs gListBundle,Default|%Bundles% ;;;;;; START ADDING BUNDLES
Gui,2: Add, Text, Section,
Gui,2: Tab ;;; Every control after this point belongs to no individual tab
Gui,2: Add, Text,ys xs,Hotstring:
Gui,2: Add, ListBox, xs r15 W100 vChoice gShowString Sort, %FileList%
Gui,2: Add, Button, w35 xs+10 GAdd,+
Gui,2: Add, Button, w35 xp+40 GDelete,-
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: 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
Hotkey,IfWinActive, Texter Management
Hotkey,!p,Preferences
Hotkey,delete,Delete
Hotkey,IfWinActive
return
ListBundle:
if A_GuiControl = BundleTabs
GuiControlGet,CurrentBundle,2:,BundleTabs
IniRead,bundleCheck,texter.ini,Bundles,%CurrentBundle%
GuiControl,2:,Choice,|
Loop,bundles\*,2
{
Bundles = %Bundles%|%A_LoopFileName%
thisBundle = %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%
}
;if A_GuiControl = Tab
; GuiControl,,Choice,|
;else
; GuiControl,,Choice,%RString%||
GuiControl,2:,FullText,
GuiControl,2:,EnterCbox,0
GuiControl,2:,TabCbox,0
GuiControl,2:,SpaceCbox,0
GuiControl,2:,bundleCheck,%bundleCheck%
if CurrentBundle = Default
{
Gosub,GetFileList
CurrentBundle = %FileList%
GuiControl,,Choice,%CurrentBundle%
}
else
{
StringTrimLeft,CurrentBundle,%CurrentBundle%,0
GuiControl,2:,Choice,%CurrentBundle%
}
return
ToggleBundle:
GuiControlGet,CurrentBundle,,BundleTabs
GuiControlGet,bundleCheck,,bundleCheck
IniWrite,%bundleCheck%,texter.ini,Bundles,%CurrentBundle%
Gosub,BuildActive
return
ADD:
EnableTriggers(false)
GoSub,Newkey
IfWinExist,Add new hotstring...
{
WinWaitClose,Add new hotstring...,,
}
;GoSub,GetFileList
GoSub,ListBundle
StringReplace, CurrentBundle, CurrentBundle,|%RString%|,|%RString%||
GuiControl,,Choice,|%CurrentBundle%
EnableTriggers(true)
GoSub,ShowString
return
DELETE:
Gui 2:+OwnDialogs
GuiControlGet,ActiveChoice,,Choice
GuiControlGet,CurrentBundle,,BundleTabs
if (CurrentBundle != "") and (CurrentBundle != "Default")
RemoveFromDir = Bundles\%CurrentBundle%\
else
RemoveFromDir =
MsgBox,1,Confirm Delete,Are you sure you want to delete this hotstring: %ActiveChoice%
IfMsgBox, OK
{
ActiveChoice:=Hexify(ActiveChoice)
FileDelete,%A_ScriptDir%\%RemoveFromDir%replacements\%ActiveChoice%.txt
DelFromBank(ActiveChoice, RemoveFromDir, "enter")
DelFromBank(ActiveChoice, RemoveFromDir, "tab")
DelFromBank(ActiveChoice, RemoveFromDir, "space")
GoSub,ListBundle
Gosub,BuildActive
GuiControl,,Choice,|%CurrentBundle%
GuiControl,,FullText,
GuiControl,,EnterCbox,0
GuiControl,,TabCbox,0
GuiControl,,SpaceCbox,0
}
return
ShowString:
GuiControlGet,ActiveChoice,,Choice
ActiveChoice:=Hexify(ActiveChoice)
GuiControlGet,CurrentBundle,,BundleTabs
if CurrentBundle = Default
ReadFrom =
else
ReadFrom = bundles\%CurrentBundle%\
FileRead,enter,%ReadFrom%bank\enter.csv
FileRead,tab,%ReadFrom%bank\tab.csv
FileRead,space,%ReadFrom%bank\space.csv
if ActiveChoice in %enter%
{
GuiControl,,EnterCbox,1
}
else
GuiControl,,EnterCbox,0
if ActiveChoice in %tab%
{
GuiControl,,TabCbox,1
}
else
GuiControl,,TabCbox,0
if ActiveChoice in %space%
{
GuiControl,,SpaceCbox,1
}
else
GuiControl,,SpaceCbox,0
FileRead, Text, %ReadFrom%replacements\%ActiveChoice%.txt
IfInString,Text,::scr::
{
GuiControl,,TextOrScript,|Text|Script||
StringReplace,Text,Text,::scr::,,
}
else
GuiControl,,TextOrScript,|Text||Script
GuiControl,,FullText,%Text%
return
PButtonSave:
Gui,2: Submit, NoHide
IsScript := (TextOrScript == "Script")
If Choice <>
{
if (CurrentBundle != "") and (CurrentBundle != "Default")
SaveToDir = Bundles\%CurrentBundle%\
else
SaveToDir =
PSaveSuccessful := SaveHotstring(Choice, FullText, IsScript, SaveToDir, SpaceCbox, TabCbox, EnterCbox)
}
else
{
PSaveSuccessful = true
}
return
2GuiEscape:
PButtonCancel:
Gui,2: Destroy
return
PButtonOK:
Gosub,PButtonSave
if PSaveSuccessful
{
Gui,2: Submit
Gui,2: Destroy
}
return