Click here to Skip to main content
6,595,444 members and growing! (19,416 online)
Email Password   helpLost your password?
Desktop Development » Desktop Gadgets » General     Intermediate License: The Common Development and Distribution License (CDDL)

pcNanny: Keep Track of What Your Kids are Doing on the Computer

By milkplus

Keep track of what your kids are doing on the computer
C#, Windows, .NET, Visual Studio, WinForms, Dev
Version:2 (See All)
Posted:6 Sep 2007
Updated:6 Jan 2009
Views:33,728
Bookmarked:82 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
15 votes for this article.
Popularity: 4.38 Rating: 3.73 out of 5
1 vote, 6.7%
1

2
2 votes, 13.3%
3
6 votes, 40.0%
4
6 votes, 40.0%
5

Overview

As a parent, I wanted to set limits on how much time my kids could spend on the family computer. I couldn't find anything simple and free to do this, so I wrote it myself in C#.

Requirements

This application only works if your family has a single shared PC computer where each person has their own account and only parents have "admin" accounts.

It should run under Windows 98/XP/Vista with .NET Framework 2.0 or later.

Features

  • Keeps track of how much time your kids spend on the computer
  • Allows you to set time limits for each day of the week
  • Nags your kids when they exceed their time limit (popup every 3 minutes)
  • Optional key logger so you can see what your kids say online*

DISCLAIMER: *This app includes an optional key logger to allow parents to see what their kids are saying online. I strongly discourage anyone from monitoring any computer that you do not own or do not have intellectual property rights over. It is illegal and punishable as a crime under (state law) to intercept electronic communications.

Quick Start

To install the application:

  1. Create a program folder and copy the binaries there - C:\Program Files\pcNanny
  2. Copy a shortcut into the "Start Menu" for all users - C:\Documents and Settings\All Users\Start Menu

Since the EXE stores data in the same folder as the EXE, it needs to be in a folder where all users can have write access. That is, somewhere like "Program Files".

How? (Reading the Code)

My first version of this program only showed the login time for the person logged in. This resulted in everyone sneaking up and "checking" the screen to see how much time the person sitting at the computer had used. That seemed dumb, so this version shows the login time of everyone in the family. We can all monitor each other.

For each user account, I keep track of time used, along with other information. When the application starts, if the date has changed, I reset the time used.

class UserInfo
{
    static public IniFile file = null;

    public string name = "Anon";
    public TimeSpan timeLimit = new TimeSpan(1, 0, 0); // 1 hour
    public TimeSpan timeUsed = new TimeSpan(0, 0, 0);
    public DateTime startDate = DateTime.Today;
    public bool loggedOn = false;
    public bool screenSaved = false;
    public bool screenLocked = false;

After you reach your time limit (the default is one hour), the graphic changes from green to red, and the window will come to the front every three minutes to annoy you.

//
// Annoy user after we are over time limit by
// bringing window to front every 3 minutes.
//
if (user.IsOverTime() &&
    (user.timeUsed.Minutes % 3) == 0 &&    // every 3 minutes
    user.timeUsed.Seconds < 5)    // annoy for 5 seconds
{
    Rectangle bounds = Screen.PrimaryScreen.Bounds;
    this.Left = (bounds.Width - this.Width) / 2;
    this.Top = (bounds.Height - this.Height) / 2;
    this.WindowState = FormWindowState.Normal;
    this.TopMost = true;
    this.Show();
}
else
{
    // if not being annoying, allow other windows to come to the front
    this.TopMost = false;
}

At first, I used voice samples, but the kids just hit mute and forgot about it. A three minute snooze seemed reasonable.

I don't want the kids to close the application, so I disabled the close box. Since they are not "admin" accounts, they can't run the Task Manager and shut it down that way.

// Get rid of control boxes
this.ControlBox = false;
this.MaximizeBox = false;
this.MinimizeBox = false;

// Disable close window unless ending session
this.Closing += 
  new System.ComponentModel.CancelEventHandler(this.OnClosingEvent);

private static int WM_QUERYENDSESSION = 0x11;
private static bool systemShutdown = false;

protected override void WndProc(ref Message m)
{
    if (m.Msg == WM_QUERYENDSESSION)
    {
        systemShutdown = true;
    }
    base.WndProc(ref m);
}

private void OnClosingEvent(object sender, 
             System.ComponentModel.CancelEventArgs e)
{
    if (!systemShutdown)
        e.Cancel = true;
}

I still need to handle the logon events such as screensaver start/stop and display lock/unlock. For those, I used some code by Richard Arthur in the .NET Journal.

self = this;    //used by SensLogon event handlers

SensLogon.StartScreenSaver += 
    new SensLogonEventHandler(SensLogon_StartScreenSaver);

private static void SensLogon_StartScreenSaver(string userName)
{
    UserInfo user = self.GetUser(userName);
    user.screenSaved = true;
}

History

