Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automatically Shut down application if not used
Message
 
To
16/06/2003 17:23:17
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00800554
Message ID:
00801446
Views:
14
Miles

I have an FLL that I run at the beginning of the application, from that I create an Idle Timer Object. Set the properties and then wait for it to kick in. It works great and only tracks mousements for the application. So if the application is minimized, it will still shutdown, even if the user is busy in word typing and moving the mouse around.
*Main.prg

*-------------------------------------------------------------------------------------------------------*
* Create the ShutDown Timer
*-------------------------------------------------------------------------------------------------------*
SET LIBRARY TO idle.fll addi
InstallHooks(.t.)
public g_oIdleTimer
g_oIdleTimer = createobject("CheckIdleTime")

...
...
********************************************************************************
* Shut Down Timer Class
********************************************************************************

define class CheckIdleTime as timer
	Enabled = .t.
	Interval = 10000 && CHECK EVERY 10 seconds
	procedure Timer
		LOCAL lnMSecs,lcMSecs,lnLen,lcResults
		lcResults=GetCurrentTime1() - GetHookTime1()
		lcMSecs=GetCurrentTime1() - GetHookTime1()
		lnMSecs=MTON(lcMSecs)
		IF gnMaxSecs > 0
			IF lnMSecs > gnMaxSecs
				IF FILE('c:\dev.cqi')
					oToolbar.command4.click
				ELSE
					*******************************************************************************
					* Record Automatic ShutDown Time
					*******************************************************************************
					lcMess=[Auto System Shutdown]
					TEXT TO lcCmd noShow
						INSERT INTO ct_errLog (ErrorMessage,UserName) VALUES (?lcMess,?gcUser)
					ENDTEXT
					IF SQLEXEC(gnConnHandle,lcCmd)<1
						=SQLERROR(program(),program(),transform(lineno()))
					ENDIF 
					*******************************************************************************
					* Record logout time for user
					*******************************************************************************
					ltNow=DATETIME()
					TEXT TO lcCmd noShow
						UPDATE userLogins set LogOutTime=?ltNow WHERE UserLogins=?gnUserLogins
					ENDTEXT
					IF SQLEXEC(gnConnHandle,lcCmd)<1
						=sqlerror()
					ENDIF 
					QUIT
				ENDIF
			ENDIF 
		ENDIF 
	ENDPROC 
ENDDEFINE 
Previous
Reply
Map
View

Click here to load this message in the networking platform