forked from imaginationac/compile-ahk
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCompile_AHK.ahk
3656 lines (3318 loc) · 116 KB
/
Compile_AHK.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%\Compile_AHK.exe
Compression=2
No_UPX=1
Created_Date=1
[VERSION]
Set_Version_Info=1
Company_Name=denick, ladiko, flashkid, ruespe, darklight_tr and mercury233
File_Description=AHK Compiler Wrapper
File_Version=0.9.2.0
Inc_File_Version=0
Internal_Name=Compile_AHK.ahk
Legal_Copyright=(c) 2006-2016 AutoHotkey
Original_Filename=Compile_AHK.ahk
Product_Name=Compile_AHK
Product_Version=1.1.23.5
Set_AHK_Version=1
[ICONS]
Icon_1=%In_Dir%\icons\Compile_AHK_160.ico
Icon_2=%In_Dir%\icons\Compile_AHK_160.ico
Icon_3=%In_Dir%\icons\Compile_AHK_206.ico
Icon_4=0
Icon_5=0
* * * Compile_AHK SETTINGS END * * *
*/
CAHK_Version=0.9.2.0
; --------------------------------------------------------------------------------
; Language : English // German // Simplified Chinese
; Platform : WinNT
; Author : <= 0.9.0.5 @ denick
; // 0.9.0.6 - 0.9.0.50 @ ladiko
; // 0.9.0.51 - 0.9.0.58 @ flashkid and ruespe
; // 0.9.1 - 0.9.1.3 @ darklight_tr
; // 0.9.2 @ mercury233
; Script Function : Alternative Gui for AHK2EXE.EXE
; --------------------------------------------------------------------------------
; This script analyses a scriptname.ahk.ini , that is present inside of a script's
; directory or creates it , when not present and controls the Compiler call and the
; possibly ResHack call.
; To use Compile_AHK you have to call it with the full path of a script as
; command line Parameter
; --------------------------------------------------------------------------------
; Das Script wertet eine im Scriptverzeichnis vorhandene scriptname.ahk.ini aus
; und steuert damit den Compiler- und ggf. ResHack-Aufruf. Ggf. wird die ini-Datei
; mit Defaultwerten neu angelegt.
; Der vollständige Pfad des Scripts muss als KommandozeilenParameter übergeben
; werden.
; --------------------------------------------------------------------------------
; Thanks goes to the AutoHotKey community
; --------------------------------------------------------------------------------
; ================================================================================
; AUTO EXECUTE SECTION ===========================================================
; ================================================================================
; --------------------------------------------------------------------------------
; AutoHotkey Directives
; --------------------------------------------------------------------------------
#NoEnv
#SingleInstance , Force
; --------------------------------------------------------------------------------
; AutoHotkey Settings
; --------------------------------------------------------------------------------
SetBatchLines , -1
DetectHiddenWindows , On
; --------------------------------------------------------------------------------
; delete temporary files of last compilation
; --------------------------------------------------------------------------------
Clean_Directory()
GoSub , DefineConstants
GoSub , CheckPortableApp
GoSub , ReadLanguage
GoSub , CheckInstall
GoSub , CommandLine
; --------------------------------------------------------------------------------
; INI File
; --------------------------------------------------------------------------------
IniRead , s_INI , %In_File% , %AHK_Section% , Exe_File , ERROR
FileRead , In_File_Content , %In_File%
If s_INI <> ERROR
{
; Ini Params included in script file
SaveIniInScript = 1
RegExMatch(In_File_Content, "is)\Compile_AHK SETTINGS BEGIN \* \* \*(?:`n|`r`n)(?:`n|`r`n)(.+?)(?:`n|`r`n)\* \* \* Compile_AHK SETTINGS END", In_File_Settings)
In_File_Content := RegExReplace(In_File_Content , "/\*(`n|`r`n) \* \* \* Compile_AHK SETTINGS BEGIN \* \* \*[\S\s]*\* \* \* Compile_AHK SETTINGS END \* \* \*(`n|`r`n)\*/(`n|`r)+")
FileDelete , %Ini_File%
FileAppend , %In_File_Settings% , %Ini_File%
_READ_INI(Ini_File)
}
Else If FileExist(Ini_File)
_READ_INI(Ini_File)
Else If FileExist(Defaults_Ini)
_READ_INI(Defaults_Ini)
; --------------------------------------------------------------------------------
; Compilation Settings Gui
; --------------------------------------------------------------------------------
_Set_Gui_VERS()
Gosub , GuiShow
Return
; ================================================================================
; FUNCTIONS AND METHODS SECTION ==================================================
; ================================================================================
; --------------------------------------------------------------------------------
; Gui Button Compile
; --------------------------------------------------------------------------------
GuiBTCompile:
Gui , Submit
If !_Get_Gui_Values() {
Return
}
SplitPath , Exe_File , Out_Name , Out_Dir
; --------------------------------------------------------------------------------
; New Log File
; --------------------------------------------------------------------------------
Error_Message := "Delete old log file Error!`n"
IfExist , %A_WorkingDir%\%Log_File%
{
FileDelete , %A_WorkingDir%\%Log_File%
If ErrorLevel
_Error_Exit(Error_Message . "Couldn't delete """ . Log_File . """")
}
; --------------------------------------------------------------------------------
; Write default values
; --------------------------------------------------------------------------------
FileAppend ,
(
* Variables:
Portable_App = %Portable_App%
A_WorkingDir = %A_WorkingDir%
AHK_Compiler_DIR = %AHK_Compiler_DIR%
AHK_DIR = %AHK_DIR%
Defaults_Ini = %Defaults_Ini%
Exe_File = %Exe_File%
Global_Defaults_Ini = %Global_Defaults_Ini%
In_File = %In_File%
Used_AHK_Dir = %Used_AHK_Dir%
User_Defaults_Ini = %User_Defaults_Ini%
) , %A_WorkingDir%\%Log_File%
; --------------------------------------------------------------------------------
; Run Before
; --------------------------------------------------------------------------------
If (Run_Before != "") {
_Run_Before()
}
; --------------------------------------------------------------------------------
; No UPX
; --------------------------------------------------------------------------------
If (No_UPX && FileExist(A_WorkingDir . "\" . UPX_Exe))
Set_UPX_Option()
; --------------------------------------------------------------------------------
; copy lib directory
; --------------------------------------------------------------------------------
If (!Portable_App)
_Copy_Lib_Dir()
; --------------------------------------------------------------------------------
; Use alternative bin file
; --------------------------------------------------------------------------------
If Alt_Bin !=
Use_Alt_Bin()
; --------------------------------------------------------------------------------
; Version Info
; --------------------------------------------------------------------------------
If (Set_Version_Info) {
_Set_Version()
}
; --------------------------------------------------------------------------------
; Change Icons
; --------------------------------------------------------------------------------
Loop , %Icon_Count%
{
If (Icon_%A_Index%_Set || Icon_%A_Index%_Delete)
{
_Change_Icons()
Break
}
}
; --------------------------------------------------------------------------------
; Modify Manifest for Vista Administrator Exection Level (User Account Control)
; --------------------------------------------------------------------------------
If (Execution_Level > 1) {
_Mod_Manifest()
}
Else {
Error_Message := "Check Exename Error!`n"
_Check_ExeName()
}
; --------------------------------------------------------------------------------
; Add Resources to AutoHotkeySC.bin
; --------------------------------------------------------------------------------
If (LV_GetCount()) {
Import_Resources()
} Else {
Resource_Files := ""
}
; --------------------------------------------------------------------------------
; Compile
; --------------------------------------------------------------------------------
If (!_Compile_AHK()) {
FileRead , Compiler_Error , %Log_File%
_Error_Exit(Error_Message . Compiler_Error)
}
; --------------------------------------------------------------------------------
; Renew created date
; --------------------------------------------------------------------------------
If (Created_Date && FileExist(Exe_File))
Renew_Created_Date()
; --------------------------------------------------------------------------------
; UPX Compression
; --------------------------------------------------------------------------------
If (!No_UPX && FileExist(Exe_File))
UPX_Compression()
; --------------------------------------------------------------------------------
; Run After
; --------------------------------------------------------------------------------
If (Run_After != "") {
_Run_After()
}
; --------------------------------------------------------------------------------
; Restore backuped files on portable Installations
; --------------------------------------------------------------------------------
Restore_File(A_WorkingDir . "\" . BIN_FILE)
Restore_File(A_WorkingDir . "\" . UPX_Exe)
; --------------------------------------------------------------------------------
; Delete HKCU\Software\AutoHotkey on portable Installations
; --------------------------------------------------------------------------------
Clean_Registry()
; --------------------------------------------------------------------------------
; delete temporary files
; --------------------------------------------------------------------------------
Clean_Directory()
; --------------------------------------------------------------------------------
; Rewrite INI
; --------------------------------------------------------------------------------
_WRITE_INI(Ini_File)
; --------------------------------------------------------------------------------
; Save INI in ScriptFile?
; --------------------------------------------------------------------------------
If SaveIniInScript
_SaveIniInScript()
; --------------------------------------------------------------------------------
; Bye
; --------------------------------------------------------------------------------
Msgbox , 262208 , %MSG_TITLE% , Everything done`, bye! , 1
_EXIT(0)
Return
; ================================================================================
; GUI SECTION ==================================================================
; ================================================================================
; Show Gui
; --------------------------------------------------------------------------------
GuiShow:
Gui , -MinimizeBox -MaximizeBox
Gui , Margin , 0 , 0
Gui , Font , s10 cNavy Arial
Gui , Add , Tab , Choose1 x0 w555 h410 vGui_Tabs , %Lang_Tabs%
Gui , Tab , 1
Gui , Add , Text , Section x+20 y+17 h20 w120 +0x1000 vGui_Script_File , %Lang_Script_File%
Gui , Font , cBlack
Gui , Add , Edit , x+20 yp h20 w280 vGui_In_File ReadOnly , %In_File%
Gui , Font , cNavy
Gui , Add , Text , xs y+17 h20 w120 +0x1000 vGui_Text_Alt_Bin , AutoHotkeySC.bin
Gui , Font , cBlack
Gui , Add , Checkbox , x+20 yp w30 vGui_Alt_Bin_Set gGuiActivateAltBin Checked%Alt_Bin_Set%
Gui , Add , Edit , x+00 yp h20 w250 vGui_Alt_Bin , %Alt_Bin%
Gui , Add , Button , x+20 yp-1 h22 w70 vGui_Select_Alt_Bin gGuiBTSelBin , %Lang_Select%
Gui , Font , cNavy
Gui , Add , Text , xs y+17 h20 w120 +0x1000 vGui_Text_Exe_File , %Lang_Exe_File%
Gui , Font , cBlack
Gui , Add , Edit , x+20 yp h20 w280 vGui_Exe_File , %Exe_File%
Gui , Add , Button , x+20 yp-1 h22 w70 vGui_Select_Exe_File gGuiBTSelFile , %Lang_Select%
Gui , Font , cNavy
Gui , Add , Text , xs y+17 h20 w120 +0x1000 vGui_Text_Compression, %Lang_Compression%
Gui , Font , cBlack
Gui , Add , DDL , x+20 yp w100 vGui_Compression_Levels AltSubmit , %Lang_Compression_Levels%
Gui_Compression_Levels := Compression + 1
GuiControl , Choose , Gui_Compression_Levels , %Gui_Compression_Levels%
Gui , Add , Checkbox , x+20 yp w80 Checked%No_UPX% vGui_No_UPX , %Lang_No_UPX%
; Gui , Font , cNavy
; Gui , Add , Text , xs y+17 h20 w120 +0x1000 vGui_Text_Password, %Lang_Password%
; Gui , Font , cBlack
; Gui , Add , Edit , x+20 yp h20 w190 vGui_Password Password , %Password%
; Gui , Add , Button , x+10 yp-1 h22 w80 gGui_Gen_Pass vGui_Generate, %Lang_Generate%
; Gui , Add , Checkbox , x+20 yp w80 Checked%Show_Pwd% vGui_Show_Pwd gGuiShowPwd , %Lang_Show_Pwd%
Gui , Font , cNavy
Gui , Add , Text , xs y+17 h20 w120 +0x1000 vGui_Text_Run_Before , %Lang_Run_Before%
Gui , Font , cBlack
Gui , Add , Edit , x+20 yp h20 w280 vGui_Run_Before , %Run_Before%
Gui , Add , Button , x+20 yp-1 h22 w70 gGuiBTRunBefore vGui_Select_Run_Before , %Lang_Select%
Gui , Font , cNavy
Gui , Add , Text , xs y+17 h20 w120 +0x1000 vGui_Text_Run_After , %Lang_Run_After%
Gui , Font , cBlack
Gui , Add , Edit , x+20 yp h20 w280 vGui_Run_After , %Run_After%
Gui , Add , Button , x+20 yp-1 h22 w70 gGuiBTRunAfter vGui_Select_Run_After , %Lang_Select%
Gui , Font , cNavy
Gui , Add , Text , xs y+17 h20 w120 +0x1000 vGui_Text_Vista_UAC , %Lang_Vista_UAC%
Gui , Add , Text , x+20 yp w100 h20 vGui_Text_Execution_Level , %Lang_Execution_Level%:
Gui , Add , DropDownList , x+20 yp w160 AltSubmit Choose%Execution_Level% vGui_Execution_Levels , %Lang_Execution_Levels%
Gui , Add , Button , x+20 yp-1 w70 h22 vGui_Help gExecution_Level_Help , %Lang_Help%
Gui , Font , cNavy
Gui , Add , Text , xs y+17 h20 w120 +0x1000 vGui_Text_Other_Options, %Lang_Other_Options%
Gui , Add , Checkbox , x+20 yp w220 h20 vGui_Created_Date Checked%Created_Date% , %Lang_Created_Date%
; Gui , Add , Checkbox , x+20 yp w120 h20 vGui_NoDecompile Checked%NoDecompile% , %Lang_NoDecompile%
Gui , Add , Checkbox , xs+140 yp+17 w220 h20 vGui_SaveIniInScript Checked%SaveIniInScript% , %Lang_SaveIniInScript%
Gui , Tab , 2
Gui , Add , Checkbox , x+20 y+20 gGui_CB_VI w150 vGui_Set_Version_Info Checked%Set_Version_Info% , %Lang_Set_Version_Info%
Gui , Font , cNavy
Gui , Add , Text , Section xp y+10 h20 w120 +0x1000 vGui_Text_Company_Name , %Lang_Company_Name%
Gui , Font , cBlack
Gui , Add , Edit , x+20 yp h20 w320 vGui_Company_Name , %Company_Name%
Gui , Font , cNavy
Gui , Add , Text , xs y+10 h20 w120 +0x1000 vGui_Text_File_Description , %Lang_File_Description%
Gui , Font , cBlack
Gui , Add , Edit , x+20 yp h20 w320 vGui_File_Description , %File_Description%
Gui , Font , cNavy
Gui , Add , Text , xs y+10 h20 w120 +0x1000 vGui_Text_File_Version , %Lang_File_Version%
Gui , Font , cBlack
Gui , Add , Edit , Center x+20 yp h20 w50 vGui_TFV1 ,
Gui , Add , Updown , vGui_FV1 Range0-9999 , %Gui_FV1%
Gui , Add , Edit , Center x+0 yp h20 w50 vGui_TFV2 ,
Gui , Add , Updown , vGui_FV2 Range0-9999 , %Gui_FV2%
Gui , Add , Edit , Center x+0 yp h20 w50 vGui_TFV3 ,
Gui , Add , Updown , vGui_FV3 Range0-9999 , %Gui_FV3%
Gui , Add , Edit , Center x+0 yp h20 w50 vGui_TFV4 ,
Gui , Add , Updown , vGui_FV4 Range0-9999 , %Gui_FV4%
Gui , Add , Checkbox , x+20 gGui_CB_INC vGui_Inc_File_Version Checked%Inc_File_Version% , %Lang_Autoincrement%
Gui , Font , cNavy
Gui , Add , Text , xs y+10 h20 w120 +0x1000 vGui_Text_Internal_Name , %Lang_Internal_Name%
Gui , Font , cBlack
Gui , Add , Edit , x+20 yp h20 w320 vGui_Internal_Name , %Internal_Name%
Gui , Font , cNavy
Gui , Add , Text , xs y+10 h20 w120 +0x1000 vGui_Text_Legal_Copyright , %Lang_Legal_Copyright%
Gui , Font , cBlack
Gui , Add , Edit , x+20 yp h20 w320 vGui_Legal_Copyright , %Legal_Copyright%
Gui , Font , cNavy
Gui , Add , Text , xs y+10 h20 w120 +0x1000 vGui_Text_Original_Filename , %Lang_Original_Filename%
Gui , Font , cBlack
Gui , Add , Edit , x+20 yp h20 w320 vGui_Original_Filename , %Original_Filename%
Gui , Font , cNavy
Gui , Add , Text , xs y+10 h20 w120 +0x1000 vGui_Text_Product_Name , %Lang_Product_Name%
Gui , Font , cBlack
Gui , Add , Edit , x+20 yp h20 w320 vGui_Product_Name , %Product_Name%
Gui , Font , cNavy
Gui , Add , Text , xs y+10 h20 w120 +0x1000 vGui_Text_Product_Version , %Lang_Product_Version%
Gui , Font , cBlack
Gui , Add , Edit , Center x+20 yp h20 w50 vGui_TPV1 ,
Gui , Add , Updown , vGui_PV1 Range0-9999 , %Gui_PV1%
Gui , Add , Edit , Center x+0 yp h20 w50 vGui_TPV2 ,
Gui , Add , Updown , vGui_PV2 Range0-9999 , %Gui_PV2%
Gui , Add , Edit , Center x+0 yp h20 w50 vGui_TPV3 ,
Gui , Add , Updown , vGui_PV3 Range0-9999 , %Gui_PV3%
Gui , Add , Edit , Center x+0 yp h20 w50 vGui_TPV4 ,
Gui , Add , Updown , vGui_PV4 Range0-9999 , %Gui_PV4%
Gui , Add , Checkbox , yp-3 x+20 gGui_CB_SAV vGui_Set_AHK_Version Checked%Set_AHK_Version% , %Lang_Set_AHK_Version%
Gui , Add , Checkbox , xp yp+16 gGui_CB_INC vGui_Inc_Product_Version Checked%Inc_Product_Version% , %Lang_Autoincrement%
Gui , Font , cNavy
Gui , Add , Text , xs y+7 h20 w120 +0x1000 vGui_Text_Language_ID , %Lang_Language_ID%
Gui , Font , cBlack
Gui , Add , DropDownList , x+20 w200 yp AltSubmit Choose%Language_ID% vGui_Language_ID , %Language_IDS%
Gui , Font , cNavy
Gui , Add , Text , xs y+7 h20 w120 +0x1000 vGui_Text_Charset , %Lang_Charset%
Gui , Font , cBlack
Gui , Add , DropDownList , x+20 w200 yp AltSubmit Choose%Charset% vGui_Charset , %Charsets%
Gui , Tab , 3
Gui , Font , cNavy
Gui , Add , Text , Section x+20 y+20 h20 w130 +0x1000 vGui_Text_Icon_1 , %Lang_Main_Icon%
Gui , Add , Checkbox , x+20 yp vGui_Icon_1_Set gGuiActivateIcon Checked%Icon_1_Set%
Gui , Font , cBlack
Gui , Add , Edit , x+0 yp h20 w190 vGui_Icon_1 gGuiEDIcon , %Icon_1%
Gui , Add , Button , x+20 yp h20 w70 vGui_Icon_1_BT gGuiBTSelIcon , %Lang_Select%
Gui , Add , Picture , x+20 yp-5 w32 h32 vGui_Icon_1_Pic , %Icon_1%
Gui , Add , Checkbox , xs w100 yp+28 vGui_Icon_1_Delete gGuiActivateIcon Checked%Icon_1_Delete% , %Lang_Delete%
Gui , Font , cNavy
Gui , Add , Text , Section xs y+8 h20 w130 +0x1000 vGui_Text_Icon_2 , %Lang_Shortcut_Icon%
Gui , Font , cBlack
Gui , Add , Checkbox , x+20 yp vGui_Icon_2_Set gGuiActivateIcon Checked%Icon_2_Set%
Gui , Add , Edit , x+0 yp h20 w190 vGui_Icon_2 gGuiEDIcon , %Icon_2%
Gui , Add , Button , x+20 yp h20 w70 vGui_Icon_2_BT gGuiBTSelIcon , %Lang_Select%
Gui , Add , Picture , x+20 yp-5 w32 h32 vGui_Icon_2_Pic , %Icon_2%
Gui , Add , Checkbox , xs w100 yp+28 vGui_Icon_2_Delete gGuiActivateIcon Checked%Icon_2_Delete% , %Lang_Delete%
Gui , Font , cNavy
Gui , Add , Text , Section xs y+8 h20 w130 +0x1000 vGui_Text_Icon_3 , %Lang_Suspend_Icon%
Gui , Font , cBlack
Gui , Add , Checkbox , x+20 yp vGui_Icon_3_Set gGuiActivateIcon Checked%Icon_3_Set%
Gui , Add , Edit , x+0 yp h20 w190 vGui_Icon_3 gGuiEDIcon , %Icon_3%
Gui , Add , Button , x+20 yp h20 w70 vGui_Icon_3_BT gGuiBTSelIcon , %Lang_Select%
Gui , Add , Picture , x+20 yp-5 w32 h32 vGui_Icon_3_Pic , %Icon_3%
Gui , Add , Checkbox , xs w100 yp+28 vGui_Icon_3_Delete gGuiActivateIcon Checked%Icon_3_Delete% , %Lang_Delete%
Gui , Font , cNavy
Gui , Add , Text , Section xs y+8 h20 w130 +0x1000 vGui_Text_Icon_4 , %Lang_Pause_Icon%
Gui , Font , cBlack
Gui , Add , Checkbox , x+20 yp vGui_Icon_4_Set gGuiActivateIcon Checked%Icon_4_Set%
Gui , Add , Edit , x+0 yp h20 w190 vGui_Icon_4 gGuiEDIcon , %Icon_4%
Gui , Add , Button , x+20 yp h20 w70 vGui_Icon_4_BT gGuiBTSelIcon , %Lang_Select%
Gui , Add , Picture , x+20 yp-5 w32 h32 vGui_Icon_4_Pic , %Icon_4%
Gui , Add , Checkbox , xs w100 yp+28 vGui_Icon_4_Delete gGuiActivateIcon Checked%Icon_4_Delete% , %Lang_Delete%
Gui , Font , cNavy
Gui , Add , Text , Section xs y+8 h20 w130 +0x1000 vGui_Text_Icon_5 , %Lang_Suspend_Pause_Icon%
Gui , Font , cBlack
Gui , Add , Checkbox , x+20 yp vGui_Icon_5_Set gGuiActivateIcon Checked%Icon_5_Set%
Gui , Add , Edit , x+0 yp h20 w190 vGui_Icon_5 gGuiEDIcon , %Icon_5%
Gui , Add , Button , x+20 yp h20 w70 vGui_Icon_5_BT gGuiBTSelIcon , %Lang_Select%
Gui , Add , Picture , x+20 yp-5 w32 h32 vGui_Icon_5_Pic , %Icon_5%
Gui , Add , Checkbox , xs w100 yp+28 vGui_Icon_5_Delete gGuiActivateIcon Checked%Icon_5_Delete% , %Lang_Delete%
/*
Gui , Font , cNavy
Gui , Add , Text , Section xs y+8 h20 w130 +0x1000 vGui_Text_Icon_6 , %Lang_Main_Icon_9x%
Gui , Font , cBlack
Gui , Add , Checkbox , x+20 yp vGui_Icon_6_Set gGuiActivateIcon Checked%Icon_6_Set%
Gui , Add , Edit , x+0 yp h20 w190 vGui_Icon_6 gGuiEDIcon , %Icon_6%
Gui , Add , Button , x+20 yp h20 w70 vGui_Icon_6_BT gGuiBTSelIcon , %Lang_Select%
Gui , Add , Picture , x+20 yp-5 w32 h32 vGui_Icon_6_Pic , %Icon_6%
Gui , Add , Checkbox , xs w100 yp+28 vGui_Icon_6_Delete gGuiActivateIcon Checked%Icon_6_Delete% , %Lang_Delete%
Gui , Font , cNavy
Gui , Add , Text , Section xs y+8 h20 w130 +0x1000 vGui_Text_Icon_7 , %Lang_Suspend_Icon_9x%
Gui , Font , cBlack
Gui , Add , Checkbox , x+20 yp vGui_Icon_7_Set gGuiActivateIcon Checked%Icon_7_Set%
Gui , Add , Edit , x+0 yp h20 w190 vGui_Icon_7 gGuiEDIcon , %Icon_7%
Gui , Add , Button , x+20 yp h20 w70 vGui_Icon_7_BT gGuiBTSelIcon , %Lang_Select%
Gui , Add , Picture , x+20 yp-5 w32 h32 vGui_Icon_7_Pic , %Icon_7%
Gui , Add , Checkbox , xs w100 yp+28 vGui_Icon_7_Delete gGuiActivateIcon Checked%Icon_7_Delete% , %Lang_Delete%
*/
Gui , Tab , 4
Gui , Add , ListView , x+20 y+20 w500 h286 Grid vGui_Resource_ListView , %Lang_Resource_ListView%
Gui , Add , Button , xp+145 y+10 w100 h23 vGui_Add_Resource gSelect_Resource , %Lang_Add_Resource%
Gui , Add , Button , x+10 yp w100 h23 vGui_Remove_Resource gRemove_Resource , %Lang_Remove_Resource%
Gui , Tab
Gui , Add , Button , Default xs y370 h25 w70 vGui_Compile gGuiBTCompile , %Lang_Compile%
Gui , Add , Button , xp+430 yp h25 w80 vGui_Cancel gGuiClose , %Lang_Cancel%
Gui , Add , Picture , xm+294 ym+4 h16 w16 hidden vGui_ON_TOP_ON gGui_ON_TOP_OFF AltSubmit Icon2 , %A_ScriptName%
Gui , Add , Picture , xm+294 ym+4 h16 w16 vGui_ON_TOP_OFF gGui_ON_TOP_ON AltSubmit Icon3 , %A_ScriptName%
Gui , Add , Button , xm+314 ym h25 w80 vGui_Save_Defaults gGuiSave_Defaults , %Lang_Save_Defaults%
Gui , Add , Button , xm+394 ym h25 w60 vGui_Credits gShowCredits , &%Lang_Credits%
LangHelp_AddLangDropDownMenu(possibleLangs, Lang_MenulanguageTitel, actualLang)
If (Resource_Files)
Add_Resource(Resource_Files)
GoSub , Gui_CB_INC
GoSub , Gui_CB_SAV
If (!Set_Version_Info) {
_Gui_DeActivate_Version_Info("Disable")
}
; GoSub , GuiShowPwd
GoSub , GuiActivateIcon
GoSub , GuiActivateAltBin
If Auto_Compile
GoSub , GuiBTCompile
Else
{
OnMessage(0x200, "WM_MOUSEMOVE") ; tooltips
Gui , Show , Autosize , %Gui_Title% v%CAHK_Version% - %IN_NAME%.%IN_EXT%
}
GuiControl , Focus , Compile
Return
; --------------------------------------------------------------------------------
; Gui Close
; --------------------------------------------------------------------------------
GuiClose:
GuiEscape:
Gui , Destroy
Error_Message := "Compilation canceled!"
_Error_Exit(Error_Message)
Return
; --------------------------------------------------------------------------------
; Gui 2 Close
; --------------------------------------------------------------------------------
2GuiEscape:
2GuiClose:
Gui 1:-Disabled
Gui 2:Destroy
Return
; --------------------------------------------------------------------------------
; Gui Drop Files
; --------------------------------------------------------------------------------
GuiDropFiles:
Gui , Submit , NoHide
IfInString , A_GuiControl , Gui_Icon_
IfNotInString , A_GuiControl , _Set
GuiControl , , %A_GuiControl% , %A_GuiEvent%
Return
; --------------------------------------------------------------------------------
; Gui Button Select Exe File
; --------------------------------------------------------------------------------
GuiBTSelFile:
Gui , Submit , NoHide
SplitPath , Gui_Exe_File , Out_Name , Out_Dir
_Select_FOLDER(Out_Dir)
GuiControl , , Gui_Exe_File , %Out_Dir%\%Out_Name%
Return
; --------------------------------------------------------------------------------
; Gui Save Default Settings
; --------------------------------------------------------------------------------
GuiSave_Defaults:
Gui , Submit , NoHide
If !_Get_Gui_Values() {
Return
}
_WRITE_INI(Defaults_Ini)
Return
; --------------------------------------------------------------------------------
; Gui OnTop On
; --------------------------------------------------------------------------------
Gui_ON_TOP_ON:
Gui , +AlwaysOnTop
GuiControl , Hide , Gui_ON_TOP_OFF
GuiControl , Show , Gui_ON_TOP_ON
Return
; --------------------------------------------------------------------------------
; Gui OnTop Off
; --------------------------------------------------------------------------------
Gui_ON_TOP_OFF:
Gui , -AlwaysOnTop
GuiControl , Hide , Gui_ON_TOP_ON
GuiControl , Show , Gui_ON_TOP_OFF
Return
; --------------------------------------------------------------------------------
; Gui Button Select Icon
; --------------------------------------------------------------------------------
GuiActivateIcon:
Gui , Submit , NoHide
Loop , %Icon_Count% {
TempControlName = Gui_Icon_%A_Index%_Set
TempControl2Name = Gui_Icon_%A_Index%_Delete
TempControl2State := %TempControl2Name%
GuiControl , Disable%TempControl2State% , Gui_Text_Icon_%A_Index%
GuiControl , Disable%TempControl2State% , Gui_Icon_%A_Index%_Set
GuiControl , Disable%TempControl2State% , Gui_Icon_%A_Index%
GuiControl , Disable%TempControl2State% , Gui_Icon_%A_Index%_BT
GuiControl , Disable%TempControl2State% , Gui_Icon_%A_Index%_Pic
If (%TempControlName% AND !%TempControl2Name%) {
; enable
GuiControl , Enable , Gui_Icon_%A_Index%
GuiControl , Enable , Gui_Icon_%A_Index%_BT
} Else {
; disable
GuiControl , , Gui_Icon_%A_Index%_Set , 0
GuiControl , Disable , Gui_Icon_%A_Index%
GuiControl , Disable , Gui_Icon_%A_Index%_BT
GuiControl , , Gui_Icon_%A_Index% ,
GuiControl , , Gui_Icon_%A_Index%_Pic ,
}
}
Return
GuiActivateAltBin:
Gui , Submit , NoHide
If (Gui_Alt_Bin_Set)
{
; enable
GuiControl , Enable , Gui_Alt_Bin
GuiControl , Enable , Gui_Select_Alt_Bin
Alt_Bin_Set := 1
}
Else
{
; disable
GuiControl , Disable , Gui_Alt_Bin
GuiControl , Disable , Gui_Select_Alt_Bin
GuiControl , , Gui_Alt_Bin
Alt_Bin_Set := 0
}
Return
; --------------------------------------------------------------------------------
; Gui Button Generate Password
; --------------------------------------------------------------------------------
;Gui_Gen_Pass:
; GuiControl , , Gui_Password , % GenPassword()
;Return
; --------------------------------------------------------------------------------
; Password Generator by Titan / www.autohotkey.net
; --------------------------------------------------------------------------------
;GenPassword(l=30, chars=3)
;{
; cAlpha = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
; cNum = 1234567890
; cAlphaNum = %cAlpha%%cNum%
; cMutation = äöüáéíóúàèìòùÄÖÜßÁÉÍÓÚÀÈÌÒÙ
; cMixed = %cAlphaNum%%cMutation%.%A_Space%!"£$`%^&*()_-=+{}[]`;:``@'#~<>,./?\|¬¦
; If chars in 0,alphanum
; StringSplit , list , cAlphaNum
; else If chars in 1,alpha
; StringSplit , list , cAlpha
; else If chars in 2,num
; StringSplit , list , cNum
; else If chars in 3,mixed
; StringSplit , list , cMixed
; Random , rnd , 0 , %list0%
; l += rnd
; Loop , %l%
; {
; Random , rnd , 1 , %list0%
; i := list%rnd%
; pass = %pass%%i%
; }
; Return , %pass%
;}
; --------------------------------------------------------------------------------
; Gui Button Select AutoHotkey.bin
; --------------------------------------------------------------------------------
GuiBTSelBin:
Gui , Submit , NoHide
_Select_FILE(Gui_Alt_Bin , "BIN")
GuiControl , , Gui_Alt_Bin , %Gui_Alt_Bin%
Alt_Bin := Gui_Alt_Bin
Return
; --------------------------------------------------------------------------------
; Gui Button Select Icon
; --------------------------------------------------------------------------------
GuiBTSelIcon:
Gui , Submit , NoHide
Error_Message := "Error Selecting icon file!`n"
; icon fix for Win9x by Drugwash
if A_OSType in WIN32_WINDOWS
shell := A_WinDir . "\system\shell32.dll"
else
shell := A_WinDir . "\system32\shell32.dll"
VarSetCapacity(SourceFile , 260)
SourceFileName := "Gui_Icon_" . SubStr(A_GuiControl , -3 , 1)
SourceFile := %SourceFileName%
If (SourceFile = "" || !FileExist(SourceFile))
SourceFile := shell
nIndex := 0
; WinGet , hWnd , ID , PickIconDlg
WinGet , hWnd , ID , A
; icon fix for Win9x by Drugwash
if A_OSType in WIN32_WINDOWS
{
If !DllCall(DllCall("GetProcAddress", "Uint", DllCall("LoadLibrary", "str", "shell32.dll"), "Uint", 62), "Uint", hWnd, "Uint", &SourceFile, "Uint", 260, "intP", nIndex)
Return ; cancel was clicked or something else failed
DllCall("FreeLibrary", "str", "shell32.dll")
}
else
{
; VarSetCapacity(wSourceFile , 260 * 2)
; DllCall("MultiByteToWideChar" , "Uint" , 0 , "Uint" , 0 , "str" , SourceFile , "int" , -1 , "str" , wSourceFile , "int" , 260)
If !(A_IsUnicode)
{
VarSetCapacity(wSourceFile , 260 * 2)
DllCall("MultiByteToWideChar" , "Uint" , 0 , "Uint" , 0 , "str" , SourceFile , "int" , -1 , "str" , wSourceFile , "int" , 260)
}
Else
{
wSourceFile := SourceFile
}
If !DllCall("shell32\PickIconDlg" , "Uint" , hWnd , "str" , wSourceFile , "Uint" , 260 , "intP" , nIndex)
Return ; cancel was clicked or something else failed
; VarSetCapacity(SourceFile , 260)
; DllCall("WideCharToMultiByte" , "Uint" , 0 , "Uint" , 0 , "str" , wSourceFile , "int" , -1 , "str" , SourceFile , "int" , 260 , "Uint" , 0 , "Uint" , 0)
If !(A_IsUnicode)
{
VarSetCapacity(SourceFile , 260)
DllCall("WideCharToMultiByte" , "Uint" , 0 , "Uint" , 0 , "str" , wSourceFile , "int" , -1 , "str" , SourceFile , "int" , 260 , "Uint" , 0 , "Uint" , 0)
}
Else
{
SourceFile := wSourceFile
}
StringReplace , SourceFile , SourceFile , `%SystemRoot`% , %A_WinDir%
}
IconFile := In_File . "_" . SubStr(A_GuiControl , -3 , 1) . ".ico"
SplitPath , IconFile , IconFileName
SplitPath , SourceFile , , SourceFileDir , SourceFileExt
StringLower, %SourceFileExt%, %SourceFileExt%
If (SourceFileExt = "ICO")
{
If (SourceFileDir = In_Dir)
IconFile := SourceFile
Else
{
Button1Name = &Use original
Button2Name = &Create copy
MsgBoxTitle = Choice required
MsgBoxText = Do you want to use the icon from its original folder or create a copy in your script's folder and use the copy (recommended)?
SetTimer , ChangeButtonNames , 50
MsgBox , 289 , %MsgBoxTitle% , %MsgBoxText%
IfMsgBox , OK
{
IconFile := SourceFile
}
Else
{
IfExist , %IconFile%
{
Button1Name = &Replace
Button2Name = Re&name
Button3Name = Cancel
MsgBoxTitle = Choice required
MsgBoxText = %IconFileName% already exists.`nDo you want to replace or rename it?
SetTimer , ChangeButtonNames , 50
MsgBox , 51 , %MsgBoxTitle% , %MsgBoxText%
IfMsgBox , Cancel
Return
IfMsgBox , No
Loop
{
StringReplace , NewIconFile , IconFile , .ico , _%A_Index%.ico
IfExist , %NewIconFile%
Continue
IconFile := NewIconFile
Break
}
}
; IfMsgBox = Yes / No -->
FileCopy , %SourceFile% , %IconFile% , 1
If (ErrorLevel)
{
s_ERR := "Replacing " . IconFile . " by " . SourceFile . " failed!"
_Error_Exit(Error_Message . s_ERR)
}
}
}
}
Else
{
IfExist , %IconFile%
{
Button1Name = &Replace
Button2Name = Re&name
Button3Name = Cancel
MsgBoxTitle = Choice required
MsgBoxText = %IconFileName% already exists.`nDo you want to replace or rename it?
SetTimer , ChangeButtonNames , 50
MsgBox , 51 , %MsgBoxTitle% , %MsgBoxText%
IfMsgBox , Cancel
Return
IfMsgBox , No
Loop
{
StringReplace , NewIconFile , IconFile , .ico , _%A_Index%.ico
IfExist , %NewIconFile%
Continue
IconFile := NewIconFile
Break
}
}
; ResHacker uses ResourceIds instead of IconIndex
IconGroupID := ResourceIdOfIcon(SourceFile , nIndex)
s_Sc_File := A_WorkingDir . "\ExtractIcon.script"
s_Script := "[FILENAMES]`n"
. "Exe=" . SourceFile . "`n"
. "SaveAs=" . IconFile . "`n"
. "Log=" . A_WorkingDir . "\" . Res_Log . "`n"
. "[COMMANDS]`n"
. "-extract """ . IconFile . """ , ICONGROUP , " . IconGroupID . " , "
FileDelete , %s_Sc_File%
FileAppend , %s_Script% , %s_Sc_File%
s_CMD := """" . A_ScriptDir . "\" Res_Exe . """"
. " -script "
. """" . s_Sc_File . """"
FileAppend , `n* Extract Icon from file:`n%s_CMD%`n, %A_WorkingDir%\%Log_File%
RunWait , %s_CMD% , , UseErrorLevel Hide
If Errorlevel
{
FileRead , s_Log , A_WorkingDir . "\" . %Res_Log%
s_ERR := "Couldn't extract icon file , " . Res_Exe . " failed!`n" . s_Log
_Error_Exit(Error_Message . s_ERR)
}
FileRead , s_Log , %A_WorkingDir%\%Res_Log%
IfInString , s_Log , ERROR:
{
s_ERR := "Couldn't extract icon file , " . Res_Exe . " failed!`n" . s_Log
_Error_Exit(Error_Message . s_ERR)
}
FileDelete , %A_WorkingDir%\%Res_Log%
FileAppend , `n~~ Reshacker Log Start ~~`n%s_Log%~~ Reshacker Log End ~~`n`n# Manifest extracted successfully!`n`n , %A_WorkingDir%\%Log_File%
}
GuiControl , , %SourceFileName% , %IconFile%
Return
; --------------------------------------------------------------------------------
; Change Button Names
; --------------------------------------------------------------------------------
ChangeButtonNames:
IfWinNotExist , %MsgBoxTitle%
Return ; Keep waiting.
SetTimer , ChangeButtonNames , off
WinActivate
ControlSetText , Button1 , %Button1Name%
ControlSetText , Button2 , %Button2Name%
ControlSetText , Button3 , %Button3Name%
Return
; --------------------------------------------------------------------------------
; Gui Edit Icon
; --------------------------------------------------------------------------------
GuiEDIcon:
Gui , Submit , NoHide
SourceFile := %A_GuiControl%
If (CHECK_ICON(SourceFile))
GuiControl , , %A_GuiControl%_Pic , *w32 *h32 %SourceFile%
Else
GuiControl , , %A_GuiControl%_Pic
Return
; --------------------------------------------------------------------------------
; Gui Button Select Show or Hide Password
; --------------------------------------------------------------------------------
;GuiShowPwd:
; Gui , Submit , NoHide
; If (Gui_Show_Pwd)
; GuiControl , -Password , Gui_Password
; Else
; GuiControl , +Password , Gui_Password
; GuiControl , Focus , Gui_Password
;Return
; --------------------------------------------------------------------------------
; Gui Button Select Run Before
; --------------------------------------------------------------------------------
GuiBTRunBefore:
Gui , Submit , NoHide
_Select_FILE(Gui_Run_Before , "RUN")
GuiControl , , Gui_Run_Before , %Gui_Run_Before%
Return
; --------------------------------------------------------------------------------
; Gui Button Select Run After
; --------------------------------------------------------------------------------
GuiBTRunAfter:
Gui , Submit , NoHide
_Select_FILE(Gui_Run_After , "RUN")
GuiControl , , Gui_Run_After , %Gui_Run_After%
Return
; --------------------------------------------------------------------------------
; Gui Checkbox Version Info
; --------------------------------------------------------------------------------
Gui_CB_VI:
Gui , Submit , NoHide
If (Gui_Set_Version_Info) {
_Gui_DeActivate_Version_Info("Enable")
} Else {
_Gui_DeActivate_Version_Info("Disable")
}
Return
; --------------------------------------------------------------------------------
; Gui Checkbox Set AHK Version
; --------------------------------------------------------------------------------
Gui_CB_SAV:
Gui , Submit , NoHide
If (Gui_Set_AHK_Version)
{
GuiControl , Disable , Gui_Inc_Product_Version
GuiControl , , Gui_Inc_Product_Version , 0
;split BIN_Version to four values
If (Alt_Bin_Set = 1 and Alt_Bin != "")
FileGetVersion,s_OrgBin,%Alt_Bin%
Else
FileGetVersion,s_OrgBin,%Bin_File%
StringSplit , a_V , s_OrgBin , .
Loop , %a_V0%
{
GuiControl , Disable , Gui_TPV%A_Index%
Value := a_V%A_Index%
GuiControl , , Gui_TPV%A_Index% , %Value%
}
}
Else
{
GuiControl , Enable , Gui_Inc_Product_Version
If (!Gui_Inc_Product_Version)
Loop , %a_V0%
GuiControl , Enable , Gui_TPV%A_Index%
}
Return
; --------------------------------------------------------------------------------
; Gui Autoincrement Version
; --------------------------------------------------------------------------------
Gui_CB_INC:
Gui , Submit , NoHide
;split Product_Version and File_Version to four values
StringSplit , a_PV , Product_Version , .
StringSplit , a_FV , File_Version , .
If (A_GuiControl = "Gui_Inc_Product_Version" || A_GuiControl = "")
{
If (Gui_Inc_Product_Version)
{
GuiControl , Disable , Gui_Set_AHK_Version
GuiControl , , Gui_Set_AHK_Version , 0
Inc_Version_Helper("PV")
}
Else {
GuiControl , Enable , Gui_Set_AHK_Version
Loop , %a_PV0%
GuiControl , Enable , Gui_TPV%A_Index%
}
}
If (A_GuiControl = "Gui_Inc_File_Version" || A_GuiControl = "")
{
If (Gui_Inc_File_Version)
{
Inc_Version_Helper("FV")
}
Else {
Loop , %a_FV0%
GuiControl , Enable , Gui_TFV%A_Index%
}
}
Return
; --------------------------------------------------------------------------------
; Increments version - type: FV or PV
; --------------------------------------------------------------------------------
Inc_Version_Helper(Type)
{
Global
increment = 1
Loop % a_%Type%0
{
ReverseIndex := 5 - A_Index
GuiControl , Disable , Gui_T%Type%%ReverseIndex%
;Set old version's value
Value := a_%Type%%ReverseIndex%