AutoHotkey Community

It is currently May 25th, 2012, 11:26 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: January 31st, 2008, 9:11 pm 
Offline

Joined: January 31st, 2008, 8:47 pm
Posts: 88
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



Last edited by fures on February 1st, 2008, 12:20 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 31st, 2008, 9:35 pm 
Offline

Joined: April 30th, 2006, 6:23 pm
Posts: 358
Location: Shigle Springs
Sweet, I was going to make one! :D
You saved me time.
I will look at your code and try soon.
One thing I was going to do, and I am sure it can still be done using your code, is to make the script look to a network share, like my computer, for an INI that contains the unlock code and or add time to it.
Maybe have it check every 30 sec in case you need to get their attention for dinner or something..
Maybe add a line in the INI for a message! :P

I have my kids on a "earn" computer time system. They do chores, they get time..
You can also encrypt the INI in case they are smart little buggers like mine. :twisted:

_________________
CPULOCK.com
virusSWAT.com
Computer Repair Computer Service.com
911PCFIX.com


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group