Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automatically Shut down application if not used
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00800554
Message ID:
00800735
Views:
30
>>Hi Kevin
>>
>>A custom timer object could have three additional properties to hold (1) the last key pressed, (2) the last mouse x position, and (3) the last mouse y position. In the timer init event set the three properties using LASTKEY(), MROW(), and MCOL(). Set the timer interval to 60 minutes (or whatever period is required).
>>
>>When the timer event fires compare the three properties to their current states. If any of them are different update the properties with the new (current) values and return normally. If the current state is identical then I would assume the system is idle i.e. no keyboard activity and no mouse movement for the timer interval, then quit the application.
>>
>>Running a timer consumes very little processing power or other resources.
>
>Jos,
>Your solution will work great exept sometimes it can take close to 2 hours before the application shuts down. If timer is initialized at time 0 minutes and mose is moved at time 1 minute, when timer fires at time 60 minutes it will regiser change and reset properties. Timer will fire again at itme 120 minutes and register no change and shut down the app. Time elapsed since mouse movement in this example is 119 minutes. If this is aceptabe this is a great solution.
>
>Just my $0.02
>

Einar, there are two options:

(1) reduce the timer interval to 30 minutes. This is a minor issue becuase if the user does nothing for 30 minutes then one could also assume its inactive.

(2) add a fourth property to the timer which is a simple counter. Set the timer interval to a much shorter period eg 5 minutes. On the timer event increment the timer counter property by +1 if the lastkey(), mrow(), or mcol() are all the same and reset the counter to 0 if anything has changed. Then at the end of the timer event test for the counter value. If it reaches some maximum value then exit. To test for 1 hour of no activity you would test for counter value = ( 60 / timer interval in mins ).
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Previous
Reply
Map
View

Click here to load this message in the networking platform