ฟอรั่มของบล็อก http://pssix.blogspot.com


Timer Manager

Share
avatar
sak
PSsix Member Class II
PSsix Member Class II


จำนวนข้อความ : 34
ความนิยม : 0
เข้าร่วมเมื่อ : 26/11/2017

Timer Manager

ตั้งหัวข้อ by sak on 12/12/17, 11:03 am

โปรแกรม Counter Timer Manager

Download: TimePlugins Clickhere OR ClickMe

Code:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <WinAPI.au3>

Opt("MustDeclareVars", 1)

Global $timer, $Secs, $Mins, $Hour, $Time

Local $hForm = GUICreate("Counter Timer", 250, 195, -1, -1, -1, $WS_EX_LAYERED)
GUISetBkColor(0xABABAB)
Local $Lbl_Clock = GUICtrlCreateLabel("00:00:00", 60, 50, 126, 35)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
GUICtrlCreateLabel("COUNTER", 70, 15, 100, 24)
GUICtrlSetFont(-1, 16, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("SetTime:", 12, 117, 55, 20)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Hour", 68, 100, 27, 15)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Min", 110, 100, 21, 15)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Sec", 150, 100, 23, 15)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Local $Input_hour = GUICtrlCreateInput("0", 65, 115, 33, 21,$ES_CENTER)
Local $Input_Min = GUICtrlCreateInput("0", 105, 115, 33, 21,$ES_CENTER)
Local $Input_Sec = GUICtrlCreateInput("0", 145, 115, 33, 21,$ES_CENTER)
Local $Btn_Start = GUICtrlCreateButton("Start", 70, 160, 75, 25)
GUICtrlSetCursor (-1, 0)
Local $combo = GUICtrlCreateCombo("ScreenSaver", 160, 163, 85, 20)
GUICtrlSetData(-1, "LogOff|StandBy|ReStart|TurnOff")

GUISetState()

_WinAPI_SetLayeredWindowAttributes($hForm, 0xABABAB, 255, BitOR($LWA_COLORKEY, $LWA_ALPHA))

While 1
 Local $nMsg = GUIGetMsg()
 Switch $nMsg
 Case $GUI_EVENT_CLOSE
 GUIDelete()
 Exit
 Case $Btn_Start
 If GUICtrlRead($Input_hour)<>0 Or _
 GUICtrlRead($Input_Min)<>0 Or _
 GUICtrlRead($Input_Sec)<>0 Then
    Local $timer = TimerInit()
 AdlibRegister("Timer", 50)
    GUICtrlSetData($Btn_Start, "Wait!")
    GUICtrlSetState($Btn_Start, $GUI_DISABLE)
 SoundPlay("TimePlugins\tick_tock.mp3")
 SoundPlay("TimePlugins\tick_tock.mp3")
 SoundPlay("TimePlugins\tick_tock.mp3")
 SoundPlay("TimePlugins\tick_tock.mp3")
 SoundPlay("TimePlugins\tick_tock.mp3")
 SoundPlay("TimePlugins\tick_tock.mp3")
 SoundPlay("TimePlugins\tick_tock.mp3")
 SoundPlay("TimePlugins\tick_tock.mp3")
 SoundPlay("TimePlugins\tick_tock.mp3")
 SoundPlay("TimePlugins\tick_tock.mp3")
 EndIf
    EndSwitch
WEnd

Func Timer()
 _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs)
 Local $sTime = $Time
 $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
 If $sTime <> $Time Then ControlSetText("Counter Timer", "", "Static1", $Time)
 If($Hour = GUICtrlRead($Input_hour))And _
  ($Mins = GUICtrlRead($Input_Min))And _
  ($Secs = GUICtrlRead($Input_Sec))Then
 AdlibUnRegister("Timer")
 SoundPlay(@WindowsDir & "\Media\Windows XP Shutdown.wav")
 _RunScript()
 _Reset()
 EndIf
EndFunc

Func _Reset()
 GUICtrlSetData($Lbl_Clock, "00:00:00")
 GUICtrlSetData($Input_hour, "0")
 GUICtrlSetData($Input_Min, "0")
 GUICtrlSetData($Input_Sec, "0")
 GUICtrlSetData($Btn_Start, "Start")
 GUICtrlSetState($Btn_Start, $GUI_ENABLE)
EndFunc

Func _RunScript()
 If GUICtrlRead($combo) = "LogOff" Then
   Shutdown(0)
 ElseIf GUICtrlRead($combo) = "StandBy" Then
   Shutdown(32)
 ElseIf GUICtrlRead($combo) = "ReStart" Then
   Shutdown(2)
 ElseIf GUICtrlRead($combo) = "TurnOff" Then
   Shutdown(1)
 Else
   Run("TimePlugins\TheMatrixTrilogy.scr /s")
   If @error Then Return 0
 EndIf
EndFunc

    เวลาขณะนี้ 19/06/18, 03:44 pm