#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\autoit3\Aut2Exe\Icons\TLB.ico
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <file.au3>
#include <GDIPlus.au3>
#include <ACN_String.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
DirCreate(@WindowsDir & "\Temp\ZLQ")
FileInstall("00A.jpg",@WindowsDir & "\Temp\ZLQ\00A.jpg",1)
FileInstall("001.bmp",@WindowsDir & "\Temp\ZLQ\001.bmp",1)
FileInstall("002.bmp",@WindowsDir & "\Temp\ZLQ\002.bmp",1)
FileInstall("install.ico",@WindowsDir & "\Temp\ZLQ\install.ico",1)
Dim $Ext,$sTmpFile,$sBmpFile,$sBmpToolFile,$sSavFile,$sIcoFile,$Gui1,$Pro1,$sName,$Lab1
Dim $Data,$Data1,$Fname1,$Fname2,$sSname,$Ext,$szDrive, $szDir, $szFName, $szExt
;界面1
Local $Form1 = GUICreate("7Z自解压包界面(仿深度)生成工具", 442, 330, 250, 251, -1, $WS_EX_ACCEPTFILES) ;接受拖放文件
;~ Local $Form1 = GUICreate("7Z自解压包界面(仿深度)生成工具", 442, 330, 250, 251, -1, 0)
Local $Pic1 = GUICtrlCreatePic(@WindowsDir & "\Temp\ZLQ\001.bmp", 13, 39, 414, 71, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetCursor (-1, 0)
GUICtrlSetTip(-1,"点击更换此主图(要求Bmp:414*71)")
Local $Pic2 = GUICtrlCreatePic(@WindowsDir & "\Temp\ZLQ\002.BMP", 13, 110, 414, 6, BitOR($SS_NOPREFIX,$SS_NOTIFY,$WS_GROUP))
GUICtrlSetCursor (-1, 0)
GUICtrlSetTip(-1,"点击更换此主图(要求Bmp:414*5)")
Local $Pic3 = GUICtrlCreatePic(@WindowsDir & "\Temp\ZLQ\00A.jpg", 11, 11, 419, 175, $WS_CLIPSIBLINGS) ;BitOR($WS_GROUP,$WS_CLIPSIBLINGS))
Local $Input1 = GUICtrlCreateInput("已经安装完成", 48, 16, 305, 17)
GUICtrlSetTip(-1,"更换标题文字")
Local $Input2 = GUICtrlCreateInput("正在安装.......", 48, 132, 305, 17)
GUICtrlSetTip(-1,"更换安装说明")
Local $Group1 = GUICtrlCreateGroup("输入输出", 11, 188, 418, 105)
Local $Label1 = GUICtrlCreateLabel("7Z文件路径:", 24, 205, 77, 17, $SS_CENTERIMAGE)
Local $Button1 = GUICtrlCreateButton("打开7Z", 128, 201, 65, 22, 0)
Local $Label4 = GUICtrlCreateLabel("EXE文件路径:", 22, 250, 77, 17, $SS_CENTERIMAGE)
Local $Button2 = GUICtrlCreateButton("保存到", 128, 245, 65, 22, 0)
Local $Group2 = GUICtrlCreateGroup("", 360, 225, 64, 64)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Local $Button3 = GUICtrlCreateButton("更换ICO", 360, 198, 65, 22, 0)
Local $Icon1 = GUICtrlCreateIcon(@WindowsDir & "\Temp\ZLQ\install.ico", 0, 364, 234, 55, 51, BitOR($SS_NOTIFY,$WS_GROUP))
Local $Input3 = GUICtrlCreateInput("", 21, 225, 333, 17)
GUICtrlSetState(-1,$GUI_ACCEPTFILES) ;接受拖放文件
Local $Input4 = GUICtrlCreateInput("", 21, 269, 333, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Local $Button4 = GUICtrlCreateButton("生成EXE", 240, 299, 83, 25, 0)
Local $Button5 = GUICtrlCreateButton("退出", 344, 299, 83, 25, 0)
GUISetState(@SW_SHOW)
;界面2
Func Guijob()
AdlibDisable()
FileInstall("ResHacker.exe",@WindowsDir & "\Temp\ZLQ\ResHacker.exe",1)
FileInstall("7z1.sfx",@WindowsDir & "\Temp\ZLQ\7z1.sfx",1)
$Gui1 = GUICreate("7Z自解压包生成工具正在工作", 579, 60, -1, @DesktopHeight - 160, BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_POPUP,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))
$Pro1 = GUICtrlCreateProgress(16, 32, 542, 17)
$sName=StringSplit(GUICtrlRead($Input4), "\") ;读取文件名
$Lab1 = GUICtrlCreateLabel("正在生成EXE文件(" & $sName[$sName[0]] & "),请稍候...", 24, 8, 532, 17)
GUISetState(@SW_SHOW)
EndFunc
AdlibEnable("sEptFile",300)
While 1
;~ sEptFile()
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE
DelDir()
ExitLoop
Case $Msg = $Pic1
sFileBmp()
Case $Msg = $Pic2
sFileBmpTool()
Case $Msg = $Button1
sFileOpen()
Case $Msg = $Button2
sFileSave()
Case $Msg = $Button3
sFileIco()
Case $Msg = $Button4
If GUICtrlRead($Input3) = "" Then
MsgBox(16,"错误","输入的7Z文件无效(空或者不存在) ")
Else
GUISetState(@SW_HIDE)
Guijob()
sfx()
DelDir()
Exit
EndIf
Case $Msg = $Button5
DelDir()
Exit
EndSelect
WEnd
Func sEptFile()
$Data = GUICtrlRead($Input3)
$Data1 =GUICtrlRead($Input4)
If $Data <> "" Then
;~ If $Data1 <> $Data Then
_PathSplit($Data, $szDrive, $szDir, $szFName, $szExt) ;读取 $input3文件名
$Fname1 = $szFName
_PathSplit($Data1, $szDrive, $szDir, $szFName, $szExt) ;读取 $input4文件名
$Fname2 = $szFName
_PathSplit($sSname, $szDrive, $szDir, $szFName, $szExt) ;读取 $input4文件名
$sSname = $szFName
$Ext = StringRegExp(GUICtrlRead($Input3),'.+\.(.+[^\.])', 1, 1) ;读取后缀名
If $Fname1 <> $Fname2 Then GUICtrlSetData($Input4, StringReplace(GUICtrlRead($Input3),$Ext[0],"exe"))
;~ If $sSavFile = "" And $Fname1 <> $Fname2 Then GUICtrlSetData($Input4, StringReplace(GUICtrlRead($Input3),$Ext[0],"exe"))
;~ GUICtrlSetState($Input3, $GUI_DISABLE)
;~ GUICtrlSetState($Input4, $GUI_DISABLE)
EndIf
EndFunc
;打开BMP位图
Func sFileBmp()
$sBmpFile = FileOpenDialog("打开BMP位图文件:", @ScriptDir & "\", "BMP文件(*.BMP)")
;判断图片大小
If $sBmpFile <> "" Then
;~ _GDIPlus_Startup()
;~ $hImage = _GDIPlus_ImageLoadFromFile($sBmpFile)
;~ $ImgWidth = _GDIPlus_ImageGetWidth($hImage)
;~ $ImgHeight = _GDIPlus_ImageGetHeight($hImage)
;~ If $ImgHeight = '71' And $ImgWidth = '414' Then
;~ _GDIPlus_ShutDown()
GUICtrlDelete($Pic1)
GUICtrlDelete($Pic3)
$Pic1 = GUICtrlCreatePic($sBmpFile, 13, 39, 414, 71, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetCursor (-1, 0)
$Pic3 = GUICtrlCreatePic(@WindowsDir & "\Temp\ZLQ\00A.jpg", 11, 11, 419, 175, $WS_CLIPSIBLINGS)
;~ Else
;~ MsgBox(16,"错误","打开的Bmp文件: " & $ImgWidth & "*" & $ImgHeight & " 不符合要求(要求Bmp:414*71) ")
EndIf
;~ EndIf
EndFunc
;打开BMPTool位图
Func sFileBmpTool()
$sBmpToolFile = FileOpenDialog("打开BMP位图文件:", @ScriptDir & "\", "BMP文件(*.BMP)")
;判断图片大小
;~ _GDIPlus_Startup()
;~ $hImage = _GDIPlus_ImageLoadFromFile($sBmpFile)
;~ $ImgWidth = _GDIPlus_ImageGetWidth($hImage)
;~ $ImgHeight = _GDIPlus_ImageGetHeight($hImage)
;~ If $ImgWidth = '414' And $ImgHeight = '5' Then
If $sBmpToolFile <> "" Then
GUICtrlDelete($Pic2)
GUICtrlDelete($Pic3)
Local $Pic2 = GUICtrlCreatePic($sBmpToolFile, 13, 110, 414, 6, BitOR($SS_NOPREFIX,$SS_NOTIFY,$WS_GROUP))
GUICtrlSetCursor (-1, 0)
$Pic3 = GUICtrlCreatePic(@WindowsDir & "\Temp\ZLQ\00A.jpg", 11, 11, 419, 175, $WS_CLIPSIBLINGS)
EndIf
;~ Else
;~ MsgBox(16,"错误","打开的Bmp文件: " & $ImgWidth & "*" & $ImgHeight & " 不符合要求(要求Bmp:414*71) ")
;~ EndIf
EndFunc
;打开ICO图标
Func sFileIco()
$sIcoFile = FileOpenDialog("打开ICO图标文件:", @ScriptDir & "\", "ICO文件(*.ICO)")
If $sIcoFile <> "" Then
GUICtrlDelete($Icon1)
$Icon1 = GUICtrlCreateIcon($sIcoFile, 0, 364, 234, 55, 51, BitOR($SS_NOTIFY,$WS_GROUP))
EndIf
EndFunc
;打开7Z文件
Func sFileOpen()
$sTmpFile = FileOpenDialog("打开7Z文件:", @ScriptDir & "\", "7z文件(*.7z)")
If $sTmpFile <> "" Then
GUICtrlSetData($Input3, $sTmpFile)
GUICtrlSetData($Input4,StringReplace($sTmpFile,".7z",".exe"))
;~ GUICtrlSetState($Input3, $GUI_DISABLE)
;~ GUICtrlSetState($Input4, $GUI_DISABLE)
EndIf
EndFunc
Func sFileSave()
$sSavFile = FileSaveDialog("保存EXE文件:", @ScriptDir & "\", "Exe文件(*.exe)")
GUICtrlSetData($Input4, $sSavFile & ".exe")
EndFunc
;修改.sfx及生成EXE文件
Func Sfx()
Dim $Put
Dim $InstallPath = @WindowsDir & "\Temp\ZLQ"
;替换标题
Run(@WindowsDir & "\Temp\ZLQ\ResHacker.exe")
WinWait("Resource","")
WinActive("Resource","")
GUICtrlSetData($Pro1,10)
Send("^o")
;~ WinSetState("Resource","",@SW_HIDE) ;隐藏界面
WinWait("打开包含资源的文件","")
WinActive("打开包含资源的文件","")
ClipPut("%windir%\Temp\ZLQ\7z1.sfx")
GUICtrlSetData($Pro1,20)
Send("^v")
Send("!O")
Send("^f")
ClipPut("正在安装压缩包数据,请稍候...")
WinWait("查找","查找内容")
WinActive("查找","查找内容")
GUICtrlSetData($Pro1,30)
Send("^v")
Send("!F")
ClipPut(GUICtrlRead($Input2))
WinWait("Resource","")
WinActive("Resource","")
GUICtrlSetData($Pro1,40)
Send("^v")
Send("!C")
Send("^s")
;替换安装说明
WinActive("Resource","")
GUICtrlSetData($Pro1,50)
Send("^f")
ClipPut("正在释放")
WinWait("查找","查找内容")
WinActive("查找","查找内容")
GUICtrlSetData($Pro1,60)
Send("^v")
Send("!C")
Send("!F")
ClipPut(GUICtrlRead($Input1))
WinWait("Resource","")
WinActive("Resource","")
GUICtrlSetData($Pro1,70)
Send("^v")
Send("!C")
Send("^s")
Send("!FX")
;替换位图
RunWait($InstallPath & '\ResHacker.exe -addoverwrite '&$InstallPath&'\7z1.sfx,'&$InstallPath&'\7z1.sfx,"'&$sBmpFile&'",bitmap,ZLQ0,0')
;替换工具条位图
RunWait($InstallPath & '\ResHacker.exe -addoverwrite '&$InstallPath&'\7z1.sfx,'&$InstallPath&'\7z1.sfx,"'&$sBmpToolFile&'",bitmap,ZLQ1,0')
GUICtrlSetData($Pro1,80)
;替换图标
RunWait($InstallPath & '\ResHacker.exe -addoverwrite '&$InstallPath&'\7z1.sfx,'&$InstallPath&'\7z1.sfx,"'&$sIcoFile&'",IconGroup,159, ')
GUICtrlSetData($Pro1,90)
;生成EXE文件
RunWait(@ComSpec & ' /c copy /b '&$InstallPath&'\7z1.sfx + "'&GUICtrlRead($Input3)&'" "'&GUICtrlRead($Input4)&'"',"",@SW_HIDE)
GUICtrlSetData($Pro1,100)
ShellExecute(StringReplace(GUICtrlRead($Input4),$sName[$sName[0]],""),"","","open")
EndFunc
;删除文件
Func DelDir()
DirRemove(@WindowsDir & "\Temp\ZLQ",1)
Exit
EndFunc
这段代码不能实现“保存到”按钮的功能,烦请高手帮手修改一下???? |