[Ex] Un countdown (un de plus, mais super-intuitif)
Posté : jeu. 12 avr. 2012 18:10
par mikell
Un petit utilitaire archi-connu mais bien pratique
Le design est épuré au max, mais c'est comme la bonne mécanique, tout est sous le capot
Mode horloge, timer ou countdown options mm:ss ou hh:mm:ss
Alarme par beep-music ou fichier mp3 de l'utilisateur (mémorisation du dernier mp3 utilisé par clé reg)
Un seul bouton de commande pour démarrer, faire pause/reprise, arrêter l'alarme, la relancer
Réglage du temps avec la roulette de la souris (sur heures minutes et secondes) et flèches haut et bas
Double-clic pour masquer la fenêtre, clic pour la ramener
Menu contextuel custom
EDIT 11 : mémorisation du dernier mp3 utilisé (clé reg)
EDIT 10 : ajout du mode timer et de l'option mp3 pour l'alarme
EDIT 9 : l'ouverture du menu contextuel ne bloque plus le script
EDIT 8 : réglage du temps possible par touches flèche haut et bas (ani)
EDIT 7 : ajout du mode horloge
EDIT 6 : version mode évènementiel
EDIT 5 : masquage de la fenêtre par double-clic (TwentyToo)
EDIT 4 : optimisation du code de l'alarme (TT22)
EDIT 3 : le compteur ne s'arrête pas quand on déplace la fenêtre (Nicoto)
EDIT 2 : couleur du bouton de commande (sksbir)
EDIT 1 : réglage du temps avec la roulette de la souris (TT22)
Le design est épuré au max, mais c'est comme la bonne mécanique, tout est sous le capot
Mode horloge, timer ou countdown options mm:ss ou hh:mm:ss
Alarme par beep-music ou fichier mp3 de l'utilisateur (mémorisation du dernier mp3 utilisé par clé reg)
Un seul bouton de commande pour démarrer, faire pause/reprise, arrêter l'alarme, la relancer
Réglage du temps avec la roulette de la souris (sur heures minutes et secondes) et flèches haut et bas
Double-clic pour masquer la fenêtre, clic pour la ramener
Menu contextuel custom
► Afficher le texte
Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Opt("WinTitleMatchMode", -2)
Opt("GuiOnEventMode", 1)
Opt("GUIResizeMode", 802) ;$GUI_DOCKALL
;~ $ico = "G:\Program Files\AutoIt3\Aut2Exe\Icons\clock.ico"
Global $gui, $start, $running , $stop, $ticks, $mus1 = 1, $masked = 0, $pos, $labels[6]
Global $context, $items[9][2], $cmexists = 0, $about, $smolgui = 1, $cdmode = 1, $oldmode
Global $timer_Gui, $timer_hour_in, $timer_min_in, $timer_btn_cancel
Global $timer_H="00", $timer_M="00", $timer_on, $timer_ring, $dir, $mp3on, $new_menu, $new
Global $mp3 = RegRead("HKEY_CURRENT_USER\Software\coundown", "Lastmp3")
$gui = GUICreate("Count Down", 220, 70, @desktopwidth/2-110, 10, $WS_POPUP, _
BitOr($WS_EX_CLIENTEDGE, $WS_EX_TOPMOST) )
GUISetBkColor(0x000000)
GuiSetFont(48, 600, 0, "Arial")
;~ If not @Compiled Then TraySetIcon($ico)
$labels[0] = GUICtrlCreateLabel("00", 0, 0, 85, 70, 2)
$labels[1] = GUICtrlCreateLabel(":", 85, 0, 15, 70)
$labels[2] = GUICtrlCreateLabel("00", 105, 0, 85, 70)
$labels[3] = GUICtrlCreateLabel(":", -20, 0, 15, 70)
$labels[4] = GUICtrlCreateLabel("00", -100, 0, 85, 70)
$labels[5] = GUICtrlCreateLabel("", -110, 0, 10, 70)
For $i = 0 to 5
GUICtrlSetOnEvent($labels[$i], "_Drag")
GUICtrlSetBkColor($labels[$i], $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor($labels[$i], 0xff0000)
Next
$start = GUICtrlCreateButton("", 200, 10, 10, 50)
GUICtrlSetBkColor(-1, 0x007700)
GUICtrlSetOnEvent(-1, "_ZeBouton")
GUISetState()
GUIRegisterMsg($WM_MOUSEWHEEL, "_SetZeTime")
GUIRegisterMsg($WM_COMMAND, "_MoveW")
_ContextMenuGui()
While 1
If $cdmode and $running = 0 Then
If _IsPressed("26") OR _IsPressed("28") Then _SetZeTime2()
EndIf
If _IsPressed("02") AND NOT WinExists("timer") Then _ContextMenu()
If $cmexists = 1 Then
_TextColor()
If NOT WinActive($context) Then
GUISetState(@SW_HIDE, $context)
$cmexists = 0
EndIf
EndIf
Sleep(10)
Wend
;==================================
Func _ContextMenu()
Local $b = GUIGetCursorInfo($gui)
For $i = 0 to 5
If $b[4] = $labels[$i] Then
Local $MPos = MouseGetPos()
WinMove($context, "", $MPos[0], $MPos[1])
GUISetState(@SW_SHOW, $context)
$cmexists = 1
Exitloop
EndIf
Next
EndFunc
Func _ContextMenuGui()
$context = GUICreate("context", 110, 180, -1, 20, BitOr($WS_BORDER, $WS_POPUP), _
BitOr($WS_EX_COMPOSITED, $WS_EX_TOOLWINDOW) )
GuiSetFont( -1, 400, 0, "Arial Unicode MS")
$items[0][0] = GUICtrlCreateLabel("", 5, 4, 10, 18)
$items[0][1] = GUICtrlCreateLabel(" Countdown Mode", 15, 4, 95, 18)
$items[1][0] = GUICtrlCreateLabel("", 25, 22, 10, 18)
$items[1][1] = GUICtrlCreateLabel(" mm:ss", 35, 22, 95, 18)
$items[2][0] = GUICtrlCreateLabel("", 25, 40, 10, 18)
$items[2][1] = GUICtrlCreateLabel(" hh:mm:ss", 35, 40, 95, 18)
$items[3][0] = GUICtrlCreateLabel("", 5, 58, 10, 18)
$items[3][1] = GUICtrlCreateLabel(" Clock Mode", 15, 58, 95, 18)
$items[7][0] = GUICtrlCreateLabel("", 5, 76, 10, 18)
$items[7][1] = GUICtrlCreateLabel(" Timer Mode", 15, 76, 95, 18)
GuiCtrlCreateLabel("", 0, 95, 110, 2, 0x1000) ; sep
$items[4][0] = GUICtrlCreateLabel("", 5, 100, 10, 18)
$items[4][1] = GUICtrlCreateLabel(" Alarme 1", 15, 100, 95, 18)
$items[5][0] = GUICtrlCreateLabel("", 5, 118, 10, 18)
$items[5][1] = GUICtrlCreateLabel(" Alarme 2", 15, 118, 95, 18)
$items[8][0] = GUICtrlCreateLabel("", 5, 136, 10, 18)
$items[8][1] = GUICtrlCreateLabel(" Fichier ...", 15, 136, 95, 18)
$new_menu = GUICtrlCreateContextMenu($items[8][1])
If $mp3 = "" Then
$new = GUICtrlCreateMenuItem("Nouveau mp3 ...", $new_menu)
Else
$new = GUICtrlCreateMenuItem($mp3, $new_menu)
EndIf
GUICtrlSetOnEvent($new, "_ContextMenuEvents")
GuiCtrlCreateLabel("", 0, 154, 110, 2, 0x1000) ; sep
$items[6][0] = GuiCtrlCreateLabel("", 5, 159, 10, 18)
$items[6][1] = GuiCtrlCreateLabel(" Exit", 15, 160, 95, 18)
For $i = 0 To 8
GUICtrlSetBkColor($items[$i][0], $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor($items[$i][1], $GUI_BKCOLOR_TRANSPARENT)
GuiCtrlSetState($items[$i][0], $GUI_ONTOP)
GuiCtrlSetState($items[$i][1], $GUI_ONTOP)
GUICtrlSetOnEvent($items[$i][0], "_ContextMenuEvents")
GUICtrlSetOnEvent($items[$i][1], "_ContextMenuEvents")
Next
GuiCtrlSetData($items[0][0], ChrW(10003))
GuiCtrlSetData($items[1][0], ChrW(10003))
GuiCtrlSetData($items[4][0], ChrW(10003))
GuiCtrlSetData($items[6][0], ChrW(9786))
WinSetTrans($context, "", 240)
WinSetOnTop($context, "", 1)
GUISetState(@SW_HIDE, $context)
EndFunc
Func _ContextMenuEvents()
Switch @GUI_CtrlId
Case $items[0][1], $items[0][0] ; countdown mode
$cdmode = 1
_CheckZeCdOptions()
_CheckZeContextMenuItems()
_ToggleMode()
Case $items[1][1], $items[1][0] ; format mm:ss
GUICtrlSetData($items[1][0], ChrW(10003))
GUICtrlSetData($items[2][0], "")
$smolgui = 1
_ToggleMode()
Case $items[2][1], $items[2][0] ; format hh:mm:ss
GUICtrlSetData($items[2][0], ChrW(10003))
GUICtrlSetData($items[1][0], "")
$smolgui = 0
_ToggleMode()
Case $items[3][1], $items[3][0] ; clock mode
$cdmode = 0
_CheckZeCdOptions()
_CheckZeContextMenuItems()
_ToggleMode()
Case $items[7][1], $items[7][0] ; timer mode
$oldmode = $cdmode
$cdmode = 0
_ToggleMode()
GUISetState(@SW_HIDE, $context)
_ShowHideTimerGui()
Case $items[4][1], $items[4][0] ; alarme 1
GUICtrlSetData($items[4][0], ChrW(10003))
GUICtrlSetData($items[5][0], "")
GUICtrlSetData($items[8][0], "")
$mus1 = 1
$mp3on = 0
Case $items[5][1], $items[5][0] ; alarme 2
GUICtrlSetData($items[4][0], "")
GUICtrlSetData($items[5][0], ChrW(10003))
GUICtrlSetData($items[8][0], "")
$mus1 = 0
$mp3on = 0
Case $items[8][1], $items[8][0] ; fichier mp3
GUISetState(@SW_HIDE, $context)
If $mp3 <> "" Then
$mp3on = 1
GUICtrlSetData($items[4][0], "")
GUICtrlSetData($items[5][0], "")
GUICtrlSetData($items[8][0], ChrW(10003))
Else
ControlClick($context, "", $items[8][1], "right")
EndIf
Case $new
If $mp3 = "" Then
$dir = @DesktopDir
$name = ""
Else
$dir = StringRegExpReplace($mp3, '(.+)\\[^\\]+', "$1")
$name = StringRegExpReplace($mp3, '.+\\(.+)', "$1")
EndIf
$var = FileOpenDialog("Chouze your mp3...", $dir & "\", "ziques (*.mp3)", 1, $name)
If not @error Then
$dir = StringRegExpReplace($var, '(.+)\\[^\\]+', "$1")
$mp3 = $var
RegWrite("HKEY_CURRENT_USER\Software\coundown", "Lastmp3", "REG_SZ", $mp3)
GuiCtrlDelete($new)
$new = GUICtrlCreateMenuItem($mp3, $new_menu)
GUICtrlSetOnEvent($new, "_ContextMenuEvents")
$mp3on = 1
GUICtrlSetData($items[4][0], "")
GUICtrlSetData($items[5][0], "")
GUICtrlSetData($items[8][0], ChrW(10003))
EndIf
Case $items[6][0]
_About()
Case $items[6][1]
GuiDelete($context)
_Exit()
EndSwitch
GUISetState(@SW_HIDE, $context)
$cmexists = 0
EndFunc
Func _CheckZeContextMenuItems()
If $cdmode = 1 Then ; countdown mode
GUICtrlSetData($items[0][0], ChrW(10003))
GUICtrlSetData($items[3][0], "")
GUICtrlSetData($items[7][0], "")
Else
If $timer_on = 1 Then ; timer mode
GUICtrlSetData($items[0][0], "")
GUICtrlSetData($items[3][0], "")
GUICtrlSetData($items[7][0], ChrW(10003))
Else ; clock mode
GUICtrlSetData($items[0][0], "")
GUICtrlSetData($items[3][0], ChrW(10003))
GUICtrlSetData($items[7][0], "")
EndIf
EndIf
EndFunc
Func _RunZeTimer($wakeup)
If $wakeup <> "00:00" and $timer_on = 0 Then
$cdmode = 0
$timer_on = 1
_CheckZeCdOptions()
_CheckZeContextMenuItems()
_ToggleMode()
AdlibRegister("_CheckZeTimer", 1*1000)
Else
$cdmode = $oldmode
$timer_on = 0
_CheckZeContextMenuItems()
_ToggleMode()
AdlibUnRegister("_CheckZeTimer")
EndIf
EndFunc
Func _CheckZeTimer()
If $timer_H = @HOUR and $timer_M = @MIN Then
AdlibUnRegister("_CheckZeTimer")
GUICtrlSetBkColor($start, 0x770000)
If $masked = 1 Then _Move()
GUISetState(@SW_HIDE, $context)
$cmexists = 0
$timer_ring = 1
$stop = 0
GUIRegisterMsg($WM_COMMAND, "_StopAlarme")
_Play()
EndIf
EndFunc
Func _ShowHideTimerGui()
If NOT WinExists("timer") Then
$timer_Gui = GuiCreate("timer", 200, 60, 5, 74, $WS_POPUP, _
BitOR($WS_EX_TOOLWINDOW, $WS_EX_CLIENTEDGE, $WS_EX_MDICHILD), $gui)
GUISetBkColor(0x000000)
GuiCtrlCreateLabel("Heure de réveil (HH:MM)", 40, 10, 120, 18)
GUICtrlSetColor(-1, 0xffffff)
$timer_hour_in = GuiCtrlCreateInput($timer_H, 10, 30, 25, 18, 1)
GuiCtrlCreateLabel(" : ", 40, 30, 10, 18)
GUICtrlSetColor(-1, 0xffffff)
$timer_min_in = GuiCtrlCreateInput($timer_M, 50, 30, 25, 18, 1)
$timer_btn_ok = GuiCtrlCreateButton("OK", 100, 30, 30, 20)
GUICtrlSetOnEvent(-1, "_ShowHideTimerGui")
GUICtrlSetBkColor(-1, 0x008800)
GUICtrlSetColor(-1, 0xffffff)
$timer_btn_cancel = GuiCtrlCreateButton("Annuler", 140, 30, 50, 20)
GUICtrlSetOnEvent(-1, "_ShowHideTimerGui")
GUICtrlSetBkColor(-1, 0x880000)
GUICtrlSetColor(-1, 0xffffff)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $timer_Gui, "int", 400, "long", 0x00040004)
GuiSetState(@SW_SHOWNOACTIVATE)
Else
$timer_H = StringFormat("%02i", GuiCtrlRead($timer_hour_in))
$timer_M = StringFormat("%02i", GuiCtrlRead($timer_min_in))
If @GUI_CtrlId = $timer_btn_cancel Then
$timer_H = "00"
$timer_M = "00"
EndIf
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $timer_Gui, "int", 400, "long", 0x00050008)
GuiDelete($timer_Gui)
_RunZeTimer($timer_H & ":" & $timer_M)
EndIf
EndFunc
Func _TextColor()
$a = GUIGetCursorInfo($context)
For $i = 0 To 8
If $a[4] = $items[$i][1] OR $a[4] = $items[$i][0] Then
GUICtrlSetColor($items[$i][1], 0xff0000)
Else
GUICtrlSetColor($items[$i][1], 0x000000)
EndIf
Next
Sleep(10)
EndFunc
Func _CheckZeCdOptions()
If not $cdmode OR $running Then
GUICtrlSetState($items[1][0], $GUI_DISABLE)
GUICtrlSetState($items[2][0], $GUI_DISABLE)
GUICtrlSetState($items[1][1], $GUI_DISABLE)
GUICtrlSetState($items[2][1], $GUI_DISABLE)
Else
GUICtrlSetState($items[1][0], $GUI_ENABLE)
GUICtrlSetState($items[2][0], $GUI_ENABLE)
GUICtrlSetState($items[1][1], $GUI_ENABLE)
GUICtrlSetState($items[2][1], $GUI_ENABLE)
EndIf
EndFunc
Func _SmolGui()
WinMove($gui, "", Default, Default, 220)
GUICtrlSetPos($labels[0], 0, 0)
GUICtrlSetPos($labels[1], 85, 0)
GUICtrlSetPos($labels[2], 105, 0)
GUICtrlSetPos($labels[3], -20, 0)
GUICtrlSetPos($labels[4], -100, 0)
GUICtrlSetPos($labels[5], -110, 0)
GUICtrlSetPos($start, 200, 10)
EndFunc
Func _BigGui()
WinMove($gui, "", Default, Default, 220+90)
GUICtrlSetPos($labels[0], 95+0, 0)
GUICtrlSetPos($labels[1], 95+85, 0)
GUICtrlSetPos($labels[2], 95+105, 0)
GUICtrlSetPos($labels[3], 85, 0)
GUICtrlSetPos($labels[4], 10, 0)
GUICtrlSetPos($labels[5], 0, 0)
GUICtrlSetPos($start, 90+200, 10)
EndFunc
Func _ToggleMode()
If not $cdmode Then
_BigGui()
GUIRegisterMsg($WM_MOUSEWHEEL, "")
_RunZeClock()
AdlibRegister("_RunZeClock", 1000)
Else
AdlibUnRegister("_RunZeClock")
If $smolgui = 1 Then
_SmolGui()
Else
_BigGui()
EndIf
If $running = 0 Then
GUIRegisterMsg($WM_MOUSEWHEEL, "_SetZeTime")
$ticks = 0
EndIf
_Display()
EndIf
EndFunc
Func _RunZeClock()
GuiCtrlSetData($labels[4], @HOUR)
GuiCtrlSetData($labels[0], @MIN)
GuiCtrlSetData($labels[2], @SEC)
EndFunc
Func _Exit()
Exit DllCall("User32.dll", "long", "AnimateWindow", "hwnd", $gui, "long", 200, "long", 0x10010)
EndFunc
Func _ZeBouton()
If $running = 0 Then
GUIRegisterMsg($WM_MOUSEWHEEL, "")
If $timer_ring = 0 Then
GUIRegisterMsg($WM_COMMAND, "_StopAlarme")
GUICtrlSetBkColor($start, 0x770000)
If $ticks = 0 Then
_Update()
Else
AdlibRegister("_Update", 1000)
EndIf
Else
GUICtrlSetData($items[3][0], ChrW(10003))
GUICtrlSetData($items[7][0], "")
$running = 1
$timer_ring = 0
$timer_on = 0
GUIRegisterMsg($WM_COMMAND, "_MoveW")
EndIf
Else
GUIRegisterMsg($WM_COMMAND, "_MoveW")
If $cdmode = 1 Then GUIRegisterMsg($WM_MOUSEWHEEL, "_SetZeTime")
AdlibUnRegister("_Update")
EndIf
$running = not $running
_CheckZeCdOptions()
EndFunc
Func _Update()
$stop = 0
If $ticks > 0 Then $ticks -= 1
If $cdmode Then _Display()
If $ticks <= 0 Then
AdlibUnRegister("_Update")
If $masked = 1 Then _Move()
GUISetState(@SW_HIDE, $context)
$cmexists = 0
_Play()
If $cdmode = 1 Then GUIRegisterMsg($WM_MOUSEWHEEL, "_SetZeTime")
GUIRegisterMsg($WM_COMMAND, "_MoveW")
EndIf
EndFunc
Func _SetZeTime($hWnd,$iMsg, $iwParam, $ilParam)
#forceref $hwnd, $iMsg, $ilParam
Local $iDelta = BitShift($iwParam, 16), $a = GUIGetCursorInfo($gui)
If $iDelta > 0 and $a[4] = $labels[0] and $ticks < 86340 Then $ticks += 60
If $iDelta > 0 and $a[4] = $labels[2] and $ticks < 86399 Then $ticks += 1
If $iDelta < 0 and $a[4] = $labels[0] and $ticks >= 60 Then $ticks -= 60
If $iDelta < 0 and $a[4] = $labels[2] and $ticks > 0 Then $ticks -= 1
If $iDelta > 0 and $a[4] = $labels[4] and $ticks < 82800 Then $ticks += 3600
If $iDelta < 0 and $a[4] = $labels[4] and $ticks >= 3600 Then $ticks -= 3600
_Display()
; Sleep(100)
EndFunc
Func _SetZeTime2()
Local $a = GUIGetCursorInfo($gui)
If $a[4] = $labels[0] Or $a[4] = $labels[2] Or $a[4] = $labels[4] Then
While _IsPressed("26")
If $a[4] = $labels[4] and $ticks < 82800 Then $ticks += 3600
If $a[4] = $labels[0] and $ticks < 86340 Then $ticks += 60
If $a[4] = $labels[2] and $ticks < 86399 Then $ticks += 1
_Display()
Sleep(100)
Wend
While _IsPressed("28")
If $a[4] = $labels[4] and $ticks >= 3600 Then $ticks -= 3600
If $a[4] = $labels[0] and $ticks >= 60 Then $ticks -= 60
If $a[4] = $labels[2] and $ticks > 0 Then $ticks -= 1
_Display()
Sleep(100)
Wend
EndIf
EndFunc
Func _Display()
Local $sec, $min, $hr
$sec = Mod($ticks, 60)
$min = Mod($ticks/60, 60)
$hr = Mod($ticks/3600, 60)
GUICtrlSetData($labels[0], StringFormat("%02i", $min))
GUICtrlSetData($labels[2], StringFormat("%02i", $sec))
GUICtrlSetData($labels[4], StringFormat("%02i", $hr))
EndFunc
Func _StopAlarme($hWnd, $Msg, $wParam, $lParam)
#forceref $hWnd, $Msg, $lParam
Switch BitAND($wParam, 0x0000FFFF)
Case $labels[0], $labels[1], $labels[2], $labels[3], $labels[4], $labels[5]
If BitShift($wParam, 16) = 1 Then _Move()
Case $start
$stop = 1
GUICtrlSetBkColor($start, 0x007700)
EndSwitch
Return 'GUI_RUNDEFMSG'
EndFunc
Func _Drag()
If $cmexists = 1 Then
GUISetState(@SW_HIDE, $context)
$cmexists = 0
EndIf
If $masked = 1 Then _Move()
Local $MousePos = MouseGetPos()
Local $hWndPos = WinGetPos($gui)
Local $WinPos[2]
$WinPos[0] = $MousePos[0]-$hWndPos[0]
$WinPos[1] = $MousePos[1]-$hWndPos[1]
Do
$hWndPos = MouseGetPos()
WinMove($gui, '', $hWndPos[0]-$WinPos[0], $hWndPos[1]-$WinPos[1])
Sleep(10)
Until not _IsPressed("01")
EndFunc
Func _MoveW($hWnd, $Msg, $wParam, $lParam) ;WM_COMMAND
#forceref $hWnd, $Msg, $lParam
Switch BitAND($wParam, 0x0000FFFF)
Case $labels[0], $labels[1], $labels[2], $labels[3], $labels[4], $labels[5]
If BitShift($wParam, 16) = 1 Then _Move() ; <= Double clic
EndSwitch
Return 'GUI_RUNDEFMSG'
EndFunc
Func _Move()
Local $speed = 30
If $masked = 0 Then
$pos = WinGetPos($gui)
For $p = $pos[0] to @desktopwidth-10
WinMove($gui, "", $p, Default)
If Mod($p, $speed) = 0 Then Sleep(1)
Next
Else
For $p = @desktopwidth-10 to $pos[0] step -1
WinMove($gui, "", $p, Default)
If Mod($p, $speed) = 0 Then Sleep(1)
Next
EndIf
$masked = not $masked
EndFunc
Func _About()
$about = GUICreate("Tchuss", 300, 100, -1, -1, BitOr($WS_BORDER, $WS_POPUP), $WS_EX_TOOLWINDOW)
GuiSetOnEvent($GUI_EVENT_PRIMARYDOWN, "_CloseAbout")
GuiSetFont(12, 400, 0, "Arial Unicode MS")
GuiCtrlCreateLabel("mikell was here " & ChrW(9835), 80, 20, 140, 20, 1)
GuiCtrlSetOnEvent(-1, "_CloseAbout")
GuiCtrlCreateLabel("http://www.autoitscript.fr/forum/", 40, 50, 220, 20, 1)
GUICtrlSetColor(-1, 0x0000ff)
GUICtrlSetFont(-1, -1, -1, 4)
GUICtrlSetCursor(-1, 0)
GuiCtrlSetOnEvent(-1, "_HaveALookAtZeForum")
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $about, "int", 300, "long", 0x00040010)
GUISetState()
EndFunc
Func _CloseAbout()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $about, "int", 300, "long", 0x00010010)
GuiDelete($about)
EndFunc
Func _HaveALookAtZeForum()
_CloseAbout()
ShellExecute("http://www.autoitscript.fr/forum/index.php")
EndFunc
Func _Play()
If $mp3on = 0 Then
_LoadZeMusic()
While $stop = 0
If $timer_ring = 1 Then $begin = TimerInit()
For $i = 0 To UBound($Notes)-1
_Beep($Notes[$i][0],$Notes[$i][1],$Notes[$i][2],$Notes[$i][3])
If $timer_ring = 1 and TimerDiff($begin)>1000 Then
_RunZeClock()
$begin = TimerInit()
EndIf
Next
Sleep(500)
Wend
Else
ShellExecute($mp3, "", "", "", @SW_HIDE)
Do
Sleep(10)
Until WinExists(".mp3")
$mp3win = WinGetHandle(".mp3")
If $timer_ring = 1 Then $begin = TimerInit()
While $stop = 0 and WinExists($mp3win)
If $timer_ring = 1 and TimerDiff($begin)>1000 Then
_RunZeClock()
$begin = TimerInit()
EndIf
Wend
$stop = 1
If WinExists($mp3win) Then WinClose($mp3win)
EndIf
EndFunc
Func _Beep($iNote,$iOctave=4,$iDuration=200,$iPause=0)
; par AZJIO (il est fou ce mec)
; http://www.autoitscript.com/forum/topic/115869-beep/
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
Func _LoadZeMusic()
If $mus1 = 1 Then
Global $nTempo=0.9, $iTone=0
Global $Notes[199][4] = [[8,4,100],[7,4,100],[8,4,100],[9,4,100],[8,4,100,100],[1,5,100,100],[8,4,100],[7,4,100], _
[8,4,100],[9,4,100],[8,4,100,100],[12,4,100,100],[8,4,100],[7,4,100],[8,4,100],[9,4,100],[8,4,100],[6,5,100], _
[3,5,100],[12,4,100],[8,4,100],[6,4,100],[5,4,100],[4,4,200,300],[1,5,100],[12,4,100],[11,4,100],[9,4,100], _
[1,5,100,100],[6,5,100,100],[4,5,100],[3,5,100],[1,5,100],[8,4,100],[1,5,100,100],[4,5,100,100],[4,5,100],[3,5,100], _
[1,5,100],[3,5,100],[3,4,100],[7,4,100],[10,4,100],[1,5,100],[4,5,100],[3,5,100],[1,5,100],[3,5,250,250], _
[8,4,100],[7,4,100],[8,4,100],[9,4,100],[8,4,100,100],[1,5,100,100],[8,4,100],[7,4,100],[8,4,100],[9,4,100], _
[8,4,100,100],[12,4,100,100],[8,4,100],[7,4,100],[8,4,100],[9,4,100],[8,4,100],[6,5,100],[3,5,100],[12,4,100], _
[8,4,100],[6,4,100],[5,4,100],[4,4,200,300],[1,5,100],[12,4,100],[11,4,100],[9,4,100],[1,5,100,100],[6,5,100,100], _
[4,5,100],[3,5,100],[1,5,100],[8,4,100],[1,5,100,100],[4,5,100,100],[4,5,100],[3,5,100],[1,5,100],[3,5,100], _
[8,4,100],[12,4,100],[3,5,100],[8,5,100],[6,5,100],[4,5,100],[3,5,100],[1,5,300,200],[3,5,100],[1,5,100], _
[12,4,100],[11,4,100],[4,4,100],[8,4,100],[11,4,100],[4,4,100],[8,4,100],[11,4,100],[12,4,100],[1,5,150,150], _
[9,4,200,100],[3,5,100],[1,5,100],[12,4,100],[11,4,100],[3,4,100],[6,4,100],[11,4,100],[3,4,100],[6,4,100], _
[11,4,100],[12,4,100],[1,5,150,150],[8,4,200,100],[4,5,100],[3,5,100],[6,5,100],[4,5,100],[3,5,100],[1,5,100], _
[4,5,100],[3,5,100],[1,5,100],[11,4,100],[3,5,150,150],[11,4,300,100],[3,5,100],[1,5,100],[4,5,100],[3,5,100], _
[1,5,100],[11,4,100],[3,5,100],[1,5,100],[11,4,100],[9,4,100],[11,4,400,100],[3,5,100],[1,5,100],[12,4,100], _
[11,4,100],[4,4,100],[8,4,100],[11,4,100],[4,4,100],[8,4,100],[11,4,100],[12,4,100],[1,5,150,150],[9,4,200,100], _
[3,5,100],[1,5,100],[12,4,100],[11,4,100],[3,4,100],[6,4,100],[11,4,100],[3,4,100],[6,4,100],[11,4,100], _
[12,4,100],[1,5,150,150],[8,4,150,150],[4,5,100],[3,5,100],[2,5,100],[1,5,100],[12,4,100],[1,5,100],[3,5,100], _
[6,5,100],[4,5,100],[3,5,100],[1,5,100],[4,5,100],[11,4,100],[4,5,100],[8,5,100],[11,5,100],[10,5,100], _
[9,5,100],[8,5,100],[6,5,100],[4,5,100],[3,5,100],[1,5,100],[11,4,100],[9,4,100],[8,4,100],[6,4,100],[4,4,200]]
Else
Global $nTempo=0.9, $iTone=-16
Global $Notes[271][4] = [[3,6,100],[1,6,100],[3,6,100],[4,6,100],[1,6,100],[12,5,100],[1,6,100],[10,5,100], _
[1,6,100],[12,5,100],[1,6,100],[3,6,100],[12,5,100],[10,5,100],[12,5,100],[8,5,100],[12,5,100],[10,5,100], _
[12,5,100],[1,6,100],[10,5,100],[8,5,100],[10,5,100],[7,5,100],[10,5,100],[8,5,100],[10,5,100],[12,5,100], _
[8,5,100],[7,5,100],[8,5,100],[3,5,100],[8,6,100],[6,6,100],[8,6,100],[9,6,100],[6,6,100],[4,6,100], _
[6,6,100],[3,6,100],[6,6,100],[4,6,100],[6,6,100],[8,6,100],[4,6,100],[3,6,100],[4,6,100],[1,6,100], _
[4,6,100],[3,6,100],[4,6,100],[6,6,100],[3,6,100],[1,6,100],[3,6,100],[12,5,100],[3,6,100],[1,6,100], _
[3,6,100],[4,6,100],[1,6,100],[12,5,100],[1,6,100],[8,5,100],[1,6,100],[12,5,100],[1,6,100],[9,5,100], _
[6,6,100],[4,6,100],[6,6,100],[8,5,100],[4,6,100],[3,6,100],[4,6,100],[6,5,100],[3,6,100],[1,6,100], _
[3,6,100],[4,5,100],[1,6,100],[12,5,100],[1,6,100],[9,5,100],[6,5,100],[4,5,100],[6,5,100],[8,5,100], _
[4,5,100],[3,5,100],[4,5,100],[6,5,100],[3,5,100],[1,5,100],[3,5,100],[8,5,100],[3,6,100],[1,6,100], _
[3,6,100],[4,6,100],[1,6,100],[12,5,100],[1,6,100],[10,5,100],[1,6,100],[12,5,100],[1,6,100],[3,6,100], _
[12,5,100],[10,5,100],[12,5,100],[8,5,100],[12,5,100],[10,5,100],[12,5,100],[1,6,100],[10,5,100],[8,5,100], _
[10,5,100],[7,5,100],[10,5,100],[8,5,100],[10,5,100],[12,5,100],[8,5,100],[7,5,100],[8,5,100],[3,5,100], _
[8,6,100],[6,6,100],[8,6,100],[9,6,100],[6,6,100],[4,6,100],[6,6,100],[3,6,100],[6,6,100],[4,6,100], _
[6,6,100],[8,6,100],[4,6,100],[3,6,100],[4,6,100],[1,6,100],[4,6,100],[3,6,100],[4,6,100],[6,6,100], _
[3,6,100],[1,6,100],[3,6,100],[12,5,100],[3,6,100],[1,6,100],[3,6,100],[4,6,100],[1,6,100],[12,5,100], _
[1,6,100],[8,5,100],[1,6,100],[12,5,100],[1,6,100],[9,5,100],[6,6,100],[4,6,100],[6,6,100],[8,5,100], _
[4,6,100],[3,6,100],[4,6,100],[6,5,100],[3,6,100],[1,6,100],[3,6,100],[4,5,100],[1,6,100],[12,5,100], _
[1,6,100],[9,5,100],[6,5,100],[4,5,100],[6,5,100],[8,5,100],[4,5,100],[3,5,100],[4,5,100],[6,5,100], _
[3,5,100],[1,5,100],[3,5,100],[3,5,100],[8,6,100],[6,6,100],[8,6,100],[9,6,100],[6,6,100],[4,6,100], _
[6,6,100],[3,6,100],[6,6,100],[4,6,100],[6,6,100],[8,6,100],[4,6,100],[3,6,100],[4,6,100],[1,6,100], _
[4,6,100],[3,6,100],[4,6,100],[6,6,100],[3,6,100],[1,6,100],[3,6,100],[12,5,100],[3,6,100],[1,6,100], _
[3,6,100],[4,6,100],[1,6,100],[12,5,100],[1,6,100],[8,5,100],[1,6,100],[12,5,100],[1,6,100],[9,5,100], _
[6,6,100],[4,6,100],[6,6,100],[8,5,100],[4,6,100],[3,6,100],[4,6,100],[6,5,100],[3,6,100],[1,6,100], _
[3,6,100],[4,5,100],[1,6,100],[12,5,100],[1,6,100],[9,5,100],[6,5,100],[4,5,100],[6,5,100],[8,5,100], _
[4,5,100],[3,5,100],[4,5,100],[6,5,100],[3,5,100],[1,5,100],[3,5,100],[1,5,100],[1,5,100],[1,5,100], _
[8,5,100],[8,5,100],[8,5,100],[11,5,100],[11,5,100],[11,5,100],[1,6,100],[1,6,100],[1,6,100],[5,6,100], _
[5,6,100],[5,6,100],[5,5,900]]
EndIf
EndFunc
Func _WinAPI_SetWindowPos($hWnd, $hAfter, $iX, $iY, $iCX, $iCY, $iFlags)
; _WinAPI_SetWindowPos($mainGui, -1, -1, -1, -1, -1, BitOR(0x0001, 0x0002)) ; $SWP_NOSIZE, $SWP_NOMOVE
; Z order
; $HWND_BOTTOM = 1 ; Places the window at the bottom of the Z order
; $HWND_NOTOPMOST = -2 ; Places the window above all non-topmost windows
; $HWND_TOP = 0 ; Places the window at the top of the Z order
; $HWND_TOPMOST = -1 ; Places the window above all non-topmost windows
Local $aResult = DllCall("user32.dll", "bool", "SetWindowPos", "hwnd", $hWnd, _
"hwnd", $hAfter, "int", $iX, "int", $iY, "int", $iCX, "int", $iCY, "uint", $iFlags)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0]
EndFunc ;==>_WinAPI_SetWindowPos
EDIT 10 : ajout du mode timer et de l'option mp3 pour l'alarme
EDIT 9 : l'ouverture du menu contextuel ne bloque plus le script
EDIT 8 : réglage du temps possible par touches flèche haut et bas (ani)
EDIT 7 : ajout du mode horloge
EDIT 6 : version mode évènementiel
EDIT 5 : masquage de la fenêtre par double-clic (TwentyToo)
EDIT 4 : optimisation du code de l'alarme (TT22)
EDIT 3 : le compteur ne s'arrête pas quand on déplace la fenêtre (Nicoto)
EDIT 2 : couleur du bouton de commande (sksbir)
EDIT 1 : réglage du temps avec la roulette de la souris (TT22)