473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Detect inactivity

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
Jan 14 '07 #1
7 6301
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
Jan 15 '07 #2
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
Jan 15 '07 #3
Hi,

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

Sonya
Jan 16 '07 #4
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" <so***@nowhere.comwrote in message
news:eI**************@TK2MSFTNGP02.phx.gbl...
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

Jan 17 '07 #5
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.
Jan 17 '07 #6
look at
http://pinvoke.net/default.aspx/user...InputInfo.html

"Sonya" <so***@nowhere.comwrote in message
news:uQ*************@TK2MSFTNGP06.phx.gbl...
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.

Jan 18 '07 #7
semedao schrieb:
look at
http://pinvoke.net/default.aspx/user...InputInfo.html
Thx, I think I will use this.
Sonya
Jan 18 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Serial # 19781010 | last post by:
I have a multithreaded server - one thread / client. I have a client 1 connected to thread A, and a I have client 2 connected to thread B. After certain equal period of inactivity Client 1 sends a...
2
by: Keith Wilby | last post by:
The link below: http://support.microsoft.com/default.aspx?scid=kb;en-us;128814 to the Microsoft KB "Detect Idle Time" article shows how to detect "idle" time. However, if a user is active but...
19
by: Frank Rizzo | last post by:
I want to log the user out when there has been a period of inactivity in the application. The key here is inactivity of the application, not the system. I know that you can retrieve the...
0
by: Jonas Hei | last post by:
I need to implement a listener that listens on a certain UDP port. I am trying to use Socket.BeginReceiveFrom for this purpose. In this scenario the remote clients (hundreds of them) send most of...
4
by: Dominique Vandensteen | last post by:
I need to receive an event when a form has a certain time of inactivity. Deactivate and Activated events are not good enough. With these events I can't find out inactivity if the form is simply...
4
by: sconeek | last post by:
hi all, i am trying to implement a page re-direction after a certain amount of inactivity. can somebody please help me in this. i was thinking could i display a screensaver using JavaScript after...
2
by: Cam | last post by:
Hi to all I have searched this subject and found some posts but none of them seem to answer my problem. I am developing a shop site and need to detect when a session times out through...
10
by: Xu, Qian | last post by:
Hi All, Is it possible to detect whether a (confirmation or prompt) dialog is present? And furthermore, how to press OK, Cancel buttons of a dialog? I am writing a javascript based test...
2
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, I want an app that I'm writing to be able to hide itself whenever it hasn't been used for say 10 minutes. Is there a smart way to detect user activity within an app. Kind of overall...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.