Code : Tout sélectionner
; Includes
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <WindowsConstants.au3>
#include <date.au3>
;GUI
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Radio Réveil", 500, 200, 192, 124)
GUISetBkColor(0x6FA1D9)
$OK = GUICtrlCreateButton("OK", 150, 150, 75, 25)
$Cancel = GUICtrlCreateButton("Cancel", 250, 150, 75, 25)
$Input1 = GUICtrlCreateInput(_NowCalc(), 24, 24, 113, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
$Input2 = GUICtrlCreateInput(_NowCalc(), 24, 84, 113, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
;$Actif1 = GUICtrlCreateCheckbox("Actif", 150, 24, 97, 17)
;GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Actif2 = GUICtrlCreateCheckbox("Actif", 150, 84, 97, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Frequence1 = GUICtrlCreateCombo("", 250, 24, 225, 25)
GUICtrlSetData (-1, "Radio Nova|RTL2|Europe2|Le Mouv'", "Radio Nova")
$Frequence2 =GUICtrlCreateCombo("", 250, 84, 225, 25)
GUICtrlSetData (-1, "Radio Nova|RTL2|Europe2|Le Mouv'", "Le Mouv'")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;###########################################################################################
;Variables
;###########################################################################################
Global $Frequence1
Global $ValFreq
Global $ValFreq2
Global $Actif2
Global $iDateCalc2
;###########################################################################################
;Script
;###########################################################################################
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $OK
_Check1()
If BitAND(GUICtrlRead($Actif2),$GUI_UNCHECKED) = $GUI_UNCHECKED Then
Exit
ElseIf BitAND(GUICtrlRead($Actif2),$GUI_CHECKED) = $GUI_CHECKED Then
_Check2()
EndIf
Case $Cancel
Exit
EndSwitch
WEnd
Exit
; ###########################################################################################
;Fonction pour définir l'action à réaliser pour le réveil 1
; ###########################################################################################
Func _Check1()
$WakeTime = GUICtrlRead($Input1)
$iDateCalc = _DateDiff('s', _NowCalc(), $WakeTime)
While 1
If $iDateCalc > 0 Then
$SleepTime = Number($iDateCalc*1000)
WinSetState ("Radio Réveil", "", @SW_HIDE)
sleep($SleepTime)
_Radio1()
ExitLoop
ElseIf $iDateCalc < 0 Then
MsgBox (48, "Erreur", "L'heure du réveil ne peut précéder l'heure actuelle")
Exitloop
ElseIf $iDateCalc = 0 Then
MsgBox (48, "Erreur", "Le format pour régler l'heure est YYYY/MM/DD HH:MM:SS")
Exitloop
EndIf
WEnd
EndFunc
; ###########################################################################################
;Fonction pour définir l'action à réaliser si Actif est coché
; ###########################################################################################
Func _Check2()
$WakeTime2 = GUICtrlRead($Input2)
$iDateCalc2 = _DateDiff('s', _NowCalc(), $WakeTime2)
While 1
If $iDateCalc2 > 0 Then
$SleepTime2 = Number($iDateCalc2*1000)
WinSetState ("Radio Réveil", "", @SW_HIDE)
sleep($SleepTime2)
_Radio2()
ExitLoop
ElseIf $iDateCalc2 < 0 Then
MsgBox (48, "Erreur", "L'heure du deuxième réveil n'est pas correcte.")
ExitLoop
ElseIf $iDateCalc2 = 0 Then
MsgBox (48, "Erreur", "Réveil 2 : Le format pour régler l'heure est YYYY/MM/DD HH:MM:SS")
ExitLoop
EndIf
WEnd
EndFunc
;###########################################################################################
; Fonction pour contrôler l'état d'un contrôle
;###########################################################################################
Func _IsChecked($control)
Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc ;==>_IsChecked
; ###########################################################################################
;Fonction pour choisir la fréquence1 à exécuter
; ###########################################################################################
Func _Radio1()
$ValFreq = GUICtrlRead($Frequence1)
Select
Case $ValFreq = "Radio Nova"
ShellExecute("firefox.exe", "http://www.novaplanet.com/radionova/player")
Case $ValFreq = "RTL2"
ShellExecute("firefox.exe", "http://radio.rtl2.fr/player.html")
Case $ValFreq = "Europe2"
ShellExecute("firefox.exe", "http://player.virginradio.fr/V4/virgin/index_V1.html")
Case $ValFreq = "Le Mouv'"
ShellExecute("firefox.exe", "http://www.lemouv.com/files/rfPlayer/player.html")
EndSelect
EndFunc
; ###########################################################################################
;Fonction pour choisir la fréquence2 à exécuter
; ###########################################################################################
Func _Radio2()
$ValFreq2 = GUICtrlRead($Frequence2)
Select
Case $ValFreq2 = "Radio Nova"
ShellExecute("firefox.exe", "http://www.novaplanet.com/radionova/player")
Exit
Case $ValFreq2 = "RTL2"
ShellExecute("firefox.exe", "http://radio.rtl2.fr/player.html")
Exit
Case $ValFreq2 = "Europe2"
ShellExecute("firefox.exe", "http://player.virginradio.fr/V4/virgin/index_V1.html")
Exit
Case $ValFreq2 = "Le Mouv'"
ShellExecute("firefox.exe", "http://www.lemouv.com/files/rfPlayer/player.html")
Exit
EndSelect
EndFunc