PC Review


Reply
Thread Tools Rate Thread

Detect inactivity

 
 
Sonya
Guest
Posts: n/a
 
      14th Jan 2007
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWFyayBSLiBEYXdzb24=?=
Guest
Posts: n/a
 
      15th Jan 2007
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
>

 
Reply With Quote
 
Sonya
Guest
Posts: n/a
 
      15th Jan 2007
Mark R. Dawson schrieb:

> 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.


Thanks a lot!
Sonya
 
Reply With Quote
 
Sonya
Guest
Posts: n/a
 
      16th Jan 2007
Hi,

That works perfect for applications with visible forms but unfortunately
not with my tray application. ;(

Sonya
 
Reply With Quote
 
semedao
Guest
Posts: n/a
 
      17th Jan 2007
Hi Sonya
Do you must work paralel with the screen saver , or you can use some timeout
interval of inactivity to identified that the user is not working ?

"Sonya" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Sonya
Guest
Posts: n/a
 
      17th Jan 2007
semedao schrieb:
> Hi Sonya
> Do you must work paralel with the screen saver , or you can use some timeout
> interval of inactivity to identified that the user is not working ?
>


I could use any timeout interval but I thought in using screensaver
event but it seems I have to use simething else.
 
Reply With Quote
 
semedao
Guest
Posts: n/a
 
      18th Jan 2007
look at
http://pinvoke.net/default.aspx/user...InputInfo.html

"Sonya" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> semedao schrieb:
>> Hi Sonya
>> Do you must work paralel with the screen saver , or you can use some
>> timeout interval of inactivity to identified that the user is not working
>> ?
>>

>
> I could use any timeout interval but I thought in using screensaver event
> but it seems I have to use simething else.



 
Reply With Quote
 
Sonya
Guest
Posts: n/a
 
      18th Jan 2007
semedao schrieb:
> look at
> http://pinvoke.net/default.aspx/user...InputInfo.html
>


Thx, I think I will use this.
Sonya
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: log off due to inactivity =?Utf-8?B?UmFqS29obGk=?= Windows XP General 0 29th Dec 2006 07:25 AM
DETECT INACTIVITY =?Utf-8?B?S2xhdHV1?= Microsoft Access Form Coding 2 7th Aug 2006 08:15 PM
Can sumif detect text strings or detect if a dollar sign $ is in a cell? MollyDavis Microsoft Excel Misc 4 17th Apr 2004 11:45 PM
Can sumif detect text strings or detect if a dollar sign $ is in a cell? MollyDavis Microsoft Excel Worksheet Functions 4 17th Apr 2004 11:45 PM
inactivity log off Antonio Microsoft Access VBA Modules 1 30th Jul 2003 02:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:36 AM.