Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Application timer / timeout ??
Message
 
 
To
26/06/2012 09:09:21
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01484249
Message ID:
01546922
Views:
61
>>>>>>>I need to add a 'timeout' feature to a VFP application.
>>>>>>>Basically all I need it to do is after 30 minutes of inactivity I need the application to close. Seems easy enough to create a timer object - but is there an easy way to tell if there has been any activity (mouse or keyboard) in the app?
>>>>>>
>>>>>>There is a class by Greg R that does it.
>>>>>
>>>>>Yep but the download doesn't work.
>>>>
>>>>You're right, seems to be not working - Greg has to fix his site.
>>>
>>>Thanks for the heads' up. I was not aware that the site was having problems. It seems that something most of changed at GoDaddy.com and my settings in my site was conflicting with the new change. But it is fixed now.
>>>
>>>By the way, here is a link to the tool to close a form after N minutes of idle time.
>>>
>>>http://www.glrsoftware.com/download/download.asp?file=AutoCloseForm.zip
>>
>>This is the code our timer class is using to detect inactivity:
>>
>>LOCAL liTime AS INTEGER, liLast AS INTEGER, lplii AS STRING, lcLast AS STRING
>>
>>liTime      = GetTickCount()
>>lplii       = CHR(8) + REPLICATE(CHR(0), 7)
>>lcLast      = GetLastInputInfo(@lplii)
>>liLast      = (ASC(SUBSTR(lplii, 8, 1)) * 16777216) + ;
>>              (ASC(SUBSTR(lplii, 7, 1)) * 65536) + ;
>>              (ASC(SUBSTR(lplii, 6, 1)) * 256) + ;
>>               ASC(SUBSTR(lplii, 5, 1))
>>
>>* liTime is the milliseconds your computer has been on.
>>* liLast is the milliseconds your computer was on when your last keystroke or mousemove was.
>>
>>lnMinutesIdle = ROUND((liTime - liLast) / 60000, 1)
>>
>>
>>It doesn't seem to work well when the application is minimized.
>>
>>I am wondering what is the correct code for detecting idle time?
>>
>>Thanks in advance.
>
>Revisiting the passed, I see.
>
>First, I see that you are using a WinAPI call (GetLastInputInfo). I would think that it would return the last input from any input, not just the foxpro application. The class I created uses the internal foxpro keyboard and mouse buffer to determine if the state of the current application has changed or not.

I'll take a closer look at your class.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform