forked from Inversil/LESwin
-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
LiveEnhancementSuite.ahk
3422 lines (3094 loc) · 104 KB
/
LiveEnhancementSuite.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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* * * Compile_AHK SETTINGS BEGIN * * *
[AHK2EXE]
Exe_File=%In_Dir%\Live Enhancement Suite.exe
Compression=0
No_UPX=1
Created_Date=1
[VERSION]
Set_Version_Info=1
Company_Name=Inverted Silence & Dylan Tallchief
File_Description=Live Enhancement Suite
File_Version=0.1.3.3
Inc_File_Version=0
Internal_Name=Live Enhancement Suite
Legal_Copyright=© 2019
Original_Filename=Live Enhancement Suite
Product_Name=Live Enhancement Suite
Product_Version=0.1.3.2
[ICONS]
Icon_1=%In_Dir%\resources\blueico.ico
Icon_2=%In_Dir%\resources\blueico.ico
Icon_3=%In_Dir%\resources\redico.ico
Icon_4=%In_Dir%\resources\redico.ico
Icon_5=%In_Dir%\resources\redico.ico
* * * Compile_AHK SETTINGS END * * *
*/
; ^^^^^^^^^^^^^^^^^^
; this stuff up here are settings I use to compile the EXE file; appointing icons.. etc.
; Ok so, just to mentally prepare you: this source code is a complete mess.
; I only really got into programming while writing this, so there's just dumb stuff happening all over.
; Live Enhancement Suite for windows was my first programming project, and you'll especially be able to see that in the sections I wrote first.
; They are the absolute worst to read.
; My apologies in advance.
; If you want to see organized code, look at the mac rewrite... But this?? nahhhhhhhhhhhhh
; Yet, I still use this version every day- since I'm a Windows user myself.
; That is to say, we're in this together >:-D
;-----------------------------------;
; AHK Setup stuff ;
;-----------------------------------;
#MaxThreadsPerHotkey 2
CoordMode, Menu, Screen
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
SetTitleMatchMode, Regex
SetWorkingDir %A_ScriptDir%
SetDefaultMouseSpeed, 0
#InstallKeybdHook
#KeyHistory 100
#SingleInstance Force
setmousedelay, -1
setbatchlines, -1
#UseHook
#MaxHotkeysPerInterval 400
OnExit, exitfunc
;-----------------------------------;
; Tray menu contents ;
;-----------------------------------;
;this sets up the tray menu
Menu, Tray, NoStandard
Menu, Tray, Add, Configure Settings, settingsini
Menu, Tray, Add, Configure Menu, menuini
Menu, Tray, Add,
Menu, Tray, Add, Donate 💲, monatpls
Menu, Tray, Add,
Menu, Tray, Add, Strict Time, stricttime
Menu, Tray, Add, Check Project Time 🕒, requesttime
Menu, Tray, Add,
Menu, Tray, Add,
Menu, Tray, Add, Install InsertWhere, InsertWhere
Menu, Tray, Add, Manual 📖, Manual
Menu, Tray, Add, Exit ❌, quitnow
Menu, Tray, Default, Exit ❌
Menu, Tray, insert, 9&, Reload ⟳️, doreload
Menu, Tray, insert, 10&, Pause && Suspend, freeze
Random, randomgen, 1, 13 ;these are the random hover quotes
if (randomgen = 1){
Menu, Tray, Tip, Ableton Live 2: Electric Boogaloo
}
if (randomgen = 2){
Menu, Tray, Tip, Super Live Bros: Lost Levels
}
if (randomgen = 3){
Menu, Tray, Tip, LES is more
}
if (randomgen = 4){
Menu, Tray, Tip, Live HD Audio Manager
}
if (randomgen = 5){
Menu, Tray, Tip, Vitableton Enhancement 100mg [Now with extra vitamin C!]
}
if (randomgen = 6){
Menu, Tray, Tip, hey`, pshh!! hit both shift keys with debug on
}
if (randomgen = 7){
Menu, Tray, Tip, Do more with LES
}
if (randomgen = 8){
Menu, Tray, Tip, *Cowbell*
}
if (randomgen = 9){
Menu, Tray, Tip, OTT.exe
}
if (randomgen = 10){
Menu, Tray, Tip, Live Sweet
}
if (randomgen = 11){
Menu, Tray, Tip, Ableton Gratis Saus
}
if (randomgen = 12){
Menu, Tray, Tip, The biggest thing since sliced bread
}
randomgen := ;
FileRead, stricttxt, %A_ScriptDir%\resources\strict.txt
if(ErrorLevel = 1){
stricton := 1
}
else{
stricton := stricttxt
}
if(stricttxt = 1){
Menu, Tray, Check, Strict Time
}
;-----------------------------------;
; Installation ;
;-----------------------------------;
; msgbox, % A_ScriptDir
FileReadLine, OutputVar, %A_ScriptDir%/resources/firstrun.txt, 1
;Checks if the first run file exists
;If it doesn't exist; this is the first run, so then do a bunch of initialization stuff.
if (ErrorLevel = 1 or !(OutputVar = 0)){
If !(InStr(FileExist("resources"), "D")){ ;if the resources folder doesn't exist, check if there's other stuff in the current folder, otherwise spawn the text box.
Loop, %A_ScriptDir%\*.*,1,1
If (A_Index > 3)
{
MsgBox,48,Live Enhancement Suite, % "You have placed LES in a directory that contains other files.`n LES will create new files when used for the first time.`n Please move the program to a dedicated directory."
exitapp
}
}
if InStr(splitPath A_ScriptDir, "Windows\Temp") or InStr(splitPath A_ScriptDir, "\AppData\Local\Temp"){
MsgBox,48,Live Enhancement Suite, % "You executed LES from within your file extraction software.`nThis placed it inside of a temporary cache folder, which will cause it to be deleted by Windows' cleanup routine.`nPlease extract LES into its own folder before proceeding."
exitapp
}
if (instr(A_ScriptDir, "C:\Program Files") != 0) or (instr(A_ScriptDir, "C:\Program Files (x86)") != 0){
MsgBox,4,Live Enhancement Suite, % "You may have executed LES from within a system folder.`nThis may cause LES to not function properly, as it will not have enough permissions to self-extract in this location.`nAre you sure you want to install LES in this location?`nPlease move this foder to another location to remove this warning."
IfMsgBox No
{
exitapp
}
}
;this part of the code extracts a bunch of resources from the .exe and puts them in the right spot
FileCreateDir, resources
FileInstall, resources/readmejingle.wav, %A_ScriptDir%/resources/readmejingle.wav
FileInstall, resources/piano.png, %A_ScriptDir%/resources/piano.png
FileInstall, resources/piano2.png, %A_ScriptDir%/resources/piano2.png
FileInstall, resources/pianoblack.png, %A_ScriptDir%/resources/pianoblack.png
FileInstall, menuconfig.ini, %A_ScriptDir%/menuconfig.ini
FileInstall, settings.ini, %A_ScriptDir%/settings.ini
FileInstall, CHANGELOG.md, %A_ScriptDir%/CHANGELOG.md
MsgBox, 4, Live Enhancement Suite, Welcome to the Live Enhancement Suite!`nWould you like to add the Live Enhancement Suite to startup?`nIt won't do anything when you're not using Ableton Live.`n(This can be changed anytime)
IfMsgBox Yes
{
;MsgBox You pressed Yes.
Loop, Read, %A_ScriptDir%/settings.ini, %A_ScriptDir%/settingstemp.ini
{
testforstartup := Instr(A_LoopReadLine, "addtostartup")
If(testforstartup = 1) {
FileAppend, addtostartup = 1`n, %A_ScriptDir%/settingstemp.ini
FileAppend, `;` causes the script to launch on startup`n, %A_ScriptDir%/settingstemp.ini"
}
Else{
FileAppend, %A_LoopReadLine%`n, %A_ScriptDir%/settingstemp.ini
}
}
goto, donewithintro
}
;MsgBox You pressed No.
Loop, Read, %A_ScriptDir%/settings.ini, %A_ScriptDir%/settingstemp.ini
{
testforstartup := Instr(A_LoopReadLine, "addtostartup")
If(testforstartup = 1) {
FileAppend, addtostartup = 0`n, %A_ScriptDir%/settingstemp.ini
FileAppend, `;` causes the script to launch on startup`n, %A_ScriptDir%/settingstemp.ini"
}
Else{
FileAppend, %A_LoopReadLine%`n, %A_ScriptDir%/settingstemp.ini
}
}
donewithintro: ;this is the goto thats being used when the "intro" is done
FileDelete,%A_ScriptDir%/resources/firstrun.txt
FileAppend, 0,%A_ScriptDir%/resources/firstrun.txt
FileDelete, %A_ScriptDir%/settings.ini
FileMove, %A_ScriptDir%/settingstemp.ini, %A_ScriptDir%/settings.ini
Sleep, 50
settimer, tooltipboi, 1
Sleep, 2
}
FileReadLine, OutputVar, %A_ScriptDir%\resources\firstrun.txt, 2
;msgbox % OutputVar
coolpath := A_ScriptFullPath
if (ErrorLevel = 1 or !(OutputVar = coolpath)){
;msgbox, adding reg
FileReadLine, line1, %A_ScriptDir%\resources\firstrun.txt, 1
;msgbox % line1
FileReadLine, line2, %A_ScriptDir%\resources\firstrun.txt, 2
if (Errorlevel = 0)
{
RegDelete, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers, %line2%
}
FileDelete, %A_ScriptDir%/resources/firstrun.txt
FileAppend, %line1%, %A_ScriptDir%/resources/firstrun.txt
FileAppend, `n%A_ScriptFullPath%,%A_ScriptDir%/resources/firstrun.txt
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers, %A_ScriptFullPath%, ~ HIGHDPIAWARE
}
loop, 1 { ;test if configuration files are present
FileReadLine, OutputVar, settings.ini, 1
if (ErrorLevel = 1){
Msgbox, 4, Oops!, % "the settings.ini file is missing and is required for operation. Create new?"
IfMsgBox Yes
{
FileInstall, settings.ini, %A_ScriptDir%/settings.ini
}
Else{
exitapp
}
}
FileReadLine, OutputVar, menuconfig.ini, 1
if (ErrorLevel = 1){
Msgbox, 4, Oops!, % "the menuconfig.ini file is missing and is required for operation. Create new?"
IfMsgBox Yes
{
FileInstall, menuconfig.ini, %A_ScriptDir%/menuconfig.ini
}
Else{
exitapp
}
}
Outputvar := ;
}
sleep, 10
; updating the changelog.txt file with the one included in the current package
FileDelete, %A_ScriptDir%\CHANGELOG.md
FileDelete, %A_ScriptDir%\changelog.txt
FileInstall, CHANGELOG.md, %A_ScriptDir%\CHANGELOG.md
;-----------------------------------;
; reading Settings.ini ;
;-----------------------------------;
; This next loop is the settings.ini "spell checker". As a lot of variables come from this text file.
; It's important that all of them are present in the correct way; otherwise AHK might misbehave or do stupid stuff.
; I didn't really know how to make this work as a function back then so I just copy pasted the different checks for each of the values.
; Contrary to what it looks like, these are not all the same; not every field requires a 1 or a 0
Loop, Read, %A_ScriptDir%\settings.ini
{
line := StrReplace(A_LoopReadLine, "`r", "")
line := StrReplace(line, "`n", "")
if (RegExMatch(line, "autoadd\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "autoadd" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
autoadd := result[2]
}
if (RegExMatch(line, "resetbrowsertobookmark\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "resetbrowsertobookmark" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
resetbrowsertobookmark := result[2]
}
if (RegExMatch(line, "bookmarkx\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(RegExReplace(result[2], "[0-9]") = ""){
msgbox % "Invalid parameter for " . Chr(34) "bookmarkx" . Chr(34) . ": the specified parameter is not a number. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
bookmarkx := result[2]
}
if (RegExMatch(line, "bookmarky\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(RegExReplace(result[2], "[0-9]") = ""){
msgbox % "Invalid parameter for " . Chr(34) "bookmarky" . Chr(34) . ": the specified parameter is not a number. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
bookmarky := result[2]
}
if (RegExMatch(line, "windowedcompensationpx\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(RegExReplace(result[2], "[0-9]") = ""){
msgbox % "Invalid parameter for " . Chr(34) "windowedcompensationpx" . Chr(34) . ": the specified parameter is not a number. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
windowedcompensationpx := result[2]
}
if (RegExMatch(line, "disableloop\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "disableloop" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
disableloop := result[2]
}
if (RegExMatch(line, "saveasnewver\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "saveasnewver" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
saveasnewver := result[2]
}
if (RegExMatch(line, "usectrlaltsinstead\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "usectrlaltsinstead" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
usectrlaltsinstead := result[2]
}
if (RegExMatch(line, "altgrmarker\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "altgrmarker" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
altgrmarker := result[2]
}
if (RegExMatch(line, "middleclicktopan\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "middleclicktopan" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
middleclicktopan := result[2]
}
if (RegExMatch(line, "scrollspeed\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(RegExReplace(result[2], "[0-9]") = ""){
msgbox % "Invalid parameter for " . Chr(34) "scrollspeed" . Chr(34) . ". The specified parameter is not a number. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
scrollspeed := floor(result[2])
}
if (RegExMatch(line, "addctrlshiftz\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "addctrlshiftz" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
addctrlshiftz := result[2]
}
if (RegExMatch(line, "0todelete\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "0todelete" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
0todelete := result[2]
}
if (RegExMatch(line, "absolutereplace\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "absolutereplace" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
absolutereplace := result[2]
}
if (RegExMatch(line, "enableclosewindow\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "enableclosewindow" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
enableclosewindow := result[2]
}
if (RegExMatch(line, "vstshortcuts\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "vstshortcuts" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
vstshortcuts := result[2]
}
; depricated feature
; if (RegExMatch(line, "superspeedmode\s=\s") != 0){
; result := StrSplit(line, "=", A_Space)
; if !(result[2] = 0 or result[2] = 1){
; msgbox % "Invalid parameter for " . Chr(34) "superspeedmode" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
; run, %A_ScriptDir%\settings.ini
; exitapp
; }
; superspeedmode := result[2]
; }
if (RegExMatch(line, "smarticon\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "smarticon" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
smarticon := result[2]
}
if (RegExMatch(line, "dynamicreload\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "dynamicreload" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
dynamicreload := result[2]
}
if (RegExMatch(line, "pianorollmacro\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if ((RegExMatch(line, "SC\d\d") = 0)){
msgbox % "Invalid parameter for " . Chr(34) "pianorollmacro" . Chr(34) . ". This needs to be a keycode starting with SC. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
pianorollmacro := result[2]
}
if (RegExMatch(line, "pianosearch\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "pianosearch" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
pianosearch := result[2]
}
if (RegExMatch(line, "enabledebug\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "enabledebug" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
enabledebug := result[2]
}
if (RegExMatch(line, "addtostartup\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "addtostartup" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
addtostartup := result[2]
}
if (RegExMatch(line, "fliptabfunction\s=\s") != 0){
result := StrSplit(line, "=", A_Space)
if !(result[2] = 0 or result[2] = 1){
msgbox % "Invalid parameter for " . Chr(34) "fliptabfunction" . Chr(34) . ". Valid parameters are: 1 and 0. The program will shut down now."
run, %A_ScriptDir%\settings.ini
exitapp
}
fliptabfunction := result[2]
}
}
; alright, so this section asks the user to update the settings.ini with the one included in the package if some values are missing.
; these are the values I deem "nescesary"
if ((autoadd = "") or (resetbrowsertobookmark = "") or (bookmarkx = "") or (bookmarky = "") or (windowedcompensationpx = "") or (disableloop = "") or (saveasnewver = "") or (usectrlaltsinstead = "")or (usectrlaltsinstead = "") or (middleclicktopan = "") or (addctrlshiftz = "") or (0todelete = "") or (absolutereplace = "") or (smarticon = "") or (pianorollmacro = "") or (pianosearch = "") or (enabledebug = "") or (addtostartup = "")){
gosub, settingsinibad
}
; this section checks for the remaining variables; ones that were added in recent updates or betas. They aren't really nescesary for the program to function.
; In case you're wondering; missing variables default to a "false" response in AHK - so none of the features with missing settings.ini entries will work until you add them to the file.
; I never bothered to make a dynamic settings.ini file updater. Or some UI thing that would make this entire process more convoluted.
; Things like LES 1.2 and 1.3 were never supposed to happen so I didn't account for them - these are the crappy workarounds.
if ((dynamicreload = "") or (altgrmarker = "") or (enableclosewindow = "") or (vstshortcuts = "") or (scrollspeed = "") or (fliptabfunction = ""))
Msgbox, 4, Oops!, % "It seems your settings.ini file is from an older version of LES.`nYou won't be able to use some of the new features added to the settings without restoring your settings.ini file to its default state. It is recommended you make a backup before you do. This won't reset your menu. Reset settings?"
IfMsgBox Yes
{
FileDelete, %A_ScriptDir%\settings.ini
FileInstall, settings.ini, %A_ScriptDir%/settings.ini
MsgBox, 4,Live Enhancement Suite, Would you like to add the Live Enhancement Suite to startup?`n(This can be changed anytime)
IfMsgBox Yes
{
;MsgBox You pressed Yes.
Loop, Read, %A_ScriptDir%/settings.ini, %A_ScriptDir%/settingstemp.ini
{
testforstartup := Instr(A_LoopReadLine, "addtostartup")
If(testforstartup = 1) {
FileAppend, addtostartup = 1`n, %A_ScriptDir%/settingstemp.ini
FileAppend, `;` causes the script to launch on startup`n, %A_ScriptDir%/settingstemp.ini"
}
Else{
FileAppend, %A_LoopReadLine%`n, %A_ScriptDir%/settingstemp.ini
}
}
goto, donelalalala
}
;MsgBox You pressed No.
Loop, Read, %A_ScriptDir%/settings.ini, %A_ScriptDir%/settingstemp.ini
{
testforstartup := Instr(A_LoopReadLine, "addtostartup")
If(testforstartup = 1) {
FileAppend, addtostartup = 0`n, %A_ScriptDir%/settingstemp.ini
FileAppend, `;` causes the script to launch on startup`n, %A_ScriptDir%/settingstemp.ini"
}
Else{
FileAppend, %A_LoopReadLine%`n, %A_ScriptDir%/settingstemp.ini
}
}
donelalalala:
FileDelete,%A_ScriptDir%/resources/firstrun.txt
FileAppend, 0,%A_ScriptDir%/resources/firstrun.txt
FileDelete, %A_ScriptDir%/settings.ini
FileMove, %A_ScriptDir%/settingstemp.ini, %A_ScriptDir%/settings.ini
Sleep, 50
settimer, tooltipboi, 1
Sleep, 2
}
if (scrollspeed = ""){ ;prevents error from empty variable, in case the user didn't want to reset their settings.ini file during an update
scrollspeed := 1
}
;-----------------------------------;
; Post-settings.ini stuff ;
;-----------------------------------;
if (enabledebug = 1){ ;modifies the tray menu if enabledebug is enabled.
Menu, Tray, Insert, 1&, Key History, listkeys
Menu, Tray, Insert, 2&,
Menu, Tray, Insert, 1&, Log, logstuff
Menu, Tray, Default, Log
}
; speeeeeeeeeeeeeeeeeeeeeeeed
; This used to have a variable setting "superspeedmode", but it was depricated.
; I'm not sure why I haven't moved this to the start of the script.
setmousedelay -1
setbatchlines -1
loop, 1{ ;adding to startup (or not)
if (addtostartup = 1){
RegWrite, REG_SZ, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, Live Enhancement Suite, %A_ScriptDir%\%A_ScriptName%
}
if (addtostartup = 0){
RegDelete, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, Live Enhancement Suite
}
}
SetTimer, watchforopen, 1000
goto hotkeysmain
~$MButton Up::
Critical
if (activenaw = 1){
if (middleclicktopan = 1){
Send {LControl up}{LAlt up}{LButton up}
}
}
else {
sendinput {blind}{mbutton up}
}
Return
hotkeysmain:
#IfWinActive ahk_exe Ableton Live.+
;-----------------------------------;
; Hotkeys main ;
;-----------------------------------;
loop, 1{ ;creating hotkeys
If (disableloop = 1){
HotKey, ^+m, midiclip
}
HotKey, %pianorollmacro% & ~Lbutton, doubleclick
if (usectrlaltsinstead = 0){
Hotkey, ^+s, savenewver
}
Else{
Hotkey, ^!s, savenewver
}
Hotkey, !e, envelopemode
if (addctrlshiftz = 1){
Hotkey, ^+z, redo
}
if (0todelete = 1){
Hotkey, ~0, double0delet
}
if (altgrmarker = 0){
Hotkey, RShift & L, quickmarker
}
else{
Hotkey, <^>!L, quickmarker
Hotkey, Ralt & L, quickmarker
}
if (enabledebug = 1){
Hotkey, ~RShift & LShift, cheats
}
Hotkey, !c, colortracks
Hotkey, !x, cleartracks
if (absolutereplace = 1){
Hotkey, ^!v, absolutev
Hotkey, ^!d, absoluted
}
if (enableclosewindow = 1){
Hotkey, ^w, closewindow
Hotkey, ^!w, closeall
}
Hotkey, ^b, buplicate
Hotkey, ^+h, directshyper
;Hotkey, !g, debugshortcut
Hotkey, !f, freezetrack
Hotkey, !+f, flattentrack
if (fliptabfunction = 1) {
Hotkey, Tab, PianoRoll
Hotkey, LShift & Tab, SessionView
}
if(vstshortcuts = 1){
scaling = 1
; depricated phaseplant VST specific shortcuts - the alt key would stick sometimes and that's really annoying.
; was mostly a proof of concept anyway
FileRead, cheatread, %A_ScriptDir%\resources\activecheat.txt
if(cheatread = "kilohearts"){ ; you can still enable it with a cheat though; for the people who wanna mess around with it.
Hotkey, ~!a, phaseplanta
Hotkey, ~!n, phaseplantn
Hotkey, ~!s, phaseplants
Hotkey, ~!w, phaseplantw
Hotkey, ~!d, phaseplantd
Hotkey, ~!f, phaseplantf
Hotkey, ~!o, phaseplanto
Hotkey, ~!l, phaseplantl
}
Hotkey, ^z, VSTundo
Hotkey, ^y, VSTredo
}
}
gosub, createpluginmenu
;-----------------------------------;
; Piano menu contents ;
;-----------------------------------;
loop,1 { ;this is where the scale menu is created
FileRead, cheatread, %A_ScriptDir%\resources\activecheat.txt ;these cheats are hidden jokes; don't mind them.
if (cheatread = "jazz"){
Menu, Scales, Add, THE LICK™, thelick
Menu, Chords, Add, THE LICK™, thelick
Menu, Pianomenu, Add, Scales, :Scales
Menu, Pianomenu, Add, Chords, :Chords
goto, skipnormalscales
}
if (cheatread = "blackmidi"){
Menu, AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, Add, 死, deathmidi
Menu, Pianomenu, Add, AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, :AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
goto, skipnormalscales
}
; the actual scale menu is built here
Menu, Scales, Add, Major/Ionian, majorscale
Menu, Scales, Add, Natural Minor/Aeolean, minorscale
Menu, Scales, Add,
Menu, Scales, Add, Harmonic Minor, minorscaleh
Menu, Scales, Add, Melodic Minor, minorscalem
Menu, Scales, Add, Dorian, dorian
Menu, Scales, Add, Phrygian, phrygian
Menu, Scales, Add, Lydian, lydian
Menu, Scales, Add, Mixolydian, mixolydian
Menu, Scales, Add, Locrian, locrian
Menu, Scales, Add,
Menu, Pentatonic Based, Add, Major Pentatonic, majorpentatonic
Menu, Pentatonic Based, Add, Minor Pentatonic, minorpentatonic
Menu, Pentatonic Based, Add, Major Blues, BluesMaj
Menu, Pentatonic Based, Add, Minor Blues, Blues
Menu, World, Add, Gypsy, Gypsy
Menu, World, Add, Minor Gypsy, GypsyM
Menu, World, Add, Arabic/Double Harmonic, Arabic
Menu, World, Add, Hungarian Minor, HungarianM
Menu, World, Add, Pelog, Pelog
Menu, World, Add, Bhairav, Bhairav
Menu, World, Add, Spanish, Spanish
Menu, World, Add,
Menu, World, Add, Hirajōshi, Hirajoshi
Menu, World, Add, In-Sen, Insen
Menu, World, Add, Iwato, Iwato
Menu, World, Add, Kumoi, Kumoi
Menu, Chromatic, Add, Chromatic/Freeform Jazz, chromatic
Menu, Chromatic, Add, Wholetone, wholetone
Menu, Chromatic, Add, Diminished, diminishedscale
Menu, Chromatic, Add, Dominant Bebop, dominantbebop
Menu, Chromatic, Add, Super Locrian, Superlocrian
Menu, Chords, Add, Octaves, octaves
Menu, Chords, Add, Power Chord, pwrchord
Menu, Chords, Add
Menu, Chords, Add, Major, maj
Menu, Chords, Add, Minor, min
Menu, Chords, Add, Maj7, maj7
Menu, Chords, Add, Min7, m7
Menu, Chords, Add, Maj9, maj9
Menu, Chords, Add, Min9, m9
Menu, Chords, Add, 7, dominant7
Menu, Chords, Add, Augmented, aug
Menu, Chords, Add, Diminished, dim
Menu, Chords, Add,
Menu, Chords, Add, Triad (Fold), fold3
Menu, Chords, Add, Seventh (Fold), fold7
Menu, Chords, Add, Ninth (Fold), fold9
Menu, Pianomenu, Add, Scales, :Scales
Menu, Pianomenu, Add, Chords, :Chords
Menu, Scales, Add, Pentatonic Based, :Pentatonic Based
Menu, Scales, Add, World, :World
Menu, Scales, Add, Chromaitc, :Chromatic
skipnormalscales:
}
;-----------------------------------;
; Double right click routine ;
;-----------------------------------;
; double right click routine
Loop, 1 {
*~RButton::
tildestate := GetKeyState(pianorollmacro)
if (A_PriorHotkey <> "*~RButton" or A_TimeSincePriorHotkey > 400)
{
KeyWait, RButton
return
}
Show()
WinKill, menu launcher
return ;end of script's auto-execute section.
return ;end of double right click loop
; the menu show routine; which includes the part of the code that uses imagesearch to detect the piano roll on a certain portion of the screen.
; I singled out just one area on the screen in order to improve performance.
; Image search is actually faster than pixel search, which is why I use 2x2 pixel .pngs to achieve the same goal.
Show() {
Global pianosearch
Global dynamicreload
Global tildestate
SetTitleMatchMode, 2
WinGetPos, wx, wy, wWidth, wHeight, Ableton Live
coolvar := ((wHeight/3.5) + wy)
coolvar2 := (wHeight - 100 + wy)
coolvar3 := ((wWidth/3.4) + wx)
if (!MX && !MY)
MouseGetPos, MX, MY
if (pianosearch = 1){
ImageSearch, x1, y1, (wx + 8), coolvar, coolvar3, coolvar2, %A_ScriptDir%\resources\piano.png
;msgbox,0,ha, % "Top left x[" (wx + 8) "] y[" coolvar "] and then bottom right x[" coolvar3 "] y[" coolvar2 "]"
if (Errorlevel = 0){
Imagesearch, a1, b1, x1, (y1 + 5), x1, (y1 + 105), %A_ScriptDir%\resources\pianoblack.png
if (Errorlevel = 0){
;mousemove, coolvar3, 500
Menu, pianomenu, Show, % MX, % MY
Return
}
if (dynamicreload = 1){
gosub, createpluginmenu
}
Menu, ALmenu, Show, % MX, % MY
Return
}
ImageSearch, x1, y1, (wx + 8), coolvar, coolvar3, coolvar2, %A_ScriptDir%\resources\piano2.png
if (Errorlevel = 0){
Imagesearch, a1, b1, x1, (y1 + 5), x1, (y1 + 105), %A_ScriptDir%\resources\pianoblack.png
if (Errorlevel = 0){
;mousemove, coolvar3, 500
Menu, pianomenu, Show, % MX, % MY
Return
}
if (dynamicreload = 1){
gosub, createpluginmenu
}
Menu, ALmenu, Show, % MX, % MY
Return
}
Else{
if (dynamicreload = 1){
gosub, createpluginmenu
}
Menu, ALmenu, Show, % MX, % MY
}
}
if (pianosearch = 0){
if GetKeyState("LShift") = 0{
gosub, createpluginmenu
Menu, ALmenu, Show, % MX, % MY
}
if GetKeyState("LShift") = 1{
Menu, pianomenu, show, % MX, % MY
}
}
}
} ;ends whole loop
Return
;-----------------------------------;
; Hotkeys Mouse ;
;-----------------------------------;
; I'm using this syntax here; rather than "Hotkey", because for some reason this works on MX master mice and the "Hotkey" approach does not.
; I'm not sure if I'm doing something wrong but this is probably a bug; AHK pease fix?
; these are after the double right click routine because it ends the auto execute section of the script.
; If they were higher up, the nescesary "Return" would end the auto-execute section of the script early.
; I moved $Mbutton up:: hotkey to the top of the script to be set before the global #ifwinactive marker
; this way you will be able to release the mbutton hotkey even when ableton live is not in focus
; I think this is the cause of the hotkey getting stuck bug (requires some testing)
$MButton::
Critical
if (middleclicktopan = 1){
Send {LControl down}{LAlt down}{LButton down}
keywait, Mbutton
Send {LControl up}{LAlt up}{LButton up}
}
Return
$WheelDown::
MouseGetPos,,,guideUnderCursor
WinGetTitle, WinTitle, ahk_id %guideUnderCursor%
if(InStr(WinTitle, "Ableton") != 0){
SendInput, {WheelDown %scrollspeed%}
}
else{
SendInput, {WheelDown 1}
}
Return
$WheelUp:: ;selecta
MouseGetPos,,,guideUnderCursor
WinGetTitle, WinTitle, ahk_id %guideUnderCursor%
if(InStr(WinTitle, "Ableton") != 0){
SendInput, {WheelUp %scrollspeed%}
}
Else{
SendInput, {WheelUp 1}
}
Return
pause::
^F1::
Suspend, Permit
if (A_IsPaused = 1){
;traytip, "Live Enhancement Suite", "LES is unpaused", 0.1, 16
Menu, Tray, Rename, Unpause && Unsuspend, Pause && Suspend
}
Else{
;traytip, "Live Enhancement Suite", "LES is paused", 0.1, 16
Menu, Tray, Rename, Pause && Suspend, Unpause && Unsuspend
}
Pause, Toggle, 1
Suspend, Toggle
Return
;-----------------------------------;
; reading menuconfig.ini ;
;-----------------------------------;
; Below here is the function that interprets the stuff inside of the menuconfig.ini file and turns it into a functional autohotkey menu.
; I made up the LES menu syntax improve accessibility. In hindsight I could've done some things better, but it's too late for that now.
; If I ever decide to overhaul this (or if someone else does), I would try to make a converter that can convert people's old configurations into a new syntax, along with the update.
; Seriously, I've seen people add a thousand items. That must take for ever...
createpluginmenu:
; this thing over here clears out all variables and folders from memory before rebuilding to prevent double entries while using dynamic reload.
if (menuitemcount != ""){
menu, ALmenu, DeleteAll
Array := ""
menuitemcount := ""
querycount := ""
categoryname := ""
configoutput := ""
TestForContent := ""
slashcount := ""
counter := ""
outputcount := ""
historyi := ""
table := trimArray(table)
loop {
if (historyi = ""){
historyi := 1
}
if (table[historyi] = ""){
Break
}
menu, % table[historyi], DeleteAll
historyi := historyi + 1
}
table := ""
historyi := ""
}
loop, 1 { ; loop, 1 does nothing. I just used it so I could collapse this section of code inside of notepad++.
table := []
mathvar := ""
Array := Array()
categorydest := Array()
categoryname := Array()
categorydest[1] := "ALmenu"
depth := 1
Loop
{
if (mathvar = "") ;if the counter is non existent, make it 1. The counter keeps tracks of the line count. Didn't know you could use 'loop, read' for this until after I was done with it.
{
Mathvar := 1
}
FileReadLine, configoutput, menuconfig.ini, mathvar
if (configoutput = ""){ ;checks if string is empty
goto, skipalles
}