With this script you can actually control your kids computer time.
The script asks for a code to allow X minutes of computer time.
Codes are recorded in a text file, not to be usable again and again. The codes should have a certain rule to match to be valid. (In the current script the first and last digits have to add up to 10, well, my kids are small enough not to decode this rule for the time being. For example a valid code is 23848, and also 176639.)
When the specified time elapses, the computer screen is dimmed with a semitransparent layer and nothing can be done - except for switching off. (But if you add the script to the autostart folder, it starts again.)
There is a Parent Hotkey (and also a master password) to kill the script or to quickly give an access to the computer.
Remaining time is indicated in a splash bar, getting more and more red as the end-time approaches.
Thanks for the inspiration for some of the scripters working on locking the computer (2 threads I think).
It is fun. The code is not streamlined at all , but works seamlessly.
This is the sript:
Code:
#NoTrayIcon
#SingleInstance FORCE
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Persistent
IniFile = %A_ScriptDir%\UsedKeys.log
IfExist, %IniFile%
IniRead, UsedKeyList, %IniFile%, Settings, UsedKeyList
Time1 := 30 * (60 * 1000) ;minutes
KeyLength := ;X character - empty means any length accepted
FirstLastSum := 10
ScreenSaverTime := 30 ;sec
ShowTimeUpdate := 1000 ;millisec
Gosub, ShowTime
Gosub, AskKey
return
AskKey:
Hg := A_ScreenHeight ;- 30
Wd := A_ScreenWidth
WinHide, ahk_class Shell_TrayWnd
Hotkey, LWin, KeyDim
Hotkey, RWin, KeyDim
Hotkey, LCtrl, KeyDim
Hotkey, RCtrl, KeyDim
Hotkey, LAlt, KeyDim
Hotkey, RAlt, KeyDim
Gui, +AlwaysOnTop +Disabled -SysMenu +Owner -Caption ; +Owner avoids a taskbar button.
Gui, Color, Black
Gui, Show, NoActivate H%Hg% W%Wd% X0 Y0, spl2
WinSet, Transparent, 200, spl2
WinSet, AlwaysOnTop, Off, spl2
InputBox, Key, Code input, To use the computer you have to ask a code from your parents.`nInput the code:,,300,160
IfEqual, Key, mypass
Goto, GiveTime
If not Key
{
MsgBox,0,Code input, You have not written the code. Write the code and click OK.
Goto, AskKey
}
If ( KeyLength and ( StrLen(Key) != KeyLength ) )
{
MsgBox,0,Code input, The code length is not correct.
Goto, AskKey
}
If Key in %UsedKeyList%
{
MsgBox,0,Code input, The code %Key% is already used once. Not good.
Goto, AskKey
}
KeyCheck := SubStr(Key, 1, 1) + SubStr(Key, 0, 1)
If ( KeyCheck != FirstLastSum )
{
MsgBox,0,Code input, This code is not correct. Dont try to cheat around! Ask code from the parents.
Goto, AskKey
}
MsgBox,0,Code input, % "You have got " . round(Time1/60/1000) . " minutes. Click OK to start."
Gosub, LogKey
GiveTime:
Hotkey, LWin, OFF
Hotkey, RWin, OFF
Hotkey, LCtrl, OFF
Hotkey, RCtrl, OFF
Hotkey, LAlt, OFF
Hotkey, RAlt, OFF
Gui, Destroy
WinShow, ahk_class Shell_TrayWnd
SetTimer, AskKey, %Time1%
marad := round(Time1/1000)
Return
+^q:: ;Shift-Ctrl Q - Give Time
Send, {escape}
Key := "mypass"
Gosub, GiveTime
Return
+!q:: ;Shift-Alt Q - Exit
Send, {escape}
Key := "mypass"
Gosub, GiveTime
ExitApp
Return
^!q:: ;Alt_Ctrl Q - Reload
Send, {escape}
Key := "mypass"
Gosub, GiveTime
Reload
Sleep, 2000
Return
KeyDim:
if A_ThisHotkey in +^q,+!q,^!q
send, %A_ThisHotkey%
Return
LogKey:
UsedKeyList = %UsedKeyList%,%Key%
IniWrite, %UsedKeyList%, %IniFile%, Settings, UsedKeyList
Return
ShowTime:
marad := (marad - (ShowTimeUpdate / 1000))
marad1 := round(marad)
If marad < 1
{
SplashImage,3:Off
if (A_TimeIdle > (ScreenSaverTime*1000))
{
If !VoltCover
{
WinSet, Transparent, 50, A
VoltCover := 1
}
}
else
{
WinSet, Transparent, OFF, A
VoltCover =
}
}
else If marad < 30
SplashImage,3:,CWFF6666 W200 X450 Y30 B1 FS8 FM8,Still %marad1% seconds to go`nClose your stuff NOW!,,spl3
else If marad < 60
SplashImage,3:,CWFF66DD W150 X450 Y30 B1 FS8 FM8,Still %marad1% seconds to go`nClose your stuff!,,spl3
else If marad < 120
SplashImage,3:,CWFFAADD W150 X450 Y30 B1 FS8 FM8,Still %marad1% seconds to go,,spl3
else If marad < 180
SplashImage,3:,CWFFDDAA W150 X450 Y30 B1 FS8 FM8,Still %marad1% seconds to go,,spl3
else
SplashImage,3:,CWFFFF99 W150 X450 Y30 B1 FS8 FM8,Still %marad1% seconds to go,,spl3
SetTimer, ShowTime, %ShowTimeUpdate%
Return