• 欢迎访问奇跡の海网站,本站不上传任何资源,所有资源均来自于网络,欢迎加入奇跡の海~!奇跡の海-WordPress QQ群
  • 本站下载资源为网络上收集整理而来,并且以计算机技术研究交流为目的,版权归原作者所有,仅供大家参考,学习,不存在任何商业目的与商业用途.
  • 本站系统镜像均来自于官方原版,ed2k可视为P2P下载链接。所有操作系统默认均为试用版,如有正版密钥可以有效激活,本站不提供任何激活和相关服务。

AutoIt3(au3)源码-reg文件转AU3文件

AutoIT3 奇跡の海 2年前 (2017-12-02) 496次浏览 已收录 0个评论 扫描二维码

源码简介

AutoIt3(au3)源码-reg文件转AU3文件
将reg文件转换成AU3文件的工具源码

AU3源码

#Region AutoIt3Wrapper 编译参数 
#AutoIt3Wrapper_UseAnsi=y 
#AutoIt3Wrapper_Icon=                                                 
#AutoIt3Wrapper_OutFile=                                         
#AutoIt3Wrapper_OutFile_Type=exe                                 
#AutoIt3Wrapper_Compression=4                                 
#AutoIt3Wrapper_UseUpx=y                                         
#AutoIt3Wrapper_Res_Comment=                                         
#AutoIt3Wrapper_Res_Description=                                 
#AutoIt3Wrapper_Res_Fileversion=                                 
#AutoIt3Wrapper_Res_FileVersion_AutoIncrement=p                                               
#AutoIt3Wrapper_Res_LegalCopyright=                 
;#AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% 
;#AutoIt3Wrapper_Run_Tidy=                   
;#AutoIt3Wrapper_Run_Obfuscator=       
;#AutoIt3Wrapper_Run_AU3Check=                                 
;#AutoIt3Wrapper_Run_Before=         
;#AutoIt3Wrapper_Run_After=                         
#EndRegion AutoIt3Wrapper 编译参数设置完成 
#cs ____________________________________ 

AutoIt 版本: 3.2.9.14(第二版) 
脚本作者: 
        Email: 
        QQ/TM: 
脚本版本: 
脚本功能: 

#ce _______________脚本开始_________________ 

#include<GUIConstants.au3> 
#include<file.au3> 
#NoTrayIcon 
;;改进了处理多行的HEX字段时只能读取第一行的BUG 
;;改进了处理路径时的BUG 
;;改进了对目标文件名判断上的一个小BUG 
GUICreate(".REG转.AU3 Beta 1.02", 425, 145) 
GUICtrlCreateGroup("", 10, 4, 348, 115)         
$Input1 = GUICtrlCreateInput("", 20, 36, 260, 21, -1) 
$Input2 = GUICtrlCreateInput("", 20, 84, 260, 21, -1) 
GUICtrlCreateLabel("待转换.REG文件路径:", 20, 18,-1,17) 
GUICtrlCreateLabel("转换为.AU3文件路径:", 20, 66,-1,17) 
GUICtrlCreateLabel("" , 10, 125,-1,17) 
$help = GUICtrlCreateLabel("http:hi.baidu.com/402090001" , 200, 125,-1,17) 
guictrlsetfont($help,-1,-1,4) 
GUICtrlSetColor($help,0x0000FF) 
GUICtrlSetCursor($help,0) 
$Runstatus = GUICtrlCreateLabel("" , 364, 36, 66, 21,0x0201) 
$Button1 = GUICtrlCreateButton("浏览", 290, 36, 53, 21) 
$Button2 = GUICtrlCreateButton("浏览", 290, 84, 53, 21) 
$Button3 = GUICtrlCreateButton("生成", 364, 84, 53, 21) 
GUISetState(@SW_SHOW) 
While 1 
$msg = GuiGetMsg() 
Select 
Case $msg = $GUI_EVENT_CLOSE 
  $exit = MsgBox (8192+36,"询问","你确定退出本程序?") 
  IF $EXIT = 7 THEN 
   ContinueLoop 
  ELSE 
   EXIT 
  ENDIF 
