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 105 106
| Titre = "Alarme"
Set ws = CreateObject("wscript.Shell")
alarmDansMin = Trim ( InputBox( "Dans combien de minutes voulez-vous déclenchez l'alarme ? " & vbCrLf & vbCrLf & NOW,Titre, "120") )
If alarmDansMin = "" Then Wscript.Quit
If Not IsNumeric(alarmDansMin) or alarmDansMin <= 1 Then
ws.Popup "Il faut Taper un Nombre strictement supérieur à 1 !","2",Titre,0+16 'Afficher un Popup durant 2 secondes puis quitte le script
Wscript.Quit
End if
sMessage = "Reste " & alarmDansMin/2 & " minutes !"
alarmDansmmsec = alarmDansMin*60*1000 'en millisecondes
alaramSecondes = alarmDansMin*60 'en secondes
nMinutes = alarmDansMin/2
WScript.sleep alarmDansmmsec/2
nSeconds = 0
sMessage = "<font color=red size=4><b>ALARME</b></font>"
' Open a chromeless window with message
with HTABox("lightBlue", 175, 450, 400,100)
.document.title = "Notification"
.msg.innerHTML = sMessage
do until .done.value or (nMinutes + nSeconds < 1)
.msg.innerHTML = sMessage & "<br>" & nMinutes & ":" & Right("0"&nSeconds, 2) _
& " restantes <br>"
wsh.sleep 1000 ' milliseconds
nSeconds = nSeconds - 1
if nSeconds < 0 then
if nMinutes > 0 then
nMinutes = nMinutes - 1
nSeconds = 59
end if
end if
loop
.done.value = true
.close
end with
ws.Popup "C'est FINI !","5",Titre,0+64
Call Run_Shutdown(120)
Call Poser_question()
'*****************************************************************************************************************
Function HTABox(sBgColor, h, w, l, t)
Dim IE, HTA, sCmd, nRnd
randomize : nRnd = Int(1000000 * rnd)
sCmd = "mshta.exe ""javascript:{new " _
& "ActiveXObject(""InternetExplorer.Application"")" _
& ".PutProperty('" & nRnd & "',window);" _
& "window.resizeTo(" & w & "," & h & ");" _
& "window.moveTo(" & l & "," & t & ")}"""
Set WshShell = WScript.CreateObject("WScript.Shell")
with CreateObject("WScript.Shell")
.Run sCmd, 1, False
do until .AppActivate("javascript:{new ") : WSH.sleep 10 : loop
end with 'WSHShell
For Each IE In CreateObject("Shell.Application").windows
If IsObject(IE.GetProperty(nRnd)) Then
set HTABox = IE.GetProperty(nRnd)
IE.Quit
HTABox.document.title = "HTABox"
HTABox.document.write _
"<HTA:Application contextMenu=no border=thin " _
& "minimizebutton=no maximizebutton=no sysmenu=no />" _
& "<body scroll=no style='background-color:" _
& sBgColor & ";font:normal 10pt Arial;" _
& "border-Style:inset;border-Width:3px'" _
& "onbeforeunload='vbscript:if not done.value then " _
& "window.event.cancelBubble=true:" _
& "window.event.returnValue=false:" _
& "done.value=true:end if'>" _
& "<input type=hidden id=done value=false>" _
& "<center><span id=msg> </span><br>" _
& "<input type=button id=btn1 value=' OK ' "_
& "onclick=done.value=true><center></body>"
HTABox.btn1.focus
Exit Function
End If
Next
MsgBox "HTA window not found."
wsh.quit
End Function
Sub Poser_question()
Question = MsgBox ("Vouliez-vous annuler le shutdown de votre PC ?",VBYesNO+VbQuestion,Titre)
If Question = VbYes then
Call Annuler_Shutdown()
Wscript.Quit
else
Wscript.Quit
end if
End Sub
Sub Run_Shutdown(N)
Dim Command,Execution
Command = "Cmd /c Shutdown -s -t "& N &" -c "& DblQuote("Sauvegarder votre travail car votre PC va s'arrêter dans "& N &" seconde(s)")
Execution = ws.run(Command,0,True)
End sub
Sub Annuler_Shutdown()
Dim Command,Execution
Command = "Cmd /c Shutdown -a"
Execution = ws.run(Command,0,True)
End Sub
'*****************************************************************
'Fonction pour ajouter des guillemets dans une variable
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'***************************************************************** |
Partager