Sign in to follow this  
Followers 0
TPlanet

MOD REMOVE THIS SCRIPT

4 posts in this topic

#1 ·  Posted (edited)

Hi all,

I wrote this to limit my children to use the pc to an hour per day. Every day it goes back to 60 minutes and we can stop it or adding 30 minutes from the icon on the tray(with a password, of course).

I would like the script to pause (or to stop the timer) while the session is not active. I mean if they change user instead of loging off.

So, here is the code... Enjoy;

CODE

#NoTrayIcon

#include <GUIConstantsEx.au3>

#include <EditConstants.au3>

#Include <Constants.au3>

Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown.

Global $TmpRestant, $RegMotDePasse

$Jour = @MDAY

$RegPath = "hkcu\software\timer"

$RegMotDePasse = RegRead("hklm\software\timer","MotDePasse")

If @error Then $RegMotDePasse = "password" ;if no set password in the registry, we set "password" as password

$RegTmpMax = RegRead("hklm\software\timer","TempMax")

If @error Then $RegTmpMax = 60 ;if no set max time in the registry, we set 60 minutes

$TmpMax = (60*$RegTmpMax)

$RegJour = RegRead($RegPath, "jour") ; if not yet connected today, we set the timer back to max time

If @error or $RegJour <> $Jour then

$TmpRestant = $TmpMax ;en secondes

RegWrite($RegPath, "jour", "reg_sz", $Jour)

RegWrite($RegPath, "tempsrestant", "reg_sz", $TmpRestant)

Else

$TmpRestant = (RegRead($RegPath, "tempsrestant")+15) ;add 15 seconds to signon on process

If $TmpRestant <= 30 Then _finsession() ;if already timed out... bye bye

EndIf

;~ tray to add 30 minutes or to stop the script

$FermeTimer = TrayCreateItem("Illimité")

TrayCreateItem("")

$Ajout30Min = TrayCreateItem("Ajout 30 Min")

TraySetState()

;~ Début du compte à rebours

$begin = TimerInit()

While 1

$dif = TimerDiff($begin)

$SecRest = ($TmpRestant - (Round($dif/1000,0)))

$MinRest = (Ceiling($SecRest/60))

ToolTip("Reste " & $MinRest & " Min.", 450, 1, "")

RegWrite($RegPath, "tempsrestant", "reg_sz", $SecRest)

If $SecRest <= 0 Then ExitLoop

$msg = TrayGetMsg() ;verifie si on a activé une commande du tray

Select

Case $msg = 0

Case $msg = $FermeTimer

_Verif("Exit")

Case $msg = $Ajout30Min

_Verif("30min")

EndSelect

sleep(100)

WEnd

_finsession() ;on appelle la fonction de fermeture de session

Exit

;~ ***********************************

;~ Fonctions

;~ ***********************************

Func _Verif($action)

Local $btn, $MotDePasse, $msg, $reponse

GUICreate("Mot de passe", 100, 60, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, $WS_CAPTION, 0x00000018)

$MotDePasse = GUICtrlCreateInput("", 10, 5, 125, 20 ,$ES_PASSWORD)

$btn = GUICtrlCreateButton("Ok", 40, 30, 60, 20)

GUISetState()

$msg = 0

While $msg <> $GUI_EVENT_CLOSE

$msg = GUIGetMsg()

Select

Case $msg = $btn

ExitLoop

Case $msg = $MotDePasse

ExitLoop

EndSelect

WEnd

if GUICtrlRead($MotDePasse) = $RegMotDePasse Then

GUIDelete()

Select

Case $action = "Exit"

Exit

Case $action = "30min"

$TmpRestant = ($TmpRestant + 1800)

EndSelect

Else

GUIDelete()

MsgBox(0,"Erreur", "Mauvais mot de passe",3)

EndIf

EndFunc ;_Verif

func _finsession()

For $Compteur = 1 to 60

ToolTip("La session va se fermer dans " & (61-$Compteur) & " secondes... c'est le temps de sauvergarder!", 450, 450, "Temps écoulé")

Sleep(1000)

Next

Shutdown(4)

EndFunc ;_finsession

Thanks,

Thierry

Edited by TPlanet

Share this post


Link to post
Share on other sites



I would like the script to pause (or to stop the timer) while the session is not active. I mean if they change user instead of loging off.

Seems like a question for the general help and support forum

So, here is the code... Enjoy;

Or is this an example??

Share this post


Link to post
Share on other sites

how do we erase this?

Share this post


Link to post
Share on other sites

go to click edit and then full editor (at your main topic)

and change the title to: MOD REMOVE THIS SCRIPT or something

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0