Case $msg = $Button1 
  $SFile = FileOpenDialog ( "请选择文件", -1, "Windows注册表文件(*.REG)",1 ) 
  IF $SFile Then 
   GUICtrlSetData($input1,$SFile) 
  EndIf 
Case $msg = $Button2 
  $DFile = FileOpenDialog ( "请选择文件", -1, "Autoit V3脚本文件(*.AU3)",2 ) 
  IF $DFile Then 
   GUICtrlSetData($input2,$DFile) 
  EndIf 
Case $msg = $Button3 
  $SFile = GUICtrlRead($input1) 
  $DFile = GUICtrlRead($input2) 
  $checkdfilepath =  checkdfilepath($SFile, $DFile) 
  IF $checkdfilepath = -1 Then 
   msgbox(8192+16,"错误","源文件并不存在.") 
  ElseIf $checkdfilepath = -2 Then 
   msgbox(8192+16,"错误","目标文件名填写不正确!") 
  ElseIf FileExists($checkdfilepath) Then 
   $msgbox = MsgBox(8192+256+32+4,"确认覆盖","目标文件已存在,是否覆盖?") 
   If $msgbox = 7 Then 
    ContinueLoop 
   EndIf 
   MAKE($SFile,$checkdfilepath) 
  Else 
   MAKE($SFile,$checkdfilepath) 
  EndIf 
Case $msg = $help 
  run(@ProgramFilesDir & "\Internet Explorer\IEXPLORE.EXE http://hi.baidu.com/402090001") 
EndSelect 
Wend 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
Func checkdfilepath( $SFile, $DFile) 
If not FileExists($SFile) then 
return -1 
ElseIf StringLen(StringStripWS($DFile,3)) = 0 Then 
$DFile = StringReplace($SFile,stringlen($SFile) - 2 ,"AU3") 
GUICtrlSetData($input2,$DFile) 
Return $DFile 
Else 
Dim $szDrive, $szDir, $szFName, $szExt 
_PathSplit($DFile, $szDrive, $szDir, $szFName, $szExt) 
If FileExists($szDrive & $szDir) AND StringStripWS($szFName,3) <> "" AND $szExt = ".AU3" Then 
  Return $DFile 
Else 
  Return -2 
EndIf 
EndIf 
EndFunc 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
Func make($sfilepath,$dfilepath) 
dim $valuename ,$type,$value,$wlines 
$tFile = fileopen($sfilepath,0) 
$lines = filereadline($tFile,1) 
If stringleft($lines,36) <> "Windows Registry Editor Version 5.00" AND stringleft($lines,8) <> "REGEDIT4" Then 
msgbox(8192+16,"错误","源文件的编码格式不为ANSI或它不是一个有效的注册表脚本文件.") 
Return 
EndIf 
$x = 1 
while 1     ;;;;;;;;;;;;;;;;;;;;;;; 
$x = $x + 1 
$lines = filereadline($tFile,$x) 
if @error = 1 or @error = -1 then 
  ExitLoop 
EndIf 
$lines = StringStripWS($lines,3) 
$left1 = stringleft($lines,1) 
$left2 = StringMid($lines,2,1) 
$reghead = -1 
If  $left1 = "[" then 
  if $left2 = "-" Then 
   $reghead = 2 
   $keyname = StringMid($lines,3,stringlen($lines) - 3) 
  Else 
   $keyname = StringMid($lines,2,stringlen($lines) - 2) 
  EndIf 
