[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Monitoring Inactivity in Delphi

Posted on 2005-03-22
5
Medium Priority
?
461 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
  • 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

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

590 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