|
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=setup3.ico
#AutoIt3Wrapper_outfile=软件安装器.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=e:\lsj\au3\源代码\软件管理器\软件管理器.kxf
Opt("TrayOnEventMode", 1) ;应用OnEvent函数于系统托盘图标
Opt("guicloseonesc", 0) ;此处为程序运行时按下ESC不发送 消息,否则按下ESC键后,退出程序
If FileExists("config.ini") = 0 Then _check()
Const $N = 19
Dim $softname[$N], $softPath[$N], $checkbox[$N], $SoftIcon[$N], $InstallPath, $auto[$N], $parameters[$N] ;定义软件名、路径、软件按钮数量、安装路径
;读取窗口标题信息
$title = IniRead("config.ini", "form", "title", "") ;窗口标题
$copyright = IniRead("config.ini", "form", "copyright", "")
If WinExists($title) Then _ex()
For $i = 0 To $N - 1
$SoftIcon[$i] = IniRead("config.ini", "shell" & $i, "Icon", "") ;软件图标的路径及名称
$softname[$i] = IniRead("config.ini", "shell" & $i, "Caption", "") ;读取软件名
$softPath[$i] = IniRead("config.ini", "shell" & $i, "Command", "") ;读取软件路径
$parameters[$i] = IniRead("config.ini", "shell" & $i, "parameters", "") ;读取软件安装参数
$auto[$i] = IniRead("config.ini", "shell" & $i, "auto", "") ;读取自动安装软件脚本路径
;msgbox(4096,"测试变量传递",$softname[$i]&$softPath[$i])
Next
;以下为创建主窗体
$Form1 = GUICreate($title, 639, 492, 438, 152)
$Group1 = GUICtrlCreateGroup("", 16, 8, 609, 353)
$checkbox[1] = GUICtrlCreateCheckbox($softname[1], 68, 38, 150, 25)
$checkbox[2] = GUICtrlCreateCheckbox($softname[2], 68, 94, 150, 25)
$checkbox[3] = GUICtrlCreateCheckbox($softname[3], 68, 150, 150, 25)
$checkbox[4] = GUICtrlCreateCheckbox($softname[4], 68, 206, 150, 25)
$checkbox[5] = GUICtrlCreateCheckbox($softname[5], 68, 262, 150, 25)
$checkbox[6] = GUICtrlCreateCheckbox($softname[6], 68, 318, 150, 25)
$checkbox[7] = GUICtrlCreateCheckbox($softname[7], 268, 38, 150, 25)
$checkbox[8] = GUICtrlCreateCheckbox($softname[8], 268, 94, 150, 25)
$checkbox[9] = GUICtrlCreateCheckbox($softname[9], 268, 150, 150, 25)
$checkbox[10] = GUICtrlCreateCheckbox($softname[10], 268, 206, 150, 25)
$checkbox[11] = GUICtrlCreateCheckbox($softname[11], 268, 262, 150, 25)
$checkbox[12] = GUICtrlCreateCheckbox($softname[12], 268, 318, 150, 25)
$checkbox[13] = GUICtrlCreateCheckbox($softname[13], 468, 38, 150, 25)
$checkbox[14] = GUICtrlCreateCheckbox($softname[14], 468, 102, 150, 25)
$checkbox[15] = GUICtrlCreateCheckbox($softname[15], 468, 150, 150, 25)
$checkbox[16] = GUICtrlCreateCheckbox($softname[16], 468, 206, 150, 25)
$checkbox[17] = GUICtrlCreateCheckbox($softname[17], 468, 262, 150, 25)
$checkbox[18] = GUICtrlCreateCheckbox($softname[18], 468, 318, 150, 25)
;在GUI上创建18个ICON控件,控件名称从配置文件里读取
$Icon1 = GUICtrlCreateIcon($SoftIcon[1], -1, 31, 36, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon2 = GUICtrlCreateIcon($SoftIcon[2], -1, 31, 92, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon3 = GUICtrlCreateIcon($SoftIcon[3], -1, 31, 148, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon4 = GUICtrlCreateIcon($SoftIcon[4], -1, 31, 204, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon5 = GUICtrlCreateIcon($SoftIcon[5], -1, 31, 260, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon6 = GUICtrlCreateIcon($SoftIcon[6], -1, 31, 316, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon7 = GUICtrlCreateIcon($SoftIcon[7], -1, 231, 36, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon8 = GUICtrlCreateIcon($SoftIcon[8], -1, 231, 92, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon9 = GUICtrlCreateIcon($SoftIcon[9], -1, 231, 148, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon10 = GUICtrlCreateIcon($SoftIcon[10], -1, 231, 204, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon11 = GUICtrlCreateIcon($SoftIcon[11], -1, 231, 260, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon12 = GUICtrlCreateIcon($SoftIcon[12], -1, 231, 316, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon13 = GUICtrlCreateIcon($SoftIcon[13], -1, 431, 36, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon14 = GUICtrlCreateIcon($SoftIcon[14], -1, 431, 100, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon15 = GUICtrlCreateIcon($SoftIcon[15], -1, 431, 148, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon16 = GUICtrlCreateIcon($SoftIcon[16], -1, 431, 204, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon17 = GUICtrlCreateIcon($SoftIcon[17], -1, 431, 260, 32, 32, $GUI_SS_DEFAULT_ICON)
$Icon18 = GUICtrlCreateIcon($SoftIcon[18], -1, 431, 316, 32, 32, $GUI_SS_DEFAULT_ICON)
;创建第二个组件窗口
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 16, 376, 609, 57)
$Radio1 = GUICtrlCreateRadio("全选", 32, 396, 105, 25)
$Radio2 = GUICtrlCreateRadio("全不选", 136, 396, 105, 25)
$Radio3 = GUICtrlCreateRadio("VISTA/WIN7", 248, 396, 105, 25)
$Radio4 = GUICtrlCreateRadio("Notebook", 376, 396, 105, 25)
$Radio5 = GUICtrlCreateRadio("Ghost", 480, 396, 105, 25)
$silent = GUICtrlSetState($Radio5, $GUI_CHECKED) ;初始设置$Radio3按钮被选中
$silent = ghost() ;默认的推荐设置
$Button2 = GUICtrlCreateButton("自动安装", 184, 451, 97, 25, $BS_NOTIFY)
$Button1 = GUICtrlCreateButton("手动安装", 336, 451, 97, 25, $BS_NOTIFY)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
button1()
Case $Button2
button2()
Case $Radio1
all()
Case $Radio2
none()
Case $Radio3
nt6()
Case $Radio4
Notebook()
Case $Radio5
ghost()
EndSwitch
WEnd
;全部选中
Func all()
For $i = 0 To $N - 1
If $softname[$i] And $softPath[$i] <> "" Then
GUICtrlSetState($checkbox[$i], $GUI_CHECKED)
Else
GUICtrlSetState($checkbox[$i], $GUI_UNCHECKED)
EndIf
Next
EndFunc ;==>all
;全部不选
Func none()
For $i = 0 To $N - 1
If $softname[$i] And $softPath[$i] <> "" Then
GUICtrlSetState($checkbox[$i], $GUI_UNCHECKED)
Else
GUICtrlSetState($checkbox[$i], $GUI_UNCHECKED)
EndIf
Next
EndFunc ;==>none
;Notebook安装模式
Func Notebook()
none()
$i = 1
Do
If IniRead("config.ini", "shell" & $i, "Notebook", "") = 1 Then GUICtrlSetState($checkbox[$i], $GUI_CHECKED)
$i = $i + 1
Until $i = 19
EndFunc ;==>Notebook
;GHOST系统安装模式
Func ghost();默认
none()
$i = 1
Do
If IniRead("config.ini", "shell" & $i, "ghost", "") = 1 Then GUICtrlSetState($checkbox[$i], $GUI_CHECKED)
$i = $i + 1
Until $i = 19
EndFunc ;==>ghost
;win7/VISTA
Func nt6()
none()
$i = 1
Do
If IniRead("config.ini", "shell" & $i, "nt6", "") = 1 Then GUICtrlSetState($checkbox[$i], $GUI_CHECKED)
$i = $i + 1
Until $i = 19
EndFunc ;==>nt6
;手动安装
Func button1()
GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetState($Button2, $GUI_DISABLE)
;===============判断CHECKBOX选中数量===================================
$numinstall = 0
For $i = 1 To 18
If GUICtrlRead($checkbox[$i]) = $GUI_CHECKED Then $numinstall += 1
Next
;=======================================================================
;===============从1到$numinstall递增====================================
$num = 0
For $i = 1 To 18
If GUICtrlRead($checkbox[$i]) = $GUI_CHECKED Then
$num += 1
;===============运行选中的软件并显示进度条==============================
ShellExecuteWait($softPath[$i], $parameters[$i])
;~ GUICtrlSetData($Progress1, 100 / $numinstall * $num)
GUICtrlSetState($checkbox[$i], $GUI_UNCHECKED)
EndIf
Next
GUICtrlSetState($Button1, $GUI_ENABLE)
GUICtrlSetState($Button2, $GUI_ENABLE)
Exit
EndFunc ;==>button1
;自动安装
Func button2()
GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetState($Button2, $GUI_DISABLE)
$numinstall = 0 ;判断软件选中的数量
For $i = 1 To 18
If GUICtrlRead($checkbox[$i]) = $GUI_CHECKED Then $numinstall += 1
Next
$num = 0 ;从1到$numinstall递增
For $i = 1 To 18
If GUICtrlRead($checkbox[$i]) = $GUI_CHECKED Then
$num += 1
;~ MsgBox(0, "", 100 / $numinstall * $num)
ShellExecuteWait($auto[$i], $parameters[$i])
;~ GUICtrlSetData($Progress1, 100 / $numinstall * $num)
GUICtrlSetState($checkbox[$i], $GUI_UNCHECKED)
EndIf
Next
GUICtrlSetState($Button1, $GUI_ENABLE)
GUICtrlSetState($Button2, $GUI_ENABLE)
Exit
EndFunc ;==>button2
Func _ex()
MsgBox(4096, "", "请不要重复运行", 3)
Exit
EndFunc ;==>_ex
Func _check()
MsgBox(4096, "", "未发现配置文件Config.ini,程序无法启动", 3)
Exit
EndFunc ;==>_check |
|