?
Solved

Timing last user input

Posted on 2003-03-07
9
Medium Priority
?
251 Views
Last Modified: 2012-06-21
I need to implement a background processing thread in my Windows app. The thread should “wake up” one hour after the last user interface activity, and run some time-consuming maintenance functions, like file backups. The idea behind one hour is to activate the thread when the app is not actively used.

How can I detect that there was no user interface activity for a certain period of time? Inserting some checkpoints into the user input functions (like OnMouseMove or OnKeydown) is hardly an option, since there is a lot of interface-related functions in my app. Is there a more elegant way to do it?
0
Comment
Question by:olegsp
[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
9 Comments
 
LVL 1

Author Comment

by:olegsp
ID: 8093895
Well, looks like I need some 100 lines of code to properly set the trigger, and it is guaranteed to work for Win 2000/XP only...

Indeed, "Microsoft-elegant" :o( ...

With this option it is really easier for me just to add a single timing line to all my user-interface functions!
0
 
LVL 86

Accepted Solution

by:
jkr earned 1000 total points
ID: 8095109
Check out this MSJ Q&A column where Paul DiLascia discusses some options: http://www.microsoft.com/msj/0200/c++/c++0200.asp

 LASTINPUTINFO lpi;
 lpi.cbSize = sizeof(lpi);
 GetLastInputInfo(&lpi);

 DWORD dwIdleTime = lpi.dwTime;

(Win98/W2k and above)

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 86

Expert Comment

by:jkr
ID: 8095110
Forgot to mention, there is also code for systems that are older.
0
 
LVL 9

Expert Comment

by:Joeisanerd
ID: 8096334
If you are a system administrator trying to set this things or just doing it for yourself then make you app into a screen saver and have windows screensaver wait 60 minutes to start. This way windows will call you program when the screen saver starts. Screen savers are fairly easy to create, basically just rename the file to .scr and your off.  You can do a simple search on the web for some other screen saver how to's;

If Windows 98 and 95 are your fancy then screen saver is the way to go.
0
 
LVL 1

Author Comment

by:olegsp
ID: 8097095
No, I am not a sysadmin, but I am writing an app which is supposed to run for a long period of time and, when idle, will need to do some backups and cleanup of its data files. So screensaver is not really a good option... Looks like jkr's suggestion is the easiest so far...
0
 
LVL 86

Expert Comment

by:jkr
ID: 8128585
>>Looks like jkr's suggestion is the easiest so far

So, any ends still open?
0
 
LVL 11

Expert Comment

by:bcladd
ID: 9892947
No comment has been added lately, so it's time to clean up this TA. I will
leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to jkr: Grade A

Please leave any comments here within the next seven days.

Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (http://www.experts-exchange.com/help.jsp#hi73).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

764 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