Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to check when the user last clicked on the program's interface Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
Others
Language
Delphi All Versions
Views
90
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

Is there a way to find out when the user last clicked on a program's interface? It 
is some sort of like idle time but the idle time for this specific program.

Answer:

From inside the application it is fairly easy. You need three pieces of equipment 
here:

A "Time of last activity" variable, field of your main form
1   
2   FLastActive: TDateTime;



A timer that regularly checks the FLastActive variable against the current time. 
Set it to an interval of, say 60000, and set its Active property to true at 
design-time. The OnTimer event handler would be something like this (timeout after 
15 minutes):

3   if (FLastActive + EncodeTime(0, 15, 0, 0)) < Now then
4     Close;



A handler for the Application.OnMessage event that updates the FLastActive variable 
on each key or mouse message. The handler would do something like this:

5   case msg.message of
6     WM_KEYFIRST..WM_KEYLAST, WM_MOUSEFIRST..WM_MOUSELAST:
7       FLastActive := Now;
8   end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC