#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ServiceControl.au3>
#include <SliderConstants.au3>
$Form1 = GUICreate("Form1", 282, 276, 424, 287)
$Checkbox1 = GUICtrlCreateCheckbox("XT800", 64, 12, 57, 33)
If Not _ServiceExists("", "XT800Service") Then
GUICtrlSetState(-1, $GUI_DISABLE)
Else
GUICtrlSetState(-1, $GUI_CHECKED)
EndIf
$Checkbox2 = GUICtrlCreateCheckbox("TeamViewer9", 144, 16, 97, 25)
If Not _ServiceExists("", "TeamViewer9") Then
GUICtrlSetState(-1, $GUI_DISABLE)
Else
GUICtrlSetState(-1, $GUI_CHECKED)
EndIf
$Button1 = GUICtrlCreateButton("开始延时", 16, 128, 89, 33)
$Button2 = GUICtrlCreateButton("立即重启服务", 116, 128, 89, 33)
$Button3 = GUICtrlCreateButton("退出", 216, 128, 49, 33)
$Label3 = GUICtrlCreateLabel("00:00:00", 18, 192, 244, 64, $SS_CENTER)
GUICtrlSetFont(-1, 36, 400, 0, "Tahoma")
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH)
$Group1 = GUICtrlCreateGroup(" 延时 ", 8, 48, 265, 57)
$Slider1 = GUICtrlCreateSlider(16, 64, 249, 25, $TBS_TOOLTIPS)
GUICtrlSetLimit(-1, 24, 0)
GUICtrlSetData(-1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
_Main()
Func _Main()
Do
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Global $iTime = GUICtrlRead($Slider1)
GUICtrlSetData($Label3, StringFormat("%02d:%02d:%02d\n", $iTime, 00, 00))
If GUICtrlRead($Button1) = "开始延时" Then
GUICtrlSetData($Button1, "停止延时")
AdlibRegister('timer', 1000)
Else
GUICtrlSetData($Button1, "开始延时")
AdlibUnRegister('timer')
EndIf
Case $Button2
reset()
Case $Button3
Exit
EndSwitch
Until $nMsg = $GUI_EVENT_CLOSE
EndFunc ;==>_Main
Func timer()
$l = Number(StringLeft(GUICtrlRead($Label3), 2))
$m = Number(StringMid(GUICtrlRead($Label3), 4, 2))
$n = Number(StringRight(StringTrimRight(GUICtrlRead($Label3), 1), 2))
;倒计时
If $n > 0 Then
$n -= 1
Else
$n = 59
If $m <> 0 Then
$m -= 1
Else
$m = 59
If $l <> 0 Then
$l -= 1
Else
reset()
If $iTime < 1 Then
$l = 0
Else
$l = $iTime - 1
EndIf
EndIf
EndIf
EndIf
GUICtrlSetData($Label3, StringFormat("%02d:%02d:%02d\n", $l, $m, $n))
EndFunc ;==>timer
Func reset()
If GUICtrlRead($Checkbox1) = 1 Then
Local $iServ = "XT800Service"
Sleep(2000)
_StopService("", $iServ)
Sleep(2000)
_StartService("", $iServ)
EndIf
If GUICtrlRead($Checkbox2) = 1 Then
Local $iServ = "TeamViewer9"
Sleep(2000)
_StopService("", $iServ)
Sleep(2000)
_StartService("", $iServ)
EndIf
EndFunc ;==>reset
|