59406 发表于 2009-9-16 19:00:56

运行一个程序,如何弹出后点确认安装,点取消按钮就退出呢?

本帖最后由 59406 于 2009-9-16 19:03 编辑

初学者可能会表达得有点语无伦次,大家见谅
如:运行一个程序 1.exe,弹出一个倒计时10秒后自动安装的询问框,里面有“确定”和“取消”按钮,点确认就安装,点取消就退出脚本,不点就10秒后自动安装,反正就是这么一回事了,嘿嘿,刚学au3请各位老师指点,谢谢~

afan 发表于 2009-9-16 19:07:35

前两天刚好帮人解决了这类问题#include <GUIConstantsEx.au3>

Dim $timez = 10, $time = $timez
$Form1 = GUICreate("安装倒计时窗口", 350, 172, 193, 125)
$Label1 = GUICtrlCreateLabel($time & "秒后将安装xxx,请选择!", 20, 32, 310, 28, 0x0002)
GUICtrlSetFont(-1, 16, 400, 0, "楷体_GB2312")
$Progress1 = GUICtrlCreateProgress(8, 88, 333, 17)
$Button1 = GUICtrlCreateButton("立即进入(&Y)", 53, 128, 90, 25)
$Button2 = GUICtrlCreateButton("退出安装(&X)", 210, 128, 90, 25)
GUISetState()
AdlibEnable("_timer", 1000)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $Button2
                        Exit
                Case $Button1
                        ExitLoop
        EndSwitch
        If $time <= 0 Then ExitLoop (Sleep(1000))
WEnd
main()

Func _timer()
        $time -= 1
        GUICtrlSetData($Label1, $time & "秒后将安装xxx,请选择!")
        GUICtrlSetData($Progress1, ($timez - $time) / $timez * 100)
        If $time <= 0 Then Return (GUICtrlSetData($Label1, "现在开始安装xxx   ")) & (AdlibDisable())
EndFunc   ;==>_timer

Func main()
        MsgBox(0, 'test', '倒计时结束,进入主程序.', 2)
        ;Run("xxx安装.exe")
EndFunc   ;==>main

59406 发表于 2009-9-16 19:16:06

本帖最后由 59406 于 2009-9-16 19:18 编辑

感谢afan 同学,如何让这个窗口能在桌面中间显示?

afan 发表于 2009-9-16 19:18:20

感谢afan 同学,如何让这个窗口能在桌面中间显示?
59406 发表于 2009-9-16 19:16 http://www.autoitx.com/images/common/back.gif

第四行改一下即可$Form1 = GUICreate("安装倒计时窗口", 350, 172)

59406 发表于 2009-9-16 19:22:07

这行代码加到哪里,谢谢

afan 发表于 2009-9-16 19:22:56

就是第4行啊~ 看看2L的代码页

hxming 发表于 2009-9-16 19:27:02

应该是软件安装管理器吧。

59406 发表于 2009-9-16 19:27:21

就是第4行啊~ 看看2L的代码页
afan 发表于 2009-9-16 19:22 http://www.autoitx.com/images/common/back.gif

感谢afan 同学

afan 发表于 2009-9-16 19:27:47

不客气~ 59406同学~
页: [1]
查看完整版本: 运行一个程序,如何弹出后点确认安装,点取消按钮就退出呢?