ElseIf $left1 = chr(34) or $left1 = "@" Then 
  If $keyname <> "" Then 
   $reghead = 0 
  EndIf 
  $dhArray = StringSplit($lines,"=") 
  If $dhArray[0] = 2 Then 
   If stringleft($dhArray[2],1) <> '"' Then 
    $typeArray = stringsplit($dhArray[2],":") 
   Else 
    dim $typeArray[2] 
    $typeArray[0] = 1 
    $typeArray[1] = $dhArray[2] 
   EndIf 
  ElseIf $dhArray[0] > 2 Then 
   msgbox(8192,"出错了!","一个错误出现在第" & $x & "行,程序会尝试去解析它,但生成的脚本可能会与源文件有出入。",3) 
   for $m = 3 to $dhArray[0] 
    $dhArray[2] = $dhArray[2]& "=" & $dhArray[$m] 
   Next 
   If stringleft($dhArray[2],1) <> '"' Then 
    $typeArray = stringsplit($dhArray[2],":") 
   Else 
    dim $typeArray[2] 
    $typeArray[0] = 1 
    $typeArray[1] = $dhArray[2] 
   EndIf 
  Else 
   ContinueLoop 
  EndIf 
  $valuename = $dhArray[1] 
  If  $valuename = "@" Then 
   $valuename = '""' 
  EndIf 
  If $typeArray[0] = 1 Then 
   If $typeArray[1] = "-" Then 
    $reghead = 1 
   Else 
    $type = '"REG_SZ"' 
    $value = StringReplace($typeArray[1],"[url=file://\]\","\[/url]") 
   EndIf 
  ElseIf  $typeArray[0] = 2 Then 
   if $typeArray[1] = "dword" Then 
    $type = '"REG_DWORD"' 
    $value = chr(39) & dec($typeArray[2]) & chr(39) 
   Else 
    If  $typeArray[1] = "hex" Then 
     $type = '"REG_BINARY"' 
    ElseIf $typeArray[1] = "hex(7)" Then 
     $type = '"REG_MULTI_SZ"' 
    ElseIf $typeArray[1] = "hex(2)" Then 
     $type = '"REG_EXPAND_SZ"' 
    EndIf 
    $right1 = StringRight($typeArray[2],1) 
    $value = $typeArray[2] 
    while $right1 = "\" 
     $x = $x + 1 
     $lines = filereadline($tFile,$x) 
     if @error = 1 or @error = -1 then 
      ExitLoop 
     EndIf 
     $lines = StringStripWS($lines,3) 
     $left2 = stringleft($lines,2) 
     If StringIsXDigit($left2) Then 
      $value = $value & $lines 
     EndIf 
     $right1 = StringRight($lines,1) 
    WEnd 
    $value = StringReplace($value, "\", "") 
    If $type = '"REG_BINARY"' Then 
     $value = StringReplace($value, ",", "") 
    ElseIf $type = '"REG_MULTI_SZ"' or $type = '"REG_EXPAND_SZ"' Then 
     $splitvalue = stringsplit($value,",") 
     $hexvalue = "" 
     for $n = 1 to $splitvalue[0] step 2 
      $chr = chr(dec($splitvalue[$n])) 
      if $chr <> "" Then 
       $hexvalue = $hexvalue & $chr 
      EndIf 
     Next 
     $value = $hexvalue 
    EndIf 
    $value = chr(39) & $value & chr(39) 
   EndIf 
  EndIf 
Else 
  ContinueLoop 
EndIf 
If     $reghead = 0 Then 
  $wlines = $wlines & "RegWrite (" & chr(39) & $keyname & chr(39) & "," & $valuename & "," & $type & "," & $value & ")" & @CRLF 
ElseIf $reghead = 1 Then 
  $wlines = $wlines & "RegDelete ("  & chr(39) & $keyname & chr(39) & "," & $valuename & ")" & @CRLF 
Elseif $reghead = 2 Then 
  $wlines = $wlines & "RegDelete ("  & chr(39) & $keyname & chr(39) & ")" & @CRLF 
EndIf 
GUICtrlSetData($Runstatus,"处理行" & $x) 
WEnd  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
FileClose($tFile) 
$DFilehd = FileOpen($dfilepath,2) 
$filewrite= FileWrite($DFilehd,$wlines) 
FileClose($DFilehd) 
If $filewrite Then 
GUICtrlSetData($Runstatus,"完成") 
Else 
GUICtrlSetData($Runstatus,"写入失败") 
EndIf 
Return 
EndFunc 


版权声明:本站所有文章和资源使用CC BY-NC-SA 4.0协议授权发布 , 转载应当以相同方式注明文章来自“SeaOMC.COM->AutoIt3(au3)源码-reg文件转AU3文件!在下边可以分享本文哦!
喜欢 (1)
[]
分享 (0)
奇跡の海
关于作者:
一个WordPress菜鸟!
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址