本帖最后由 3mile 于 2010-8-2 16:07 编辑
借用楼上兄弟的代码作为分析的数据。
前79行均为楼上兄弟的代码,作为一个字符串:#include <array.au3>
$Str = _
'dim $au3' & @CRLF & _
'dim $c' & @CRLF & _
'dim $d' & @CRLF & _
'$au3 = FileOpenDialog("请选择你要打开的脚本文件", "", "AU3脚本文件(*.au3)", 1)' & @CRLF & _
'' & @CRLF & _
'If @error Then' & @CRLF & _
' MsgBox(4096,"","没有选中任何文件。",3)' & @CRLF & _
'exit' & @CRLF & _
'EndIf' & @CRLF & _
'' & @CRLF & _
'$file = FileOpen($au3, 0)' & @CRLF & _
'If $file = -1 Then' & @CRLF & _
' MsgBox(0, "错误", "无法打开目标文件。",3)' & @CRLF & _
' Exit' & @CRLF & _
'EndIf' & @CRLF & _
'' & @CRLF & _
'; 每次读取1行字符直到文件结尾(EOF,End-Of-File) 为止' & @CRLF & _
'While 1' & @CRLF & _
' $line = FileReadLine($file)' & @CRLF & _
' If @error = -1 Then ExitLoop' & @CRLF & _
'$a = StringInStr($line, "$")' & @CRLF & _
'if $a <> 0 then' & @CRLF & _
'$line = StringTrimLeft($line, $a)' & @CRLF & _
'$b = 1' & @CRLF & _
'' & @CRLF & _
'do' & @CRLF & _
'$d = $c' & @CRLF & _
'$c = StringLeft($line, $b)' & @CRLF & _
'$b = $b + 1' & @CRLF & _
'Until $d = $c or StringIsAlNum($c) = 0' & @CRLF & _
'$c = StringLeft($line, $b - 2)' & @CRLF & _
'if $c <> "" then cf()' & @CRLF & _
'endif' & @CRLF & _
'Wend' & @CRLF & _
'FileClose($file)' & @CRLF & _
'' & @CRLF & _
'$file2 = FileOpen($au3&".au3", 2)' & @CRLF & _
'$var = IniReadSection($au3&".ini","所有变量")' & @CRLF & _
'If @error Then ' & @CRLF & _
' MsgBox(4096, "", "发生错误,可能目标文件并非标准的INI文件.",3)' & @CRLF & _
'exit' & @CRLF & _
'Else' & @CRLF & _
' For $i = 1 To $var[0][0]' & @CRLF & _
' FileWriteLine($file2, "Dim $"&$var[$i][0])' & @CRLF & _
' Next' & @CRLF & _
'EndIf' & @CRLF & _
'' & @CRLF & _
'$file3 = FileOpen($au3, 0)' & @CRLF & _
'If $file3 = -1 Then' & @CRLF & _
' MsgBox(0, "错误", "无法打开目标文件。",3)' & @CRLF & _
' Exit' & @CRLF & _
'EndIf' & @CRLF & _
'While 1' & @CRLF & _
' $line = FileReadLine($file3)' & @CRLF & _
' If @error = -1 Then ExitLoop' & @CRLF & _
' FileWriteLine($file2, $line)' & @CRLF & _
'Wend' & @CRLF & _
'FileClose($file3)' & @CRLF & _
'FileClose($file2)' & @CRLF & _
'FileDelete($au3&".ini")' & @CRLF & _
'' & @CRLF & _
'func cf()' & @CRLF & _
'$file3 = FileOpen($au3, 0)' & @CRLF & _
'If $file = -1 Then' & @CRLF & _
'else' & @CRLF & _
'$e = 0' & @CRLF & _
'While 1' & @CRLF & _
' $line3 = FileReadLine($file3)' & @CRLF & _
' If @error = -1 Then ExitLoop' & @CRLF & _
'if StringInStr($line3,"Dim $"&$c) <> 0 then $e = 1' & @CRLF & _
'Wend' & @CRLF & _
'if $e = 0 then IniWrite($au3&".ini", "所有变量", $c, "")' & @CRLF & _
'EndIf' & @CRLF & _
'FileClose($file3)' & @CRLF & _
'endfunc' & @CRLF & _
''
Local $var
$var_temp=StringRegExp($str,'\$\w*',3)
If Not @error Then $var_array=_ArrayUnique($var_temp)
For $i=1 To $var_array[0]
$var&=$var_array[$i]&","
Next
MsgBox(0,'包含变量有:',"local "&StringLeft($var,StringLen($var)-1))
|