Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A Global Timer since last User's Input
Message
De
09/12/2004 08:32:02
 
 
À
09/12/2004 05:50:47
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00897805
Message ID:
00967991
Vues:
18
>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
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform