Code : Tout sélectionner
;#include <GUIConstantsEx.au3>
;#include <WindowsConstants.au3>
#Include <Date.au3>
Global Const $WS_POPUP = 0x80000000
Global Const $WS_EX_CLIENTEDGE = 0x00000200
Global Const $WS_EX_TOPMOST = 0x00000008
Global Const $WM_COMMAND = 0x0111
Global Const $WM_MOUSEWHEEL = 0x020A
Global Const $GUI_BKCOLOR_TRANSPARENT = -2
Global Const $GUI_WS_EX_PARENTDRAG = 0x00100000
Global $labelm, $labels, $labelj,$start, $exit1, $exit2, $running , $stop, $ticks
Global $nTempo=0.8, $iTone=0
$gui = GUICreate("Count Down", 400, 70, @desktopwidth/2-110, 10, $WS_POPUP, 0x00000208)
GUISetBkColor(0x000000)
$labelj = GUICtrlCreateLabel("0",10,0,90,70,-1,$GUI_WS_EX_PARENTDRAG)
GUICtrlCreateLabel("j", 85, 0, 15, 70, -1, $GUI_WS_EX_PARENTDRAG)
$labelh = GUICtrlCreateLabel("00", 115, 0, 90, 70, 0, $GUI_WS_EX_PARENTDRAG)
GUICtrlCreateLabel(":", 190, 0, 15, 70, -1, $GUI_WS_EX_PARENTDRAG)
$labelm = GUICtrlCreateLabel("00", 210, 0, 90, 70, 0, $GUI_WS_EX_PARENTDRAG)
GUICtrlCreateLabel(":", 285, 0, 15, 70, -1, $GUI_WS_EX_PARENTDRAG)
$labels = GUICtrlCreateLabel("00", 305, 0, 85, 70, -1, $GUI_WS_EX_PARENTDRAG)
For $i = $labelj to $labels
GUICtrlSetBkColor($i, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont($i, 48, 600, 0, "Arial")
GUICtrlSetColor($i, 0xff0000)
Next
$start = GUICtrlCreateButton("", 385, 10, 12, 50)
GUICtrlSetBkColor(-1, 0x007700)
$exit1 = GUICtrlCreateMenuItem("Exit", GUICtrlCreateContextMenu($labelm))
$exit2 = GUICtrlCreateMenuItem("Exit", GUICtrlCreateContextMenu($labels))
$exit3 = GUICtrlCreateMenuItem("Exit", GUICtrlCreateContextMenu($labelh))
$exit4 = GUICtrlCreateMenuItem("Exit", GUICtrlCreateContextMenu($labelj))
;; GUIRegisterMsg($WM_MOUSEWHEEL, "_Settings")
_dateset()
If $ticks > 0 Then
AdlibRegister("_Update", 1000)
GUICtrlSetBkColor($start, 0x770000)
GUIRegisterMsg($WM_COMMAND, "_StopAlarme")
GUIRegisterMsg($WM_MOUSEWHEEL, "")
$running = 1
_Update()
EndIf
GUISetState()
While 1
Switch GUIGetMsg()
Case $exit1, $exit2 , $exit3 , $exit4
Exit
Case $start
If $running = 0 Then
_dateset()
GUICtrlSetBkColor($start, 0x770000)
GUIRegisterMsg($WM_COMMAND, "_StopAlarme")
GUIRegisterMsg($WM_MOUSEWHEEL, "")
If $ticks = 0 Then
_Update()
Else
AdlibRegister("_Update", 1000)
EndIf
Else
$stop = 0
GUIRegisterMsg($WM_COMMAND, "")
GUIRegisterMsg($WM_MOUSEWHEEL, "_Settings")
AdlibUnRegister("_Update")
EndIf
$running = not $running
EndSwitch
Wend
;==================================
Func _dateset()
Local $test
$test=_DateDiff( 's',_NowCalc(),"2012/09/20 12:00:00")
If $test>0 Then $ticks=$test
EndFunc
Func _Settings($hWnd,$iMsg, $iwParam, $ilParam)
#forceref $hwnd, $iMsg, $ilParam
Local $iDelta = BitShift($iwParam, 16), $a = GUIGetCursorInfo()
If $iDelta > 0 and $a[4] = $labelm Then $ticks += 60
If $iDelta > 0 and $a[4] = $labels Then $ticks += 1
If $iDelta < 0 and $a[4] = $labelm and $ticks>=60 Then $ticks -= 60
If $iDelta < 0 and $a[4] = $labels and $ticks>0 Then $ticks -= 1
If $iDelta > 0 and $a[4] = $labelh Then $ticks += 3600
If $iDelta < 0 and $a[4] = $labelh and $ticks>=3600 Then $ticks -= 3600
If $iDelta > 0 And $a[4] = $labelj And $ticks < 2592000 Then $ticks += 86400
If $iDelta < 0 And $a[4] = $labelj And $ticks > 86400 Then $ticks -= 86400
_Display()
EndFunc
Func _Display()
Local $sec, $min , $hour, $jour
$sec = Mod($ticks, 60)
$min = Mod($ticks/60, 60)
$hour = Mod($ticks/3600, 24 )
$jour = Mod($ticks/86400 , 86400 )
GUICtrlSetData($labelm, StringFormat("%02i", $min))
GUICtrlSetData($labels, StringFormat("%02i", $sec))
GUICtrlSetData($labelh, StringFormat("%02i", $hour))
GUICtrlSetData($labelj, StringFormat("%02i", $jour))
EndFunc
Func _Update()
If $running Then $stop = 0
If $ticks > 0 Then $ticks -= 1
_Display()
If $ticks <= 0 Then
AdlibUnRegister("_Update")
_Play()
GUIRegisterMsg($WM_MOUSEWHEEL, "_Settings")
GUIRegisterMsg($WM_COMMAND, "")
EndIf
EndFunc
Func _StopAlarme($hWnd, $Msg, $wParam, $lParam)
#forceref $hWnd, $Msg, $lParam
Switch BitAND($wParam, 0x0000FFFF)
Case $start, $exit1, $exit2
$stop = 1
GUICtrlSetBkColor($start, 0x007700)
EndSwitch
Return 'GUI_RUNDEFMSG'
EndFunc
Func _Play()
; http://www.autoitscript.com/forum/topic/115869-beep/
While $stop = 0
_Beep(8,4,100)
_Beep(7,4,100)
_Beep(8,4,100)
_Beep(9,4,100)
_Beep(8,4,100,100)
_Beep(1,5,100,100)
_Beep(8,4,100)
_Beep(7,4,100)
_Beep(8,4,100)
_Beep(9,4,100)
_Beep(8,4,100,100)
_Beep(12,4,100,100)
_Beep(8,4,100)
_Beep(7,4,100)
_Beep(8,4,100)
_Beep(9,4,100)
_Beep(8,4,100)
_Beep(6,5,100)
_Beep(3,5,100)
_Beep(12,4,100)
_Beep(8,4,100)
_Beep(6,4,100)
_Beep(5,4,100)
_Beep(4,4,200,300)
_Beep(1,5,100)
_Beep(12,4,100)
_Beep(11,4,100)
_Beep(9,4,100)
_Beep(1,5,100,100)
_Beep(6,5,100,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(8,4,100)
_Beep(1,5,100,100)
_Beep(4,5,100,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(3,5,100)
_Beep(3,4,100)
_Beep(7,4,100)
_Beep(10,4,100)
_Beep(1,5,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(3,5,250,250)
;===========================
_Beep(8,4,100)
_Beep(7,4,100)
_Beep(8,4,100)
_Beep(9,4,100)
_Beep(8,4,100,100)
_Beep(1,5,100,100)
_Beep(8,4,100)
_Beep(7,4,100)
_Beep(8,4,100)
_Beep(9,4,100)
_Beep(8,4,100,100)
_Beep(12,4,100,100)
_Beep(8,4,100)
_Beep(7,4,100)
_Beep(8,4,100)
_Beep(9,4,100)
_Beep(8,4,100)
_Beep(6,5,100)
_Beep(3,5,100)
_Beep(12,4,100)
_Beep(8,4,100)
_Beep(6,4,100)
_Beep(5,4,100)
_Beep(4,4,200,300)
_Beep(1,5,100)
_Beep(12,4,100)
_Beep(11,4,100)
_Beep(9,4,100)
_Beep(1,5,100,100)
_Beep(6,5,100,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(8,4,100)
_Beep(1,5,100,100)
_Beep(4,5,100,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(3,5,100)
;=============================
_Beep(8,4,100)
_Beep(12,4,100)
_Beep(3,5,100)
_Beep(8,5,100)
_Beep(6,5,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,300,200)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(12,4,100)
_Beep(11,4,100)
_Beep(4,4,100)
_Beep(8,4,100)
_Beep(11,4,100)
_Beep(4,4,100)
_Beep(8,4,100)
_Beep(11,4,100)
_Beep(12,4,100)
_Beep(1,5,150,150)
_Beep(9,4,200,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(12,4,100)
_Beep(11,4,100)
_Beep(3,4,100)
_Beep(6,4,100)
_Beep(11,4,100)
_Beep(3,4,100)
_Beep(6,4,100)
_Beep(11,4,100)
_Beep(12,4,100)
_Beep(1,5,150,150)
_Beep(8,4,200,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(6,5,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(11,4,100)
_Beep(3,5,150,150)
_Beep(11,4,300,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(11,4,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(11,4,100)
_Beep(9,4,100)
_Beep(11,4,400,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(12,4,100)
_Beep(11,4,100)
_Beep(4,4,100)
_Beep(8,4,100)
_Beep(11,4,100)
_Beep(4,4,100)
_Beep(8,4,100)
_Beep(11,4,100)
_Beep(12,4,100)
_Beep(1,5,150,150)
_Beep(9,4,200,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(12,4,100)
_Beep(11,4,100)
_Beep(3,4,100)
_Beep(6,4,100)
_Beep(11,4,100)
_Beep(3,4,100)
_Beep(6,4,100)
_Beep(11,4,100)
_Beep(12,4,100)
_Beep(1,5,150,150)
_Beep(8,4,150,150)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(2,5,100)
_Beep(1,5,100)
_Beep(12,4,100)
_Beep(1,5,100)
_Beep(3,5,100)
_Beep(6,5,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(4,5,100)
_Beep(11,4,100)
_Beep(4,5,100)
_Beep(8,5,100)
_Beep(11,5,100)
_Beep(10,5,100)
_Beep(9,5,100)
_Beep(8,5,100)
_Beep(6,5,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(11,4,100)
_Beep(9,4,100)
_Beep(8,4,100)
_Beep(6,4,100)
_Beep(4,4,200)
Sleep(500)
Wend
EndFunc
Func _Beep($iNote,$iOctave=4,$iDuration=200,$iPause=0)
If $stop = 0 Then
$iFrequency=440*2^(($iNote+$iTone)/12+$iOctave+1/6-4)
Beep($iFrequency, $iDuration/$nTempo)
If $iPause<>0 Then Sleep($iPause/$nTempo)
Else
Return
EndIf
EndFunc