?
Solved

Monitoring Inactivity in Delphi

Posted on 2005-03-22
5
Medium Priority
?
451 Views
Last Modified: 2010-04-05
I'm writing a program and I need a way to enable a timer when
a user stops all activity on a computer(mouse movement, keyboard)
The program will always be running in the System tray.

Any code would be appreciated.
0
Comment
Question by:ralph44e
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 46

Expert Comment

by:aikimark
ID: 13603130
Why not just use the system inactivity monitor?

Create a screen saver
http://www.mindspring.com/~cityzoo/scrnsavr.html
http://delphi.about.com/od/screensavers/
http://www.pcmag.com/article2/0,1759,1180484,00.asp
http://www.delphifaq.com/fq/q2192.shtml
http://community.borland.com/article/0,1410,26652,00.html

Set the screen saver to the Desktop default, using the inactivity time limit you want.

========================
I probably need a bit more information on what you are trying to do.

1. Do you want to start a timer or reset a timer when mouse/keyboard events happen?
2. Do you want to take some action if the interval between events exceeds some preset limit?
3. What do you want to do when the system goes into power-save mode?
4. What do you want to do when the user logs off?
5. How is your application started?
6. Is your application running as a Windows service?
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13603383
try this simple code.

function secondsIdle: dword;
var liInfo: TLastInputInfo;
begin
        liInfo.cbSize := SizeOf(TLastInputInfo) ;
        GetLastInputInfo(liInfo) ;
        Result := (GetTickCount - liInfo.dwTime) DIV 1000  ;
end;

Now have a timer set on every 30 seconds:

if secondsIdle > 10000 then begin
   form1.caption:='User has been idle for more than 10 minutes!';
end;
0
 
LVL 15

Accepted Solution

by:
mikelittlewood earned 1000 total points
ID: 13603396
In your case, turn on a timer here:
if secondsIdle > 10000 then begin
   Timer1.Enabled
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13605100
use a TApplication ("Additional" tab in the components list)
and use the "OnIdle" event
0
 
LVL 46

Expert Comment

by:aikimark
ID: 13605332
I thought this question was about any idle period in any application
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question