views:

28

answers:

2

Is it programmatically possible to intercept the maximize/restore event on Windows such that when you click on a minimized button on the taskbar, it asks you for a password?

Update: To clarify, I'm asking if it is possible systemwide. For example, I may pick a browser/im/editor window that I want to secure if I need to walk away from the machine for a few minutes.

A: 

It is possible to capture a "SizeChange" event. I don't see anything specific to Minimizing/Restoring.

With .NET (C#), you'd do something like this:

private void Form1_Load(object sender, EventArgs e)
  {
    // Tie in a new event handler.
    this.SizeChanged += new EventHandler(Form1_SizeChanged);
  }

  void Form1_SizeChanged(object sender, EventArgs e)
  {
     if(WindowState == FormWindowState.Minimized)
         MessageBox.Show("Window is now: " + WindowState.ToString());
  }

If you can be more specific as to which language you are using, perhaps me or someone else can better answer.

nsr81
Updated question. It's not about a specific language - hence the language-agnostic tag.
Mussnoon
A: 

Well, you could write a program that deep hooks the target program.

Seriously, however, if I can walk up to your computer and encounter that you got away lucky the first time. Next time I'll be back with a powerful tool to read disk files, scrape memory, or worse.

Winkey+L, dude!

Joshua
Personally, it really isn't a defense against a "malicious" user. (Not someone who does it on purpose anyhow...).
Mussnoon