#NoTrayIcon
#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <ProgressConstants.au3>
#include 'ListView_Progress.au3'
$i = 1
$d = 0
$w = 0
Dim $sfile
Dim $dfile
Dim $dll,$bf=@TempDir&"vista.skf" ;皮肤文件路径
;建立窗口
$Form1 = GUICreate("软件安装器", 352, 308, -1, -1)
$button1 = GUICtrlCreateButton("安装(&I)", 265, 282, 68, 23)
If FileExists(@ScriptDir & "\SoftIns.jpg") = 0 Then
FileInstall("_wjq0886.jpg",@TempDir & "",1)
$pic = GUICtrlCreatePic(@TempDir & "\_wjq0886.jpg", 10, 284,160,20)
FileDelete(@TempDir & "\_wjq0886.jpg")
Else
$pic = GUICtrlCreatePic(@ScriptDir & "\SoftIns.jpg", 10, 284,160,20)
EndIf
GUICtrlSetCursor($pic, 0)
;建立ListView
_SkinGUI(@TempDir&"SkinCrafterDll.dll", $bf, $form1);
$nListView = GUICtrlCreateListView("软件名称|大小|状态", 0, 0, 352, 275)
;设置ListView样式
_GUICtrlListView_SetExtendedListViewStyle($nListView, BitOR($LVS_EX_CHECKBOXES ,$LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
;设置ListView首项宽度
_GUICtrlListView_SetColumnWidth($nListView, 0, 223)
;判断Soft文件夹是否存在
If FileExists ( @ScriptDir & "\soft" ) = 0 Then
MsgBox(64,"SoftIns","当前目录下没有找到Soft文件夹,程序即将退出。",3)
Exit
EndIf
Func _SkinGUI($SkincrafterDll, $SkincrafterSkin, $Handle)
$Dll = DllOpen($SkincrafterDll)
DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr", "1", "wstr", "", "wstr", "1@1.com", "wstr", "1")
DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1)
DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin)
DllCall($Dll, "int:cdecl", "DecorateAs", "int", $Handle, "int", 25)
DllCall($Dll, "int:cdecl", "ApplySkin")
EndFunc ;==_
;统计软件个数
SplashTextOn("", "读取软件列表中...", 220, 35, -1, -1, 32 + 1, "", 12)
filesnum(@ScriptDir & "\soft")
;定义软件列表数组
Local $Item[$d+1]
Local $wzlj_filename[$d+1]
;判断删除、建立涉及到的文件或文件夹
If FileExists ( @TempDir & "\_SoftInsIco" ) = 1 Then
DirRemove ( @TempDir & "\_SoftInsIco" ,1)
DirCreate ( @TempDir & "\_SoftInsIco" )
Else
DirCreate ( @TempDir & "\_SoftInsIco" )
EndIf
If FileExists (@TempDir & "\SoftIns_files.ini") = 1 Then
FileDelete (@TempDir & "\SoftIns_files.ini")
EndIf
;搜索Soft文件夹的文件并写入配置文件SoftIns_files.ini
FindAll(@ScriptDir & "\soft")
;读取软件列表(名称,大小、图标)
FileInstall("getico.dll",@SystemDir & "")
Local $geticodll=DllOpen(@SystemDir & "\getico.dll")
For $i = 1 To $d
;读取软件列表
$wzlj_filename[$i] = IniRead( @TempDir & "\SoftIns_files.ini", "Soft", $i, "" )
$num = StringInStr($wzlj_filename[$i] , "", 0, -1)
$filename = StringTrimLeft($wzlj_filename[$i], $num)
$softfdx = Round(FileGetSize ( $wzlj_filename[$i] ) / 1024 /1024,2) & "M"
$softf = StringTrimRight ( $filename, 4)
$Item[$i] = GUICtrlCreateListViewItem ( $softf & "|" & $softfdx, $nListView )
;选择项目
_GUICtrlListView_SetItemChecked($nListView, $i - 1)
;提取并写入图标
$sfile = $wzlj_filename[$i]
$dfile = @TempDir & "\_SoftInsIco" & $softf & ".ico"
DllCall($geticodll,"int","getico","str",$sfile,"str",$dfile)
GUICtrlSetImage($Item[$i], @TempDir & "\_SoftInsIco" & $softf & ".ico")
Next
DllClose($geticodll)
FileDelete(@SystemDir & "\getico.dll")
FileDelete(@TempDir & "\SoftIns_files.ini")
;删除提取的图标
DirRemove ( @TempDir & "\_SoftInsIco" ,1)
SplashOff ( )
GUISetState(@SW_SHOW, $Form1)
;倒计时8秒
$time = 8
GUICtrlSetData($button1, "安装 8s")
AdlibRegister("djs", 1000)
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
Case $nMsg = $GUI_EVENT_PRIMARYDOWN
AdlibUnRegister()
GUICtrlSetData($button1, "安装(&I)")
Case $nMsg = $pic
Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe http://sky123.org")
Case $nMsg = $button1
yunxing()
EndSelect
WEnd
;统计soft文件夹包含文件的个数
Func filesnum($path)
Local $fpath, $fs, $fa
$fpath = $path & "\*.*"
Local $f = FileFindFirstFile($fpath)
While 1
$fs = FileFindNextFile($f)
If @error Then
FileClose($f)
Return
EndIf
If $fs = "." Or $fs = ".." Then
ContinueLoop
EndIf
$fa = FileGetAttrib($path & "" & $fs)
If StringInStr($fa, "D") Then
filesnum($path & "" & $fs)
Else
$d = $d + 1
EndIf
WEnd
EndFunc
;搜索Soft文件夹的文件并写入配置文件SoftIns_files.ini
Func FindAll($path)
Local $fpath, $fs, $fa
$fpath = $path & "\*.*"
Local $f = FileFindFirstFile($fpath)
While 1
$fs = FileFindNextFile($f)
If @error Then
FileClose($f)
Return
EndIf
If $fs = "." Or $fs = ".." Then
ContinueLoop
EndIf
$fa = FileGetAttrib($path & "" & $fs)
If StringInStr($fa, "D") Then
FindAll($path & "" & $fs)
Else
;软件列表写入配置文件
IniWrite(@TempDir & "\SoftIns_files.ini", "Soft", $i, $path & "" & $fs)
$i = $i + 1
EndIf
WEnd
EndFunc
;倒计时自定义函数
Func djs()
$time = $time - 1
GUICtrlSetData($button1, "安装 " & $time & "s")
If $time = -1 Then
yunxing()
EndIf
EndFunc
;程序执行函数
Func yunxing()
GUICtrlSetData($button1, "安装(&I)")
GUICtrlSetState ( $button1,$GUI_DISABLE )
For $i = 1 To $d
If _GUICtrlListView_GetItemChecked($nListView, $i - 1) = "true" Then
Else
_GUICtrlListView_SetItemState ($nListView, $i - 1, $LVIS_CUT,$LVIS_CUT)
GUICtrlSetColor ( $Item[$i], 0xB7B7B7)
$w = $w + 1
EndIf
Next
If $w = $d Then
MsgBox(64,"","当我傻子啊,你一个软件都没选,安装什么?!",3)
Exit
EndIf
For $i = 1 To $d
If _GUICtrlListView_GetItemChecked($nListView, $i - 1) = "true" Then
_GUICtrlListView_SetItemSelected($nListView, $i - 1)
_Progress_SetPos(_ListView_InsertProgressBar ($nListView, $i-1, 2), 30)
RunWait($wzlj_filename[$i])
_Progress_SetPos(_ListView_InsertProgressBar ($nListView, $i-1, 2), 100)
GUICtrlSetColor ( $Item[$i], 0x0000FF)
EndIf
Next
Exit
EndFunc
Func Quit()
GUISetState(@SW_HIDE)
DllCall($dll, "int:cdecl", "DeInitDecoration")
DllCall($dll, "int:cdecl", "RemoveSkin")
DllClose($dll)
FileDelete(@TempDir&"SkinCrafterDll.dll")
FileDelete(@TempDir&"vista.skf")
Exit
EndFunc