1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| <HTML>
<HEAD>
<TITLE> Alarme </TITLE>
<HTA:APPLICATION
APPLICATIONNAME="alarme"
ID="alarme"
SCROLL="no"
INNERBORDER="no"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
</HEAD>
<SCRIPT language="VBScript">
Option Explicit
'Déclarations utilisables dans toute la partie VBScript
Dim chrono, NbrSon, NumPass
chrono = 0
'----------------------------------------------------------------------------------------------------------------------
Sub Window_Onload()
ResizeTo 225, 120
End Sub
'----------------------------------------------------------------------------------------------------------------------
Sub Window_OnUnload()
If chrono <> 0 then window.clearInterval(chrono)
End Sub
'----------------------------------------------------------------------------------------------------------------------
Sub NbrSon_onkeyUp()
If window.event.keyCode = 13 then BtApp_onClick()
End Sub
'----------------------------------------------------------------------------------------------------------------------
Sub entSc_onkeyUp()
If window.event.keyCode = 13 then BtApp_onClick()
End Sub
'----------------------------------------------------------------------------------------------------------------------
Sub BtApp_onClick()
dim tSc, tMn, tempo
tSc = entSc.Value
tMn = entMn.Value
If chrono = 0 then
If IsNumeric(tSc) Then
If Cint(tSc) < 5 Or cint(tSc) >= 61 Then ' temps entre chaque sonnerie
msgbox "Minimum 5, maximum 60"
Exit Sub
End If
Else
msgbox "Entrez un chiffre, minimum 5, maximum 60"
Exit Sub
End If
If IsNumeric(tMn) Then ' plage de temps de la sonnerie
If Cint(tMn) < 1 Or cint(tMn) >= 61 Then
msgbox "Minimum 1, maximum 60"
Exit Sub
End If
Else
msgbox "Entrez un chiffre, minimum 1, maximum 60"
Exit Sub
End If
BtApp.value = "Arreter"
entSc.disabled = True ' empêcher la possibilité d'entrer un chiffre dans le Input Type="text"
entMn.disabled = True ' idem
NbrSon = Cint((tMn*60) / tSc) 'nombre de sonnerie durant la plage de temps
NumPass = 0 'comptage de passage dans la Sub "sonner()"
tempo = tSc*1000 'temps entre chaque sonnerie en millisecondes
chrono = window.setInterval("sonner", tempo) ' appelle la fonction de manière répétée, avec un certain délai fixé entre chaque appel
'sonner() ' éventuellement pour sonner au moment de l'enclenchement, dans ce cas mettre NumPass = -1
Else
window.clearInterval(chrono)
chrono = 0
BtApp.value = "Appliquer"
entSc.disabled = False
entMn.disabled = False
End If
End Sub
'----------------------------------------------------------------------------------------------------------------------
Sub sonner()
dim oShell
Set oShell = CreateObject("WSCript.shell")
oShell.Run "%comspec% /c echo " & Chr(7), 0, False
Set oShell = NotHing
NumPass = NumPass + 1
If NumPass = NbrSon Then
window.clearInterval(chrono)
BtApp.value = "Appliquer"
entSc.disabled = False
entMn.disabled = False
End If
End Sub
</SCRIPT>
<Body>
<p style="position:absolute; left:15px; top:5px"> Sonnerie toutes les </p>
<Input Type="text" id="entSc" value="60" style="position:absolute; left:135px; top:5px; width:30px">
<p style="position:absolute; left:180px; top:5px"> Sc </p>
<p style="position:absolute; left:15px; top:30px"> Durant ..............</p>
<Input Type="text" id="entMn" value="15" style="position:absolute; left:135px; top:30px; width:30px">
<p style="position:absolute; left:180px; top:30px"> Mn </p>
<Input Type="button" id="BtApp" Value="Appliquer"
style="position:absolute; left:15px; top:55px; height:22px; width:180px;
background-color:powderblue; Color:#000000">
</Body>
</HTML> |
Partager