Hi Sonya,
I do not believe there is any native event in .Net that will tell you
this, however you can override your forms WndProc method to capture raw
windows messages to see when the WM_SYSCOMMAND message is sent with a
parameter of SC_SCREENSAVE, this occurs when the screen saver starts. For
example:
using System;
using System.Windows.Forms;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
MyForm f = new MyForm();
Application.Run(f);
}
}
class MyForm : Form
{
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
int WM_SYSCOMMAND = 0x112;
int SC_SCREENSAVE = 0xf140;
if ((m.Msg == WM_SYSCOMMAND) && (m.WParam.ToInt32() ==
SC_SCREENSAVE))
{
Console.WriteLine("Screen saver activated");
}
}
}
}
Mark
--
http://www.markdawson.org http://themightycoder.spaces.live.com
"Sonya" wrote:
Hi,
can an application detect if windows starts the screensaver? So that my
application can do some work while the user is afk.
Greetings Sonya