应该在哪里合适的添加runwait呢?
本帖最后由 思夜月心 于 2010-8-29 15:05 编辑是这样一个网友让我帮他写一个
自动安装一些工具
窗口标题为:系统可选组件更新和优化设置
内容:
()安装IE8.0和更新补丁——ie8 .exe 默认
( ) 建立宽带连接——adsl.exe 默认
( ) 安装微软msxml解释器——msxml.exe默认
( ) 安装Framework2.0和3.0----net .exe 不默认
( ) 注册表优化——anti.reg 默认
( ) 重启调用软件安装管理器-----chongqi.exe 默认
说明:
默认8秒执行安装命令
鼠标点击窗口则停止倒计时。
界面最好是白色半透明,字体清晰
界面我是弄好了!
粗略的代码也是写好了!
但是在想调用RUNwait的时候还有不是合适!
下面是我的代码。
请大家帮帮忙,看看 这个RUNWAIT应该要加在哪里啊?#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $time = 8
$Form1 = GUICreate("系统可选组件更新和优化设置", 250, 150,300,300,$WS_POPUP)
GUISetBkColor(0xE0FFFF)
WinSetTrans("系统可选组件更新和优化设置","",170)
GUICtrlCreateGroup("",5,5,160,130)
$Checkbox1 = GUICtrlCreateCheckbox("安装IE8.0和更新补丁", 10, 15, 150, 15)
$Checkbox2 = GUICtrlCreateCheckbox("建立宽带连接", 10, 35, 150, 15)
$Checkbox3 = GUICtrlCreateCheckbox("安装微软msxml解释器", 10, 55, 150, 15)
$Checkbox4 = GUICtrlCreateCheckbox("安装Framework2.0和3.0", 10, 75, 150, 15)
$Checkbox5 = GUICtrlCreateCheckbox("注册表优化", 10, 95, 150, 15)
$Checkbox6 = GUICtrlCreateCheckbox("重启调用软件安装管理器", 10, 115, 150, 15)
GUICtrlCreateGroup("",170,5,75,130)
$Button1 = GUICtrlCreateButton("默认安装",175,15,70,30)
$Button2 = GUICtrlCreateButton("手动安装",175,45,70,30)
GUISetFont(20,"","","宋体")
$Label1 = GUICtrlCreateLabel($time,200,90,70,30)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetState($Checkbox1, $GUI_CHECKED)
GUICtrlSetState($Checkbox2, $GUI_CHECKED)
GUICtrlSetState($Checkbox3, $GUI_CHECKED)
GUICtrlSetState($Checkbox5, $GUI_CHECKED)
GUICtrlSetState($Checkbox6, $GUI_CHECKED)
AdlibRegister("Times", 1000)
;RunWait(@WindowsDir&"\notepad.exe")
;RunWait(@ScriptDir&"\IE8.EXE")
;RunWait(@ScriptDir&"\ADSL.EXE")
;RunWait(@ScriptDir&"\msxml.exe")
;RunWait(@WindowsDir&"\REGEDIT.exe /S "&@ScriptDir&"\anti.reg")
;RunWait(@ScriptDir&"\chongqi.exe")
Case $Checkbox1
AdlibUnRegister()
Case $Checkbox2
AdlibUnRegister()
Case $Checkbox3
AdlibUnRegister()
Case $Checkbox4
AdlibUnRegister()
Case $Checkbox5
AdlibUnRegister()
Case $Checkbox6
AdlibUnRegister()
Case $Button2
If GUICtrlRead($Checkbox1)=1 Then
RunWait(@ScriptDir&"\IE8.EXE")
EndIf
If GUICtrlRead($Checkbox2)=1 Then
RunWait(@ScriptDir&"\ADSL.EXE")
EndIf
If GUICtrlRead($Checkbox3)=1 Then
RunWait(@ScriptDir&"\msxml.exe")
EndIf
If GUICtrlRead($Checkbox4)=1 Then
RunWait(@ScriptDir&"\net .exe")
EndIf
If GUICtrlRead($Checkbox5)=1 Then
RunWait(@WindowsDir&"\REGEDIT.exe /S "&@ScriptDir&"\anti.reg")
EndIf
If GUICtrlRead($Checkbox6)=1 Then
RunWait(@ScriptDir&"\chongqi.exe")
EndIf
Exit
EndSwitch
WEnd
Func Times()
$time -=1
GUICtrlSetData($Label1,$time)
If $time <= 0 Then
EndIf
EndFunc还有如果代码哪里写的不好的,也请指明!谢谢!
我说一下我试了两种 一种就是上面中用 ;变成注释的那里 还有一种是在func中 {:face (356):}沙发。。。。。。。。。。。。。。。。。。。。。。。支持楼主 AdlibUnRegister
为什么要反注册啊,能否讲讲 回复 3# liufenglg
这个是为了说当我点击到选项中倒计时会停止啊! 回复 1# 思夜月心
看不懂你的代码,好像方法不对。。。。给你一段代码参考一下
func Install_Select() ;批安装 处理
Local $ItemCount = _GUICtrlListView_GetItemCount($hListView) ;获取 项目数
Local $Selected_Count = _GUICtrlListView_GetSelectedCount($hListView)
If $Selected_Count = 0 Then ;若软件计数$Selected_Count=0 则 提示
MsgBox (16, "提示", "未选择软件,或缺少配置文件,请检查!")
Else
GUISetState(@SW_HIDE, $GUI_Manager);主窗口隐藏
$ABC = GUICtrlRead( $Drivers );读取路径输入框的路径
ClipPut ( $ABC );向剪贴板写入路径文本.
$A = 1 ;当前安装第?数,初值=1
$B = $Selected_Count ;进度条步进值计算参数,初值=软件计数$Selected_Count值
for $i = 0 to $ItemCount Step 2 ;循环检测
Local $lectedCount = _GUICtrlListView_GetItemChecked($hListView, $i);检测项目是否选中: True=选中
if $lectedCount = False Then; 如未选中,则跳过
Else
Local $ItemText = _GUICtrlListView_GetItemText($hListView, $i) ;获取选中项的 文本
Local $array = StringSplit ( $ItemText, @CRLF) ;拆分选中项文本,返回数组
Local $WS = StringStripWS($array,3) ;删去字符串中首、尾"空白符".
Local $File_path = IniRead (@ScriptDir & "\SoftTool.ini", $WS, $Install_File_type, "");用 $WS 读取 手(自)动安装的 值
Dim $szDrive, $szDir, $szFName, $szExt
Local $TestPath = _PathSplit($File_path, $szDrive, $szDir, $szFName, $szExt)
ProgressOn("", "", "", -1, @DesktopHeight - 135, 1);创建自定义进度条窗口,安装计数进度条
ProgressSet(($Selected_Count-$B)/($Selected_Count/100),"共 " & $Selected_Count & " 项,当前安装第 " & $A & " 项!" _
& @CRLF & @CRLF & "除非必要,不要使用鼠标、键盘,请稍候!... ", "安装:" & $TestPath );设置进度条信息
$B -= 1 ;进度条步进值计算参数自减 1
If StringRight ( $File_path, 3 ) = "msi" Then
RunWait( "msiexec.exe /i " & @ScriptDir & "\" & $File_path)
Else
RunWait(@ScriptDir & "\" & $File_path)
EndIf
$A += 1;当前安装第计数 + 1
If $A > $Selected_Count Then SoftTail()
EndIf
Next
EndIf
EndFunc 回复 5# 131738
不好意思!不是很明白楼上你的这段代码的意思? 本帖最后由 afan 于 2010-8-29 22:09 编辑
这种透明效果反而会使界面明显不清晰啊
另外,使用$WS_POPUP样式总得给个拖动的地方吧 解决了,看看lz是不是这种效果。
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $time = 8
$Form1 = GUICreate("系统可选组件更新和优化设置", 250, 150,300,300,$WS_POPUP)
GUISetBkColor(0xE0FFFF)
WinSetTrans("系统可选组件更新和优化设置","",170)
GUICtrlCreateGroup("",5,5,160,130)
$Checkbox1 = GUICtrlCreateCheckbox("安装IE8.0和更新补丁", 10, 15, 150, 15)
GUICtrlSetState(-1,$GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("建立宽带连接", 10, 35, 150, 15)
GUICtrlSetState(-1,$GUI_CHECKED)
$Checkbox3 = GUICtrlCreateCheckbox("安装微软msxml解释器", 10, 55, 150, 15)
GUICtrlSetState(-1,$GUI_CHECKED)
$Checkbox4 = GUICtrlCreateCheckbox("安装Framework2.0和3.0", 10, 75, 150, 15)
$Checkbox5 = GUICtrlCreateCheckbox("注册表优化", 10, 95, 150, 15)
GUICtrlSetState(-1,$GUI_CHECKED)
$Checkbox6 = GUICtrlCreateCheckbox("重启调用软件安装管理器", 10, 115, 150, 15)
GUICtrlSetState(-1,$GUI_CHECKED)
GUICtrlCreateGroup("",170,5,75,130)
$Button1 = GUICtrlCreateButton("默认安装",175,15,70,30)
$Button2 = GUICtrlCreateButton("手动安装",175,45,70,30)
GUISetFont(20,"","","宋体")
$Label1 = GUICtrlCreateLabel($time,200,90,70,30)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox1,$Checkbox2,$Checkbox3,$Checkbox4,$Checkbox5,$Checkbox6
AdlibUnRegister()
Case $Button1
AdlibRegister("times",1000)
Case $Button2
If GUICtrlRead($Checkbox1)=1 Then
RunWait(@ScriptDir&"\IE8.EXE")
EndIf
If GUICtrlRead($Checkbox2)=1 Then
RunWait(@ScriptDir&"\ADSL.EXE")
EndIf
If GUICtrlRead($Checkbox3)=1 Then
RunWait(@ScriptDir&"\msxml.exe")
EndIf
If GUICtrlRead($Checkbox4)=1 Then
RunWait(@ScriptDir&"\net .exe")
EndIf
If GUICtrlRead($Checkbox5)=1 Then
RunWait(@WindowsDir&"\REGEDIT.exe /S "&@ScriptDir&"\anti.reg")
EndIf
If GUICtrlRead($Checkbox6)=1 Then
RunWait(@ScriptDir&"\chongqi.exe")
EndIf
Exit
EndSwitch
WEnd
Func Times()
$time -=1
GUICtrlSetData($Label1,$time)
If $time <= 0 Then
MsgBox(64,"OK","倒数完毕,开始安装。")
;RunWait(@WindowsDir&"\notepad.exe")
;RunWait(@ScriptDir&"\IE8.EXE")
;RunWait(@ScriptDir&"\ADSL.EXE")
;RunWait(@ScriptDir&"\msxml.exe")
;RunWait(@WindowsDir&"\REGEDIT.exe /S "&@ScriptDir&"\anti.reg")
;RunWait(@ScriptDir&"\chongqi.exe")
Exit
EndIf
EndFunc
回复 7# afan
谢谢AFAN的提醒!在下面SKY808的源码上有修正!
页:
[1]