forked from Codehimn/AutoItScript
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Include_Helper.au3
677 lines (611 loc) · 24.3 KB
/
Include_Helper.au3
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
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_OutFile=Include_Helper.exe
#AutoIt3Wrapper_icon=Include_Helper.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseAnsi=y
#AutoIt3Wrapper_Res_Comment=-
#AutoIt3Wrapper_Res_Description=Include_Helper.exe
#AutoIt3Wrapper_Res_Fileversion=0.1.0.0
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=n
#AutoIt3Wrapper_Res_LegalCopyright=AZJIO
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Run_AU3Check=n
#AutoIt3Wrapper_Res_Field=Version|0.1
#AutoIt3Wrapper_Res_Field=Build|2011.08.08
#AutoIt3Wrapper_Res_Field=Coded by|AZJIO
#AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time%
#AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; @AZJIO 8.08.2011
#cs
Notepad++\shortcuts.xml
<Command name="Include_Helper" Ctrl="yes" Alt="no" Shift="no" Key="118">"$(NPP_DIRECTORY)\..\AutoIt3.exe" "$(NPP_DIRECTORY)\Instrument_azjio\Include_Helper.au3" "$(FULL_CURRENT_PATH)"</Command>
SciTE\Properties\au3.properties
# 39 Include_Helper
command.39.*.au3="$(autoit3dir)\autoit3.exe" "$(SciteDefaultHome)\Instrument_azjio\Include_Helper.au3" "$(FilePath)"
command.name.39.*.au3=Include_Helper
command.save.before.39.*.au3=1
command.is.filter.39.*.au3=1
command.shortcut.39.*.au3=Ctrl+F7
#ce
#include <Array.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#NoTrayIcon
; En
$LngFOD='Locate your script'
$LngClp='Copy to Clipboard'
$LngTmr='time'
$LngTm2='sec'
$LngFSF='Select Folder Containing Include Files'
$LngMsB1='Error'
$LngMsB2='Files not found'
$LngMsB3='Remove the old database file to create a new'
$LngMsB4='Message'
$LngMsB5='"Constants" and "Functions" is not found'
$LngMsB6='There are no functions and variables in the file'
$LngAll='All'
$LngMsn='Missing'
$LngUnn='Unnecessary'
$LngAtS='Everything in script'
$LngMtS='Add missing'
$LngUtS='Remove excess'
$LngAtSH='Removes from script, all of the "Include"'&@CRLF&'and adds to the beginning of the script a list of "'&$LngAll&'"'
$LngMtSH='Adds to the beginning of the script a list of "'&$LngMsn&'"'
$LngUtSH='Deletes from a script "Include"'&@CRLF&'specified in the "'&$LngUnn&'"'
$LngLog='Statistics selection'
$LngUpd='v'
$LngUpdH='Update database file'&@CRLF&'Include_Helper_Data.txt'
$Lang_dll = DllOpen("kernel32.dll")
$UserIntLang=DllCall ( $Lang_dll, "int", "GetUserDefaultUILanguage" )
If Not @error Then $UserIntLang=Hex($UserIntLang[0],4)
DllClose($Lang_dll)
; Ru
; åñëè ðóññêàÿ ëîêàëèçàöèÿ, òî ðóññêèé ÿçûê
If $UserIntLang = 0419 Then
$LngFOD='Âûáåðèòå âàø ñêðèïò'
$LngClp='Â áóôåð'
$LngTmr='âðåìÿ'
$LngTm2='ñåê'
$LngFSF='Âûáðàòü ïàïêó Include'
$LngMsB1='Îøèáêà'
$LngMsB2='Ôàéëû íå íàéäåíû'
$LngMsB3='Óäàëèòå ñòàðûé ôàéë áàçû, ÷òîáû ñîçäàëñÿ íîâûé'
$LngMsB4='Ñîîáùåíèå'
$LngMsB5='Êîíàñòàíòû è ôóíêöèè íå íàéäåíû'
$LngMsB6='Îòñóòñòâóþò ôóíêöèè è ïåðåìåííûå â ôàéëå'
$LngAll='Âñå'
$LngMsn='Íåäîñòàþùèå'
$LngUnn='Ëèøíèå'
$LngAtS='Âñå â ñêðèïò'
$LngMtS='Äîáàâèòü íåäîñòàþùèå'
$LngUtS='Óäàëèòü ëèøíèå'
$LngAtSH='Óäàëÿåò èç ñêðèïòà âñå Include'&@CRLF&'è äîáàâëÿåò â íà÷àëî ñïèñîê "'&$LngAll&'"'
$LngMtSH='Äîáàâëÿåò â íà÷àëî ñêðèïòà'&@CRLF&'ñïèñîê "'&$LngMsn&'"'
$LngUtSH='Óäàëÿåò èç ñêðèïòà Include'&@CRLF&'óêàçàííûå â ñïèñêå "'&$LngUnn&'"'
$LngLog='Ñòàòèñòèêà îòáîðà'
$LngUpd='v'
$LngUpdH='Îáíîâèòü ôàéë áàçû'&@CRLF&'Include_Helper_Data.txt'
EndIf
Global $StatLog=''
; Global $aConstantsData
If $CmdLine[0]>0 Then
$Path_AU3 = $CmdLine[1]
Else
$Path_AU3 = FileOpenDialog($LngFOD, @WorkingDir, "AutoIt Script (*.au3)", 1)
If @error Then Exit
EndIf
Global $Path=@ScriptDir&'\Include_Helper_Data.txt'
If Not FileExists($Path) Then _CreateData()
$timer = TimerInit()
Global $DataFile = FileRead($Path)
$aDataFile = StringSplit($DataFile, @CRLF&'|'&@CRLF, 1)
If @error Or Not(IsArray($aDataFile) And $aDataFile[0]=4) Then
MsgBox(0, $LngMsB1, $LngMsB3)
Exit
EndIf
$aConstantsData = StringSplit($aDataFile[1], @CRLF, 1)
$aFunctionsData = StringSplit($aDataFile[2], @CRLF, 1)
$aIncludeData = StringSplit($aDataFile[4], @CRLF, 1)
$DataFile = $aDataFile[3]
$script_text = FileRead($Path_AU3)
_stripComments($script_text) ; óäàëåíèå êîììåíòàðèåâ
$script_text = StringRegExpReplace($script_text, '_[\r\n]+', '') ; óäàëåíèå ïåðåíîñîâ ñòðîê
; $script_text=StringRegExpReplace($script_text, '(\r\n){2,}', '\1')
; $script_text = StringStripWS($script_text, 3)
$Include_script=StringRegExp($script_text, '(?i)(?=\A|\s)\s*#include\s*[\x3c\x22\x27]*([^\r\n]+?\.au3)', 3) ; âîçâðàùàåò include óêàçàííûå â ñêðèïòå
$Include=''
$exist=0
$a=_Search_Var($script_text) ; âîçâðàùàåò ñòðîêó ïåðåìåííûõ ñêðèïòà â îäíîì ýêçåìïëÿðå
If Not @error Then
For $i = 1 to $aConstantsData[0]
$tmp=_Search_Include($aConstantsData[$i]&$a)
If Not @error Then $Include&=$tmp&';'
Next
$exist=1
EndIf
$a=_Search_Fun1($script_text) ; âîçâðàùàåò ìàññèâ áåç ïîâòîðîâ
If @error And $exist=0 Then
MsgBox(0, $LngMsB1, $LngMsB6)
Exit
EndIf
$text=StringRegExp($script_text, '(?mi)^\h*Func\h+(\w+)', 3) ; äîáàâëÿåì ôóíêöèè ñêðèïòà
$DataFile&=';'&_ArrayToString($text, ';')
$a=_Search_Fun2($a) ; âîçâðàùàåò ôóíêöèè â ñòðîêå èñêëþ÷àÿ ñòàíäàðòíûå ôóíêöèè è ôóíêöèè ñêðèïòà
For $i = 1 to $aFunctionsData[0]
$tmp=_Search_Include($aFunctionsData[$i]&$a)
If Not @error Then $Include&=$tmp&';'
Next
$Include=StringTrimRight($Include, 1)
; Ìèíèìèçèðîâàòü êîëè÷åñòâî Include
Dim $b[$aIncludeData[0]+1][2]
$b[0][0]=$aIncludeData[0]
For $i = 1 to $aIncludeData[0]
$tmp=StringRegExp($aIncludeData[$i], '(?i)^(.*?);(.*)$', 3)
If Not @error Then
$b[$i][0]=$tmp[0]
$b[$i][1]=';'&$tmp[1]&';'
EndIf
Next
$z=';'&$Include&';'
$aInclude = StringSplit($Include, ';')
If Not @error Then
For $i = 1 to $aInclude[0]
If $aInclude[$i]<>'' Then
$aInd = _ArrayFindAll($b, ';'&$aInclude[$i]&';', 1, 0, 0, 1, 1)
If Not @error Then
For $n= 0 to UBound($aInd)-1
If StringInStr($z, ';'&$b[$aInd[$n]][0]&';') Then
$z=StringReplace($z, ';'&$aInclude[$i]&';', ';')
For $j= 1 to $aInclude[0]
If $b[$aInd[$n]][0]=$aInclude[$j] Then $aInclude[$j]=''
Next
ExitLoop
EndIf
Next
EndIf
EndIf
Next
EndIf
$z=StringTrimLeft($z, 1)
$Include=StringTrimRight($z, 1)
; êîíåö
$kol=0
; âñå
$IncludeAll=''
$IncludeAll0=''
$kA=0
$aInclude = StringSplit($Include, ';')
If Not @error Then
$kA=$aInclude[0]
For $i = 1 to $kA
$IncludeAll0&='#include <'&$aInclude[$i]&'>'&@CRLF
Next
$IncludeAll&=@CRLF&$LngAll&@CRLF&$IncludeAll0
$kol+=$kA
EndIf
; íåäîñòþùèå
$Missing=''
$Missing0=''
$kM=0
$aMissing=_Missing($Include_script, $aInclude)
If Not @error Then
$kM=UBound($aMissing)
For $i = 0 to $kM-1
$Missing0&='#include <'&$aMissing[$i]&'>'&@CRLF
Next
$Missing&=@CRLF&$LngMsn&@CRLF&$Missing0
$kol+=$kM
EndIf
; ëèøíèå
$Unnecessary=''
$Unnecessary0=''
$kU=0
$aUnnecessary=_Unnecessary($aInclude, $Include_script)
If Not @error Then
$kU=UBound($aUnnecessary)
For $i = 0 to $kU-1
$Unnecessary0&='#include <'&$aUnnecessary[$i]&'>'&@CRLF
Next
$Unnecessary&=@CRLF&$LngUnn&@CRLF&$Unnecessary0
$kol+=$kU
EndIf
$kol+=5
If $kol >20 Then $kol = 25
$h=$kol*15+65
If $h<205 Then $h=170
GUICtrlSetResizing(-1, 802)
$GUI=GUICreate('Include Helper AZJIO', 420, $h, -1, -1, $WS_OVERLAPPEDWINDOW)
If Not @compiled Then GUISetIcon(@ScriptDir&'\Include_Helper.ico')
$BtnAtC = GUICtrlCreateButton('^', 260, 10, 20, 24)
GUICtrlSetResizing(-1, 4 + 32 + 256 + 512)
GUICtrlSetTip(-1, $LngClp)
$BtnAtS = GUICtrlCreateButton($LngAtS, 285, 10, 130, 24)
GUICtrlSetResizing(-1, 4 + 32 + 256 + 512)
GUICtrlSetTip(-1, $LngAtSH)
If $kA = 0 Then
GUICtrlSetState($BtnAtC, $GUI_DISABLE)
GUICtrlSetState($BtnAtS, $GUI_DISABLE)
EndIf
$BtnMtC = GUICtrlCreateButton('^', 260, 40, 20, 24)
GUICtrlSetResizing(-1, 4 + 32 + 256 + 512)
GUICtrlSetTip(-1, $LngClp)
$BtnMtS = GUICtrlCreateButton($LngMtS, 285, 40, 130, 24)
GUICtrlSetResizing(-1, 4 + 32 + 256 + 512)
GUICtrlSetTip(-1, $LngMtSH)
If $kM = 0 Then
GUICtrlSetState($BtnMtC, $GUI_DISABLE)
GUICtrlSetState($BtnMtS, $GUI_DISABLE)
EndIf
$BtnUtC = GUICtrlCreateButton('^', 260, 70, 20, 24)
GUICtrlSetResizing(-1, 4 + 32 + 256 + 512)
GUICtrlSetTip(-1, $LngClp)
$BtnUtS = GUICtrlCreateButton($LngUtS, 285, 70, 130, 24)
GUICtrlSetResizing(-1, 4 + 32 + 256 + 512)
GUICtrlSetTip(-1, $LngUtSH)
If $kU = 0 Then
GUICtrlSetState($BtnUtC, $GUI_DISABLE)
GUICtrlSetState($BtnUtS, $GUI_DISABLE)
EndIf
GUICtrlCreateLabel($LngTmr&' : '&Round(TimerDiff($timer) / 1000, 2) & ' '&$LngTm2&@CRLF&StringRegExpReplace($Path_AU3, '(^.*)\\(.*)$', '\2'), 260, 100, 183, 34, 0xC)
GUICtrlSetResizing(-1, 4 + 32 + 256 + 512)
$BtnLog = GUICtrlCreateButton($LngLog, 260, 140, 130, 24)
GUICtrlSetResizing(-1, 4 + 32 + 256 + 512)
$BtnUpd = GUICtrlCreateButton($LngUpd, 395, 140, 20, 24)
GUICtrlSetResizing(-1, 4 + 32 + 256 + 512)
GUICtrlSetTip(-1, $LngUpdH)
$Edit1 = GUICtrlCreateEdit("", 5, 5, 250, $h-10)
GUICtrlSetResizing(-1, 2+4+32+64)
GUICtrlSetData(-1, $IncludeAll&$Missing&$Unnecessary)
GUISetState()
GUIRegisterMsg(0x0024, "WM_GETMINMAXINFO")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $BtnUpd
If FileExists($Path) Then
FileSetAttrib($Path, "-RASHT")
FileDelete($Path)
EndIf
_CreateData()
Case $BtnLog
MsgBox(8192+262144, $LngLog, $StatLog)
Case $BtnAtC
ClipPut(StringTrimRight($IncludeAll0, 2))
Case $BtnMtC
ClipPut(StringTrimRight($Missing0, 2))
Case $BtnUtC
ClipPut(StringTrimRight($Unnecessary0, 2))
Case $BtnAtS
$tmp=FileRead($Path_AU3)
$tmp=StringRegExpReplace($tmp, '(?i)(?=\A|\s)(\s*#include\s*[\x3c\x22\x27]*[^\r\n]+?\.au3[\x3e\x22\x27])', '')
$file = FileOpen($Path_AU3, 2)
FileWrite($file, $IncludeAll0&$tmp)
FileClose($file)
GUICtrlSetState($BtnAtS, $GUI_DISABLE)
Case $BtnMtS
$tmp=FileRead($Path_AU3)
$file = FileOpen($Path_AU3, 2)
FileWrite($file, $Missing0&$tmp)
FileClose($file)
GUICtrlSetState($BtnMtS, $GUI_DISABLE)
Case $BtnUtS
$tmp=FileRead($Path_AU3)
$tmp1=''
For $i = 0 to UBound($aUnnecessary)-1
$tmp1&=StringTrimRight($aUnnecessary[$i], 4)&'|'
Next
$tmp=StringRegExpReplace($tmp, '(?i)(?=\A|\s)(\s*#include\s*[\x3c\x22\x27]*('&StringTrimRight($tmp1, 1)&')\.au3[\x3e\x22\x27])', '')
$file = FileOpen($Path_AU3, 2)
FileWrite($file, $tmp)
FileClose($file)
GUICtrlSetState($BtnUtS, $GUI_DISABLE)
EndSwitch
WEnd
Func _Missing($b, $a)
Local $k
Assign('/', 1, 1)
For $i = 0 To UBound($b)-1
Assign($b[$i]&'/', Eval($b[$i]&'/')+1, 1)
Next
$k=0
For $i = 1 To $a[0]
Assign($a[$i]&'/', Eval($a[$i]&'/')+1, 1)
If Eval($a[$i]&'/') = 1 Then
$a[$k]=$a[$i]
$k+=1
EndIf
Next
If $k = 0 Then Return SetError(1)
ReDim $a[$k]
Return $a
EndFunc
Func _Unnecessary($b, $a)
Local $k
Assign('/', 1, 1)
For $i = 1 To $b[0]
Assign($b[$i]&'/', Eval($b[$i]&'/')+1, 1)
Next
$k=0
For $i = 0 To UBound($a) -1
Assign($a[$i]&'/', Eval($a[$i]&'/')+1, 1)
If Eval($a[$i]&'/') = 1 Then
$a[$k]=$a[$i]
$k+=1
EndIf
Next
If $k = 0 Then Return SetError(1)
ReDim $a[$k]
Return $a
EndFunc
Func _Search_Include($text)
Assign('/', 3, 1)
Local $a = StringSplit($text, ';')
If Not @error Then
For $i = 2 To UBound($a) -1
Assign($a[$i]&'/', Eval($a[$i]&'/')+1, 1)
If Eval($a[$i]&'/') = 2 Then
$StatLog&=$a[1]&' - '&$a[$i]&@CRLF
Return $a[1]
EndIf
Next
Return SetError(1)
Else
Return SetError(1)
EndIf
EndFunc
Func _Search_Var($text)
Assign('/', 1, 1)
Local $z, $k, $a
$z = StringRegExp($text & @CRLF, '(?i)(?<=Const \$)(\w+)', 3) ; èñêëþ÷àåò êîíñòàíòû
If Not @error Then
For $i = 0 To UBound($z) -1
Assign($z[$i]&'/', Eval($z[$i]&'/')+1, 1)
Next
EndIf
$a = StringRegExp($text & @CRLF, '(?<=\$)\w+', 3) ; èñêëþ÷àåò ïîâòîðû
If Not @error Then
$k=''
For $i = 0 To UBound($a) -1
Assign($a[$i]&'/', Eval($a[$i]&'/')+1, 1)
If Eval($a[$i]&'/') = 1 Then
$k&=';'&$a[$i]
EndIf
Next
Return $k
Else
Return SetError(1)
EndIf
EndFunc
Func _Search_Fun2($a)
Local $k, $b
Assign('/', 1, 1)
$b = StringSplit($DataFile, ';')
If Not @error Then
For $i = 1 To $b[0]
Assign($b[$i]&'/', Eval($b[$i]&'/')+1, 1)
Next
$k=''
For $i = 0 To UBound($a) -1
Assign($a[$i]&'/', Eval($a[$i]&'/')+1, 1)
If Eval($a[$i]&'/') = 1 Then
$k&=';'&$a[$i]
EndIf
Next
Return $k
Else
Return SetError(1)
EndIf
EndFunc
Func _Search_Fun1($text)
Assign('/', 1, 1)
Local $a = StringRegExp($text, '(\w+)\h*\([^*]', 3)
If Not @error Then
$k=0
For $i = 0 To UBound($a) -1
Assign($a[$i]&'/', Eval($a[$i]&'/')+1, 1)
If Eval($a[$i]&'/') = 1 Then
$a[$k]=$a[$i]
$k+=1
EndIf
Next
ReDim $a[$k]
Return $a
Else
Return SetError(1)
EndIf
EndFunc
; ñîçäàíèå ôàéëà ôóíêöèé è êîíñòàíò Include_Helper_Data.txt ïðè ïåðâîì çàïóñêå ïðîãðàììû
Func _CreateData()
Local $sAutoIt_Path, $ConstantsData, $search, $file, $text
If $CmdLine[0]>1 Then
$sAutoIt_Path = $CmdLine[2]
Else
$sAutoIt_Path = RegRead("HKLM\SOFTWARE\AutoIt v3\AutoIt", "InstallDir")
If @error Or Not FileExists($sAutoIt_Path) Then
$sAutoIt_Path = RegRead('HKCU\Software\AutoIt v3\Autoit', 'Include')
If @error Or Not FileExists($sAutoIt_Path) Then
$sAutoIt_Path = FileSelectFolder($LngFSF, '')
If @error Then Exit
EndIf
Else
$sAutoIt_Path&="\Include"
EndIf
EndIf
$size = DirGetSize($sAutoIt_Path, 3)
$FunctionsData=''
$ConstantsData=''
$IncludeData=''
$search = FileFindFirstFile($sAutoIt_Path&"\*.au3")
If $search = -1 Then
MsgBox(0, $LngMsB1, $LngMsB2)
Exit
EndIf
ProgressOn("", "Create Data", "", -1, -1, 3)
$KolF=0
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
$KolF+=1
ProgressSet(Int(100/$size[1]*$KolF), $KolF&' / '&$size[1]& ' '&$file)
; If $file = 'GUIConstants.au3' Then $file = 'GUIConstantsEx.au3'
$text=FileRead($sAutoIt_Path&'\'&$file)
_stripComments($text)
$tmp = StringRight($file, 13)
$text2=StringRegExp($text, '(?i)(?=\A|\s)\s*#include\s*[\x3c\x22\x27]*([^\r\n]+?\.au3)', 3) ;âîçâðàùàåò include óêàçàííûå â ñêðèïòå
If Not @error Then $IncludeData&=$file&';'&_ArrayToString($text2, ';')&@CRLF
; êîíñòàíòû èçâëåêàþòñÿ òîëüêî èç ôàéëîâ *Constants.au3 (èñêëþ÷åíèå GUIConstantsEx.au3)
If $tmp = 'Constants.au3' Or $tmp = 'nstantsEx.au3' Then
$text2=StringRegExp($text, '(?i)(?<=Global Const \$)\w+', 3)
If Not @error Then $ConstantsData&=$file&';'&_ArrayToString($text2, ';')&@CRLF
Else
; ôóíêöèè èçâëåêàþòñÿ òîëüêî èç ôàéëîâ íå ÿâëÿþùèåñÿ ôàéëàìè êîíñòàíò. Âíóòðåííèå ôóíêöèè íà÷èíàþùèåñÿ ñ "__" èãíîðèðóþòñÿ
If StringInStr($text, 'GUIRegisterMsg') Then $tmp = StringRegExp($text, '(?i)GUIRegisterMsg\s*\(\s*\$\w+\s*,\s*[\x22\x27](\w+)', 3)
$text2=StringRegExp($text, '(?mi)^\h*Func\h+(\w+)', 3)
If Not @error Then
$text2=_Del_re($text2)
If IsArray($tmp) Then
For $i = 0 to UBound($tmp)-1
$text2=StringReplace($text2&';', ';'&$tmp[$i]&';', ';')
Next
EndIf
$text2=StringRegExpReplace($text2&';', ';__\w+?(?=;)', '')
$text2=StringRegExpReplace($text2, ';{2,}', ';')
$text2=StringTrimRight($text2, 1)
$FunctionsData&=$file&$text2&@CRLF
EndIf
EndIf
WEnd
FileClose($search)
If $ConstantsData='' And $FunctionsData='' Then
MsgBox(0, $LngMsB1, $LngMsB5)
Exit
EndIf
; ñïèñîê ñòàíäàðòíûõ ôóíêöèé âçÿò èç "AutoIt3\SciTE\Properties\au3.keywords.properties"
; íå ó âñåõ ìîæåò îêàçàòüñÿ SciTE, ïîýòîìó ñêîïèðîâàë ñïèñîê
$properties=StringRegExpReplace($sAutoIt_Path, '(^.*\\)(.*)$', '\1')&'SciTE\Properties\au3.keywords.properties'
If FileExists($properties) Then
$properties = FileRead($properties)
$properties=StringRegExpReplace($properties, '(?si)(?:.*?au3\.keywords\.functions=)(.*?)(?:au3\.keywords\.udfs.*)', '\1')
$properties=StringRegExpReplace($properties, '[\s\\]+', ';')
$FunctionsStr=StringTrimRight($properties, 1)&@CRLF
Else
$FunctionsStr='abs;acos;adlibregister;adlibunregister;asc;ascw;asin;assign;atan;autoitsetoption;autoitwingettitle;autoitwinsettitle;beep;binary;binarylen;binarymid;binarytostring;bitand;bitnot;bitor;bitrotate;bitshift;bitxor;blockinput;break;call;cdtray;ceiling;chr;chrw;clipget;clipput;consoleread;consolewrite;consolewriteerror;controlclick;controlcommand;controldisable;controlenable;controlfocus;controlgetfocus;controlgethandle;controlgetpos;controlgettext;controlhide;controllistview;controlmove;controlsend;controlsettext;controlshow;controltreeview;cos;dec;dircopy;dircreate;dirgetsize;dirmove;dirremove;dllcall;dllcallbackfree;dllcallbackgetptr;dllcallbackregister;dllclose;dllopen;dllstructcreate;dllstructgetdata;dllstructgetptr;dllstructgetsize;dllstructsetdata;drivegetdrive;drivegetfilesystem;drivegetlabel;drivegetserial;drivegettype;drivemapadd;drivemapdel;drivemapget;drivesetlabel;drivespacefree;drivespacetotal;drivestatus;envget;envset;envupdate;eval;execute;exp;filechangedir;fileclose;filecopy;filecreatentfslink;filecreateshortcut;filedelete;fileexists;filefindfirstfile;filefindnextfile;fileflush;filegetattrib;filegetencoding;filegetlongname;filegetpos;filegetshortcut;filegetshortname;filegetsize;filegettime;filegetversion;fileinstall;filemove;fileopen;fileopendialog;fileread;filereadline;filerecycle;filerecycleempty;filesavedialog;fileselectfolder;filesetattrib;filesetpos;filesettime;filewrite;filewriteline;floor;ftpsetproxy;guicreate;guictrlcreateavi;guictrlcreatebutton;guictrlcreatecheckbox;guictrlcreatecombo;guictrlcreatecontextmenu;guictrlcreatedate;guictrlcreatedummy;guictrlcreateedit;guictrlcreategraphic;guictrlcreategroup;guictrlcreateicon;guictrlcreateinput;guictrlcreatelabel;guictrlcreatelist;guictrlcreatelistview;guictrlcreatelistviewitem;guictrlcreatemenu;guictrlcreatemenuitem;guictrlcreatemonthcal;guictrlcreateobj;guictrlcreatepic;guictrlcreateprogress;guictrlcreateradio;guictrlcreateslider;guictrlcreatetab;guictrlcreatetabitem;guictrlcreatetreeview;guictrlcreatetreeviewitem;guictrlcreateupdown;guictrldelete;guictrlgethandle;guictrlgetstate;guictrlread;guictrlrecvmsg;guictrlregisterlistviewsort;guictrlsendmsg;guictrlsendtodummy;guictrlsetbkcolor;guictrlsetcolor;guictrlsetcursor;guictrlsetdata;guictrlsetdefbkcolor;guictrlsetdefcolor;guictrlsetfont;guictrlsetgraphic;guictrlsetimage;guictrlsetlimit;guictrlsetonevent;guictrlsetpos;guictrlsetresizing;guictrlsetstate;guictrlsetstyle;guictrlsettip;guidelete;guigetcursorinfo;guigetmsg;guigetstyle;guiregistermsg;guisetaccelerators;guisetbkcolor;'
$FunctionsStr&='guisetcoord;guisetcursor;guisetfont;guisethelp;guiseticon;guisetonevent;guisetstate;guisetstyle;guistartgroup;guiswitch;hex;hotkeyset;httpsetproxy;httpsetuseragent;hwnd;inetclose;inetget;inetgetinfo;inetgetsize;inetread;inidelete;iniread;inireadsection;inireadsectionnames;inirenamesection;iniwrite;iniwritesection;inputbox;int;isadmin;isarray;isbinary;isbool;isdeclared;isdllstruct;isfloat;ishwnd;isint;iskeyword;isnumber;isobj;isptr;isstring;log;memgetstats;mod;mouseclick;mouseclickdrag;mousedown;mousegetcursor;mousegetpos;mousemove;mouseup;mousewheel;msgbox;number;objcreate;objevent;objevent;objget;objname;onautoitexitregister;onautoitexitunregister;opt;ping;pixelchecksum;pixelgetcolor;pixelsearch;pluginclose;pluginopen;processclose;processexists;processgetstats;processlist;processsetpriority;processwait;processwaitclose;progressoff;progresson;progressset;ptr;random;regdelete;regenumkey;regenumval;regread;regwrite;round;run;runas;runaswait;runwait;send;sendkeepactive;seterror;setextended;shellexecute;shellexecutewait;shutdown;sin;sleep;soundplay;soundsetwavevolume;splashimageon;splashoff;splashtexton;sqrt;srandom;statusbargettext;stderrread;stdinwrite;stdioclose;stdoutread;string;stringaddcr;stringcompare;stringformat;stringfromasciiarray;stringinstr;stringisalnum;stringisalpha;stringisascii;stringisdigit;stringisfloat;stringisint;stringislower;stringisspace;stringisupper;stringisxdigit;stringleft;stringlen;stringlower;stringmid;stringregexp;stringregexpreplace;stringreplace;stringright;stringsplit;stringstripcr;stringstripws;stringtoasciiarray;stringtobinary;stringtrimleft;stringtrimright;stringupper;tan;tcpaccept;tcpclosesocket;tcpconnect;tcplisten;tcpnametoip;tcprecv;tcpsend;tcpshutdown;tcpstartup;timerdiff;timerinit;tooltip;traycreateitem;traycreatemenu;traygetmsg;trayitemdelete;trayitemgethandle;trayitemgetstate;trayitemgettext;trayitemsetonevent;trayitemsetstate;trayitemsettext;traysetclick;trayseticon;traysetonevent;traysetpauseicon;traysetstate;traysettooltip;traytip;ubound;udpbind;udpclosesocket;udpopen;udprecv;udpsend;udpshutdown;udpstartup;vargettype;winactivate;winactive;winclose;winexists;winflash;wingetcaretpos;wingetclasslist;wingetclientsize;wingethandle;wingetpos;wingetprocess;wingetstate;wingettext;wingettitle;winkill;winlist;winmenuselectitem;winminimizeall;winminimizeallundo;winmove;winsetontop;winsetstate;winsettitle;winsettrans;winwait;winwaitactive;winwaitclose;winwaitnotactive'&@CRLF
EndIf
_MaxIncludeData($IncludeData) ; äîáàâëÿåò âëîæåííûå Include
$file = FileOpen($Path, 2)
FileWrite($file, $ConstantsData&'|'&@CRLF&$FunctionsData&'|'&@CRLF&$FunctionsStr&'|'&@CRLF&$IncludeData)
FileClose($file)
ProgressOff()
EndFunc
Func _MaxIncludeData(ByRef $a)
$a = StringTrimRight($a, 2)
$a = StringSplit($a, @CRLF, 1)
Local $b[$a[0]+1][3]
$b[0][0]=$a[0]
For $i = 1 to $a[0]
$tmp=StringRegExp($a[$i], '(?i)^(.*?);(.*)$', 3)
If Not @error Then
$b[$i][0]=$tmp[0]
$b[$i][1]=$tmp[1]
$b[$i][2]=StringLen($b[$i][1])
EndIf
Next
$TrRe=0
$KolRe=0
While $KolRe<10 ; öèêë íå áîëåå 10 ïîâòîðîâ ñ âûõîäîì ïðè íåèçìåííîì ðåçóëüòàòå ìàññèâà $b
For $i = 1 to $b[0][0]
For $j = 1 to $b[0][0]
If $i<>$j And StringInStr(';'&$b[$j][1]&';', ';'&$b[$i][0]&';') Then
$b[$j][1]&=';'&$b[$i][1]
$b[$j][1]=_Del_Re_MaxInc($b[$j][1])
$tmp=StringLen($b[$j][1])
If $tmp>$b[$j][2] Then
$TrRe=1
$b[$j][2]=$tmp
EndIf
EndIf
Next
Next
If $TrRe = 0 Then ExitLoop
$TrRe = 0
$KolRe+=1
WEnd
$a=''
For $i = 1 to $b[0][0]
$a&=$b[$i][0]&';'&$b[$i][1]&@CRLF
Next
EndFunc
Func _Del_Re_MaxInc($a)
Assign('/', 1, 1)
$a = StringSplit($a, ';')
Local $k=''
For $i = 1 To $a[0]
Assign($a[$i]&'/', Eval($a[$i]&'/')+1, 1)
If Eval($a[$i]&'/') = 1 Then
$k&=$a[$i]&';'
EndIf
Next
Return StringTrimRight($k, 1)
EndFunc
Func _Del_re($a)
Assign('/', 1, 1)
Local $k=''
For $i = 0 To UBound($a) -1
Assign($a[$i]&'/', Eval($a[$i]&'/')+1, 1)
If Eval($a[$i]&'/') = 1 Then
$k&=';'&$a[$i]
EndIf
Next
Return $k
EndFunc
Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
#forceref $iMsg, $wParam
If $hWnd = $GUI Then
Local $tMINMAXINFO = DllStructCreate("int;int;" & _
"int MaxSizeX; int MaxSizeY;" & _
"int MaxPositionX;int MaxPositionY;" & _
"int MinTrackSizeX; int MinTrackSizeY;" & _
"int MaxTrackSizeX; int MaxTrackSizeY", _
$lParam)
DllStructSetData($tMINMAXINFO, "MinTrackSizeX", 390)
DllStructSetData($tMINMAXINFO, "MinTrackSizeY", 205)
EndIf
EndFunc
; çàèìñòâîâàíî èç "Organize Includes"
Func _stripComments(ByRef $string)
;Author: Prog@ndy
$string = StringReplace(StringReplace($string, "#comments-start", "#cs", 0, 2), "#comments-end", "#ce", 0, 2)
$string = StringRegExpReplace($string, "(?si)(\v|\A)\h*#cs\b.*?\v\h*#ce\b", '') ; remove simple block comments (ìîä AZJIO)
#region remove nested block-comments
Local $match, $depth, $offset, $start, $CommentsAfterce
While 1
$depth = 0
$match = StringRegExp($string, "(?im)^\h*#cs\b", 1)
$start = @extended
If @error Then ExitLoop
Do
$match = StringRegExp($string, "(?im)^\h*#c([se])\b", 1, $offset)
$offset = @extended
Select
Case @error
Return False
Case $match[0] = "e"
$depth -= 1
Case Else
$depth += 1
EndSelect
Until $depth < 1
$string = StringLeft($string, $start - 4) & StringRegExpReplace(StringMid($string, $offset), ".*", '', 1)
;~ $string = StringLeft($string, $start-4) & StringMid($string, $offset)
WEnd
#endregion remove nested block-comments
$string = StringRegExpReplace($string, '(?m)^((?:[^''";]*([''"]).*?\2)*[^;]*);.*$', '\1') ; remove one-line comments
Return True
EndFunc ;==>_stripComments