Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A Global Timer since last User's Input
Message
De
10/12/2004 06:21:22
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
09/12/2004 08:32:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00897805
Message ID:
00968243
Vues:
19
>>Hi Peter,
>>Nowadays I've another piece of code (more complex but based on a single timer - unfortunately something I can't publish for now).
>>I revisited the code and GetLastInputInfo documentation and I think now I can see why I wrote it like that then:
>>GetLastInputInfo checks input only and a mouse movement is not considered an input (if it's then I misinterpreted it and never tested)
>
>My test (see below) shows that GetLastInputInfo does also consider a mouse movement as input. And I assume that other/new types of input will also be handled by this api-call (now and in the future), making it the better candidate to do the job.
>Makes me wonder whether you could rewrite your (nowadays) more complex code to more simple code.
>
>This code works for 60 seconds. Touch nothing and the last value will be 1 minute. Move the mouse after 30 seconds and it will display something like .48 minutes.
>
local iTime as integer, iLast as integer
>local plii as string, cLast as string
>
>declare integer GetTickCount in kernel32
>declare short GetLastInputInfo in win32api string @ plii
>
>?
>
>for n = 1 to 2
>
>	iTime = GetTickCount()
>	plii = chr(8) + replic( chr(0), 7 )
>	cLast = GetLastInputInfo( @plii )
>	iLast = ( asc( substr( plii, 8, 1 ) ) * 16777216 ) + ;
>			( asc( substr( plii, 7, 1 ) ) * 65536 ) + ;
>			( asc( substr( plii, 6, 1 ) ) * 256 ) + ;
>			( asc( substr( plii, 5, 1 ) ) )
>
>	?? ( iTime - iLast ) / 60000, ' '
>
>	if n=2
>		exit
>	endif	
>	
>	for k = 1 to 60
>		inkey(1)
>		?? str( mod( k, 10), 1 )
>	next
>next
Peter,
I think probably also this code would return to a timer implementation. Here is my partial class. I called it complex but checking it back sounds it was not much complex. This doesn't check for inactivity but for 'shutdown' flag for remote shutdowns, would be easy to convert for inactivity check.
* define class ...
* ...
Add Object FlagChecker As Timer With Interval=30000

Procedure FlagChecker.Timer
  Local lcShutDown,lnSecondsLeft
  With This.Parent
    If .IsShutDownFlagged()
      If !.lStartCountDown
        .nCountdown = Int(.GetShutdownTime())
        .nShutDownType = .GetShutDownType()
        .lStartCountDown = .T.  && Enable CountDown counter
        This.Interval = 5000
      Else
        .nCountdown = Int(.nCountdown - (This.Interval/1000))
        If .nCountdown <= 0
          This.Enabled = .F.
          .ShutDownApp()
        Endif
      Endif
      If !.lNotified
        * Prepare message
TEXT to lcShutdown textmerge noshow
Application will shutdown automatically in <<.nCountDown>> seconds.
Please complete your work and shutdown the application.
ENDTEXT
        .lNotified = ;
          ( Messagebox(m.lcShutDown,0+64,"Application Shutdown",This.Interval) = 1 ) && Show Message
      Endif
    Else
      If .lStartCountDown && If a countdown was in progress
        .lStartCountDown = .F.
        This.Interval = 30000
        * Show cancel message
        Messagebox("Application shutdown is cancelled."+chr(13)+;
          "You may continue to work.",0+64,;
          "Application Shutdown",This.Interval)
      Endif
    Endif
  Endwith
Endproc
* other procs
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform