Autopoff shutdown

Contenu du snippet

Un petit prog bien pratique pour s'endormir avec la zique du PC ou sur un film.
Il éteint tout seul le PC Grace à la fct ExitWindows après un temps reglé par l'utilisateur. Trop pratique :)

Source / Exemple :


'Controles à placer sur la feuille:
'___Type_ __|_Nom_____
' Bouton      | BPStart
'                 | BPCancel
' Timer        | Timer1
' Textbox    | Text1
' "UpDown"  | UpDown1 (Windows Common Controls)

Private Declare Function ExitWindows Lib "user32" (ByVal dwReserved As Long, ByVal uReturnCode As Long) As Long
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Const EWX_SHUTDOWN = 1
Dim sursis As Integer

Private Sub BPCancel_Click()
If Timer1.Enabled = False Then End

Timer1.Enabled = False
Text1.Enabled = True
BPStart.Enabled = True
UpDown1.Enabled = True
Form1.Caption = "Win Auto-shutdown"

End Sub

Private Sub BPStart_Click()
Text1.Enabled = False
BPStart.Enabled = False
UpDown1.Enabled = False
sursis = Text1.Text
Timer1.Enabled = True
Form1.Caption = "Arrêt dans " + Str(sursis) + " minutes"
End Sub

Private Sub Text1_Change()
If Text1.Text = "" Then Text1.Text = "1"
If Text1.Text > 120 Then Text1.Text = "120"
If Text1.Text < 1 Then Text1.Text = "1"
UpDown1.Value = Text1.Text
End Sub

Private Sub Timer1_Timer()
sursis = sursis - 1
If sursis = 0 Then ret = ExitWindowsEx(EWX_SHUTDOWN, 0): End
Form1.Caption = "Arrêt dans " + Str(sursis) + " minutes"
End Sub

Private Sub UpDown1_Change()
Text1.Text = UpDown1.Value
End Sub

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.