本帖最后由 tubaba 于 2017-4-24 21:35 编辑
不再此贴谈此话题了,如果有兴趣我们可以私下聊.粗略看了一下,不支持中文是因为它使用asc函数,修改一下脚本,把所有asc换成ascw,把chr换成chrw应该可以正确还原
chr(asc('中文'))必定会产生乱码.使用chrw(ascw('中文')就不会了.
另外,此脚本查找字符串的方法是逐字载入,而我是采用正则匹配的方法判断字符串
$curchar=Asc(StringMid($linewithstrings,$rc,1)),有空好好学习一下,看看人家的思路.:)
刚刚没事看了一下脚本结构.有些地方不够严谨.比如下面这个函数,完全没有依据#include 的定义.没有考虑用户自定义库,没有考虑查找顺序.在很多系统库文件中,再一次包含的文件可能写法是 #include "XXXX.au3",根据定义,首先从此文件的所在的文件夹路径搜索.
搜索次序依赖于 AutoIt 使用 #include 的格式. 下面表格是两种使用 #include 形式时的搜寻次序.
使用 #include <>标准库 在解释程序(AUTOIT3.EXE)所在目录的 "\Include" 目录中搜索.
用户自定义库 在上述注册表中顺序搜索.
脚本目录 在当前执行脚本的目录中搜索.
使用 #include "" (与 #include <> 相反).脚本目录 在当前执行脚本的目录中搜索
用户自定义库 在上述注册表中反序搜索.
标准库 在解释程序(AUTOIT3.EXE)所在目录的 "\Include" 目录中搜索.Func _AddInclude($curfile,$linecount,$line)
; assumes first string in line identifies the #include file
; accepted delimiters: double-quotes, single-quotes, or angled brackets (paired, not mixed)
$include_index=-1
$params="<n\a>"
$pos1=StringInStr($line,'"',0,1)
$pos2=StringInStr($line,'"',0,2)
$pos3=StringInStr($line,"'",0,1)
$pos4=StringInStr($line,"'",0,2)
$pos5=StringInStr($line,"<",0,1)
$pos6=StringInStr($line,">",0,1)
Select
case $pos1*$pos2>0 And $pos3*$pos4=0 and $pos5*$pos6=0
$newinclude=StringStripWS(StringMid($line,$pos1+1,$pos2-$pos1-1),3)
$bracketed=False
Case $pos1*$pos2=0 And $pos3*$pos4>0 and $pos5*$pos6=0
$newinclude=StringStripWS(StringMid($line,$pos3+1,$pos4-$pos3-1),3)
$bracketed=False
Case $pos1*$pos2=0 And $pos3*$pos4=0 and $pos5*$pos6>0
$newinclude=StringStripWS(StringMid($line,$pos5+1,$pos6-$pos5-1),3)
$bracketed=True
Case Else
Return -1 ; some other format we currently cannot deal with?
EndSelect
If StringInStr($newinclude,"constants")=True Then
If $includeConstants=False And $WriteMetaCode=False Then Return False
EndIf
; extend path if need be
$curpath=StringLeft($curfile,StringInStr($curfile,"",0,-1))
$expanded=False
If StringLeft($newinclude,2)="." Then
$newinclude=$curpath & StringTrimLeft($newinclude,2)
$expanded=True
ElseIf StringLeft($newinclude,3)=".." Then
$newinclude=StringLeft($curfile,StringInStr($curfile,"",0,-2)) & StringTrimLeft($newinclude,3)
$expanded=True
EndIf
If $bracketed=True Then
If FileExists($AutoItIncludeFolder & $newinclude) Then
$newinclude=$AutoItIncludeFolder & $newinclude
Else
For $rc=1 To $extrapaths[0]
If FileExists($extrapaths[$rc] & $newinclude) Then
$newinclude=$extrapaths[$rc] & $newinclude
ExitLoop
EndIf
Next
If $rc>$extrapaths[0] Then $newinclude= $curpath & $newinclude ; add sourcecode's path and hope for the best
EndIf
ElseIf Not $expanded Then ; #include not angle-bracketed
If FileExists($curpath & $newinclude) Then
$newinclude=$curpath & $newinclude
Else
For $rc=1 To $extrapaths[0]
If FileExists($extrapaths[$rc] & $newinclude) Then
$newinclude=$extrapaths[$rc] & $newinclude
ExitLoop
EndIf
Next
If $rc>$extrapaths[0] And FileExists($AutoItIncludeFolder & $newinclude) Then _
$newinclude=$AutoItIncludeFolder & $newinclude ; add default autoit3\include path and hope for the best
EndIf
Endif
; add to list of includes if absent
$okay=(FileExists($newinclude)=True)
If $okay Then
$include_index=_ArraySearch($includes,$newinclude,1)
If $include_index<1 Then
_ArrayAdd($includes,$newinclude,0,ChrW(0))
$includes[0]=UBound($includes)-1
$include_index=$includes[0]
; store separately if not in the default path
If StringInStr($newinclude,$AutoItIncludeFolder)=0 Then
_ArrayAdd($myincludes,$newinclude,0,ChrW(0))
$myincludes[0]=UBound($myincludes)-1
EndIf
If $diagnostics=True Then ConsoleWrite("New include added to list: " & $newinclude & " (nr " & $includes[0] & ")" & @CRLF)
EndIf
Else
$newinclude=$line
$params=$filenotfoundtag
$include_notfound+=1
If _ArraySearch($incl_notfound,$newinclude,1)<1 Then
_ArrayAdd($incl_notfound,$newinclude,0,ChrW(0))
$incl_notfound[0]=UBound($incl_notfound)-1
If $diagnostics=True Then ConsoleWrite("New lost include added to list: " & $newinclude & " (nr " & $incl_notfound[0] & ")" & @CRLF)
EndIf
If $diagnostics=True Then _
MsgBox(262144+8192+48,"Error","unable to find #include referenced in: " & @CRLF& @CRLF & _
"Source file: " & $curfile & @CRLF & _
"Line number: " & $linecount & @CRLF & @CRLF & _
"Content: " & @CRLF & $newinclude)
EndIf
; keep track of where it is being referenced/defined
_AddRef($okay,$curfile,$linecount,"#include",$newinclude,$params)
Return $include_index
EndFunc
|