  • 6 September, 2007 - Created
  • 13 May, 2008 - Added bar graph, all users, and screensaver + screenlock events
  • 10 July, 2008 - Improved annoy code, added sessionTimeUsed, and fixed reported error
  • August 2008 - Added key logger
  • 3 January, 2009: Updated article

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)

About the Author

milkplus


Member
David McClurg is a game programmer from Oregon, USA. He is currently interested in C#, xna for zune, and steering behaviors. When not coding, David enjoys tennis, kayaking, and botany.
Occupation: Software Developer
Company: Buzz Monkey Software
Location: United States United States

Other popular Desktop Gadgets articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 33 (Total in Forum: 33) (Refresh)FirstPrevNext
GeneralKids more immature these days? PinmemberMember 266702212:28 7 Jan '09  
GeneralAre you sure you actually want to do this? PinmemberDmitri Nesteruk8:20 7 Jan '09  
GeneralRe: Are you sure you actually want to do this? Pinmemberthund3rstruck9:06 7 Jan '09  
JokeRe: Are you sure you actually want to do this? PinmemberDmitri Nesteruk9:20 7 Jan '09  
GeneralRe: Are you sure you actually want to do this? Pinmemberthund3rstruck9:30 7 Jan '09  
GeneralRe: Are you sure you actually want to do this? Pinmembermilkplus10:32 7 Jan '09  
GeneralRe: Are you sure you actually want to do this? PinmemberDmitri Nesteruk10:43 7 Jan '09  
Generalstupid control system Pinmemberradioman.lt3:37 7 Jan '09  
GeneralAnother implementation Pinmembermaxal191719:57 20 Aug '08  
GeneralMoved to sourceforge Pinmembermilkplus12:00 12 Aug '08  
GeneralGood, but not all secure Pinmemberjacobjordan19:44 12 Jul '08  
GeneralRe: Good, but not all secure Pinmembermilkplus16:46 17 Jul '08  
GeneralJust came across this page.... Pinmemberltmarks22:17 3 Jul '08  
GeneralRe: Just came across this page.... PinmemberHarm Salomons8:24 8 Jul '08  
GeneralRe: Just came across this page.... Pinmembermilkplus16:19 10 Jul '08  
GeneralCan't get the LoginTime to work. Pinmembercp@otto13:56 13 Jun '08  
GeneralRe: Can't get the LoginTime to work. PinmemberHarm Salomons8:18 8 Jul '08  
GeneralRe: Can't get the LoginTime to work. Pinmembermilkplus16:35 10 Jul '08  
Generalyou beat me... PinmemberHarm Salomons8:43 16 May '08  
GeneralRe: you beat me... PinmemberJBDUDLEY4:20 8 Jul '08  
GeneralRe: you beat me... PinmemberHarm Salomons8:11 8 Jul '08  
GeneralRe: you beat me... PinmemberHarm Salomons9:28 8 Jul '08  
GeneralRe: you beat me... Pinmembermilkplus16:22 10 Jul '08  
GeneralRe: you beat me... PinmemberHarm Salomons11:21 11 Jul '08  
Generalsuggestions Pinmemberdvhh23:38 14 May '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 6 Jan 2009
Editor: Deeksha Shenoy
Copyright 2007 by milkplus
Everything else Copyright © CodeProject, 1999-2009
Web15 | Advertise on the Code Project