-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGui.ahk
416 lines (319 loc) · 11 KB
/
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%
; Variables
;
;
title := "Macro Controller"
fileName := "data"
file := FileOpen(fileName, "rw`n")
keyboardName := "Main.ahk"
keyboardLen := 0
keyboard := FileOpen(keyboardName, "rw`n")
file.Seek(0, Origin := 0)
mainX := file.ReadLine()
mainY := file.ReadLine()
StringReplace, mainX, mainX, `n,,,A
StringReplace, mainY, mainY, `n,,,A
width := 1000
height := 600
buttonSize := 50
key := "`;H"
showKeyboard := 1
defaultText := "Run`, Notepad`nSleep 100`nSend`, So long and thanks for all the fish"
mainText := "Hello and welcome"
; GUI Layout
;
;
Gui, Primary:Color, White
file.Seek(StrLen(mainX)+2)
tempVar := file.ReadLine()
Gui, Primary:Add, Text,, %mainText%
Gui, Primary:Add, Button, x10 y+ w90 h100, Page 1
Gui, Primary:Add, Button, x10 y+ w90 h100 gPage2, Page 2
; Adding The Keyboard
Gui, Primary:Add, GroupBox, y10 Section w770 h280, Keyboard
; First Row Keys
Gui, Primary:Add, Button, xs10 ys20 w%buttonSize% h%buttonSize% gOpen_Menu, ``
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, 1
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, 2
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, 3
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, 4
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, 5
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, 6
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, 7
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, 8
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, 9
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, 0
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, -
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, +
modSize := buttonSize * 2
Gui, Primary:Add, Button, x+ w%modSize% h%buttonSize% gOpen_Menu_2, _Backspace
; Second Row Keys
modSize := buttonSize * 1.5
Gui, Primary:Add, Button, xs10 y+ w%modSize% h%buttonSize% gOpen_Menu_2, _Tab
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, Q
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, W
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, E
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, R
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, T
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, Y
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, U
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, I
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, O
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, P
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, [
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, ]
modSize := buttonSize * 1.5
Gui, Primary:Add, Button, x+ w%modSize% h%buttonSize% gOpen_Menu, \
; Third Row Keys
modSize := buttonSize * 1.8
Gui, Primary:Add, Button, xs10 y+ w%modSize% h%buttonSize% gOpen_Menu_2 vCapsLock, _CapsLock
GuiControl, Disable, CapsLock
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, A
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, S
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, D
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, F
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, G
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, H
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, J
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, K
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, L
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, `;
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, `'
modSize := buttonSize * 2.2
Gui, Primary:Add, Button, x+ w%modSize% h%buttonSize% gOpen_Menu_2, _Enter
; Fourth Row Keys
modSize := buttonSize * 2
Gui, Primary:Add, Button, xs10 y+ w%modSize% h%buttonSize% gOpen_Menu_2, _Shift
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, Z
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, X
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, C
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, V
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, B
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, N
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, M
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, ,
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, .
Gui, Primary:Add, Button, x+ w%buttonSize% h%buttonSize% gOpen_Menu, /
modSize := buttonSize * 3
Gui, Primary:Add, Button, x+ w%modSize% h%buttonSize% gOpen_Menu_2, _Shift
; Fifth Row Keys
modSize := buttonSize * 1.1
Gui, Primary:Add, Button, xs10 y+ w%modSize% h%buttonSize% gOpen_Menu_2, _Ctrl
Gui, Primary:Add, Button, x+ w%modSize% h%buttonSize% gOpen_Menu_2 vFunc, _Func
GuiControl, Disable, Func
Gui, Primary:Add, Button, x+ w%modSize% h%buttonSize% gOpen_Menu_2 vWin, _Win
GuiControl, Disable, Win
Gui, Primary:Add, Button, x+ w%modSize% h%buttonSize% gOpen_Menu_2, _Alt
modSize := buttonSize * 6
Gui, Primary:Add, Button, x+ w%modSize% h%buttonSize% gOpen_Menu_2, _Space
modSize := buttonSize * 1.1
Gui, Primary:Add, Button, x+ w%modSize% h%buttonSize% gOpen_Menu_2, _Alt
Gui, Primary:Add, Button, x+ w%modSize% h%buttonSize% gOpen_Menu_2, _Insert
Gui, Primary:Add, Button, x+ w%modSize% h%buttonSize% gOpen_Menu_2, _Ctrl
Gui, Primary:Show, x%mainX% y%mainY% w%width% h%height%, %title%
Gui, Page2:Color, White
Gui, Page2:+LastFound +OwnerPrimary
Gui, Page2:Add, Text,, %mainText%
Gui, Page2:Add, Button, x10 y+ w90 h100 gPage1, Page 1
Gui, Page2:Add, Button, x10 y+ w90 h100, Page 2
return
; Lables
;
;
Page1:
WinGetPos, X1, Y1, W1, H1, A
Gui, Primary:Show, % "x" X1 "y" Y1 "w" width "h" height, %title%
Gui, Primary:+LastFound
Gui, Page2:Hide
return
Page2:
WinGetPos, X1, Y1, W1, H1, A
Gui, Page2:Show, % "x" X1 "y" Y1 "w" width "h" height, Page 2
Gui, Page2:+LastFound
Gui, Primary:Hide
return
Open_Menu:
GuiControlGet, var,, % A_GuiControl
keyLetter := SubStr(var, 0)
key := "`;"
key .= keyLetter
Gosub, Get_Command
Gui, KeyGui:Destroy
WinGetPos, X1, Y1,,, A
Gui, KeyGui:+LastFound +ToolWindow +AlwaysOnTop +OwnerPrimary
Gui, KeyGui:Add, Edit, Multi vCommandBox w200 h100, %defaultText%
Gui, KeyGui:Add, Button, x10 w100 h40 gSet_Key, Set %var%
Gui, KeyGui:Add, Button, x+ w100 h40 gSet_Key, Reset %var%
Gui, KeyGui:Show, % "x" X1 + width/2-100 "y" Y1 + 25, %var%
return
Open_Menu_2:
GuiControlGet, var,, % A_GuiControl
key := "`;"
key .= var
Gosub, Get_Command
Gui, KeyGui:Destroy
var := SubStr(var, 2v )
WinGetPos, X1, Y1,,, A
Gui, KeyGui:+LastFound +ToolWindow +AlwaysOnTop +OwnerPrimary
Gui, KeyGui:Add, Edit, Multi vCommandBox w200 h100, %defaultText%
Gui, KeyGui:Add, Button, x10 w100 h40 gSet_Key, Set %var%
Gui, KeyGui:Add, Button, x+ w100 h40 gSet_Key, Reset %var%
Gui, KeyGui:Show, % "x" X1 + width/2-100 "y" Y1 + 25, %var%
return
Set_Key:
IfInString, var, Reset
{
Gosub, Reset_Button
}
else
{
Gosub, Set_Button
}
return
Set_Button:
Gosub, Reset_Button
Sleep 100
keyboardLen := keyboard.Length
output := ""
keyboard.Seek(0)
i := 0
while (i < keyboardLen) {
Line := keyboard.ReadLine()
StringReplace, Line, Line, `n,,,A
IfInString, Line, %key%
{
output .= Line . "`n"
i += Line.Length
Line := keyboard.ReadLine()
StringReplace, Line, Line, `n,,,A
output .= Line . "`n"
i += Line.Length
GuiControlGet, Line,, CommandBox
StringReplace, Linetemp, Line, `n, `n`t`t`t, All]
Line := "`t`t`t"
Line .= Linetemp
}
output .= Line . "`n"
i += Line.Length
isAtEOF := keyboard.AtEOF
if (isAtEOF != 0) {
Break
}
}
FileDelete, Main.ahk
FileAppend, %output%, Main.ahk
keyboard := FileOpen(keyboardName, "rw`n")
Run Main.ahk
return
Reset_Button:
keyboardLen := keyboard.Length
output := ""
keyboard.Seek(0)
i := 0
while (i < keyboardLen) {
Line := keyboard.ReadLine()
StringReplace, Line, Line, `n,,,A
IfInString, Line, %key%
{
msgbox Working
output .= Line . "`n"
i += Line.Length
Line := keyboard.ReadLine()
StringReplace, Line, Line, `n,,,A
output .= Line . "`n"
i += Line.Length
boolVar := 0
while boolVar = 0 {
Line := keyboard.ReadLine()
StringReplace, Line, Line, `n,,,A
IfInString, Line, }
{
break
}
i += Line.Length
}
}
output .= Line . "`n"
i += Line.Length
isAtEOF := keyboard.AtEOF
if (isAtEOF != 0) {
Break
}
}
FileDelete, Main.ahk
FileAppend, %output%, Main.ahk
keyboard := FileOpen(keyboardName, "rw`n")
Run Main.ahk
return
Get_Command:
keyboardLen := keyboard.Length
output := ""
keyboard.Seek(0)
i := 0
while (i < keyboardLen)
{
Line := keyboard.ReadLine()
StringReplace, Line, Line, `n,,,A
IfInString, Line, %key%
{
i += Line.Length
Line := keyboard.ReadLine()
i += Line.Length
boolVar := 0
while boolVar = 0
{
Line := keyboard.ReadLine()
StringReplace, Line, Line, `n,,,A
StringReplace, Line, Line, `t,,,A
IfInString, Line, }
{
break
}
output .= Line . "`n"
i += Line.Length
}
}
i += Line.Length
isAtEOF := keyboard.AtEOF
if (isAtEOF != 0)
{
Break
}
}
if (output != "")
{
defaultText := SubStr(output, 1, -1)
}
else
{
defaultText := "Run`, Notepad`nSleep 100`nSend`, So long and thanks for all the fish"
}
return
; Functions
;
;
PrimaryGuiClose:
file.Length := 0
Gui, Primary:+LastFound
WinGetPos,x,y
file.Seek(0, Origin := 0)
file.WriteLine(x)
file.WriteLine(y)
file.WriteLine(keyboardLen)
file.WriteLine(temps)
Texts := file.Read()
file.Close()
keyboard.Close()
ExitApp
return
2GuiClose:
Gui 2:Destroy
return
Page2GuiClose:
Gosub, PrimaryGuiClose
return
; Hotkeys
;
;