Dim $sSoftName = "Java8 Update"
==>定義顯示畫面的訊息,本例為安裝Java8 Update 的訊息
Case $Button1
MsgBox(4096, "Software Install", "Install Beging")
==> 在Case $Button1 中定義時間內點選立即安裝時所要執行的程序,當然你可以自訂啟動執行安裝程式
Case $Button2
$sComboRead = GUICtrlRead($Combo1)
If $sComboRead ="10 分" Then
GUISetState(@SW_HIDE)
Sleep(600000)
GUISetState(@SW_SHOW)
ElseIf $sComboRead ="1 小時" Then
GUISetState(@SW_HIDE)
Sleep(3600000)
GUISetState(@SW_SHOW)
ElseIf $sComboRead ="4 小時" Then
GUISetState(@SW_HIDE)
Sleep(14400000)
GUISetState(@SW_SHOW)
EndIf
==>Case $Button2 中訂義下拉選項程式等待安裝的時間,例如我點選10分後,畫面會隱藏600000 毫秒,其它1小時、4小時依此類推,只要訂義好時間畫面會隱藏,這樣就可以達到由使用者自訂安裝的時間,彈性佈署。
範例:
#cs ----------------------------------------------------------------
AutoIt Version: 3.3.14.2
Author: 奔騰兔開發誌
Date : 2017/06/16
Script Function: Script Demo
Description :彷Windows更新重啟訊息
Notes:http://pentiumto.blogspot.tw/
#ce -----------------------------------------------------------------
Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info
Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon
Dim $sNowtime=@YEAR &"-"& @MON &"-"& @MDAY &" "& @HOUR &":"& @MIN
ConsoleWrite($sNowtime & " [Info] " & @ScriptLineNumber & " 自訂訊息可以在開發過程除錯 "&@CRLF)
#include
#include
#include
#include
#include
#include
; Display the tray icon.
Opt("TrayIconHide", 1)
Dim $sSoftName = "Java8 Update"
#Region ### START Koda GUI section ### Form=AlarmInfo.kxf
$Form1 = GUICreate("SoftWare Update", 600, 212, 229, 500,$WS_CAPTION)
$Label1 = GUICtrlCreateLabel( $sSoftName &" 軟體派送更新,請將您的文件儲存", 8, 16, 600, 28)
GUICtrlSetFont(-1, 18, 800, 0, "標楷體")
GUICtrlSetColor(-1, 0x0000FF)
$Icon1 = GUICtrlCreateIcon("D:\icon\Leopard_ico\ico\AppleScript Utility.ico", -1, 8, 112, 48, 48)
$Group1 = GUICtrlCreateGroup("執行選項", 172, 112, 369, 89)
$Combo1 = GUICtrlCreateCombo("請選擇", 372, 136, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "10 分|1 小時|4 小時")
GUICtrlSetFont(-1, 10, 800, 0, "標楷體")
$Button1 = GUICtrlCreateButton("立即安裝", 268, 165, 121, 33)
GUICtrlSetFont(-1, 12, 800, 0, "標楷體")
$Button2 = GUICtrlCreateButton("延期", 420, 164, 105, 33)
GUICtrlSetFont(-1, 12, 800, 0, "標楷體")
$Label2 = GUICtrlCreateLabel("過了下列時間後提醒我:", 180, 136, 191, 20)
GUICtrlSetFont(-1, 12, 800, 0, "標楷體")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label3 = GUICtrlCreateLabel("程式更新過程中有可能造成不可預期的錯誤,為避免資料遺失,"& @CRLF &"請務必儲存您的檔案後,再進行安裝", 8, 48, 884, 63)
GUICtrlSetFont(-1, 14, 400, 0, "標楷體")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Local $sComboRead = ""
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
$sComboRead = GUICtrlRead($Combo1)
; MsgBox($MB_SYSTEMMODAL, "", "The combobox is currently displaying: " & $sComboRead, 0, $Form1)
Case $Button1
MsgBox(4096, "Software Install", "Install Beging")
Case $Button2
$sComboRead = GUICtrlRead($Combo1)
If $sComboRead ="10 分" Then
GUISetState(@SW_HIDE)
Sleep(600000)
GUISetState(@SW_SHOW)
ElseIf $sComboRead ="1 小時" Then
GUISetState(@SW_HIDE)
Sleep(3600000)
GUISetState(@SW_SHOW)
ElseIf $sComboRead ="4 小時" Then
GUISetState(@SW_HIDE)
Sleep(14400000)
GUISetState(@SW_SHOW)
EndIf
EndSwitch
WEnd
執行結果: