Saludos.
Hace d铆as, el Master Joao (Karinha), me solicit贸 que le dejara un ejemplo de la funci贸n "sysIdleSecs()"
Ac谩 se los dej贸, a 茅l y a todo el foro, espero sea de utilidad para muchos.
NOTA: La funci贸n mide el tiempo transcurrido SIN actividad del mouse y teclado EN TODA LA PC , no es el tiempo sin actividad dentro de nuestra aplicaci贸n.
El contador de dicha funci贸n, se reinicia automaticamente a 0 cuando se realiza alguna operacion con el mouse o el teclado.
Un abrazo.
NOTA: El archivo "Cuentas32.ch" que esta al inicio del c贸digo, es mi versi贸n personalizada del "Fivewin.ch"
Hace d铆as, el Master Joao (Karinha), me solicit贸 que le dejara un ejemplo de la funci贸n "sysIdleSecs()"
Ac谩 se los dej贸, a 茅l y a todo el foro, espero sea de utilidad para muchos.
NOTA: La funci贸n mide el tiempo transcurrido SIN actividad del mouse y teclado EN TODA LA PC , no es el tiempo sin actividad dentro de nuestra aplicaci贸n.
El contador de dicha funci贸n, se reinicia automaticamente a 0 cuando se realiza alguna operacion con el mouse o el teclado.
Un abrazo.
#Include "Cuentas32.ch"
// function to exit the app when default 'x' number of seconds pass with no activity
// from the keyboard or mouse.
// attention! IT IS NOT THE TIME without activity of our application, it is the inactive time of the PC
// funci贸n para salir de la aplicaci贸n cuando pasan 'x' cantidad de segundos predeterminados sin actividad
// del teclado o raton.
// 隆atenci贸n! NO ES EL TIEMPO sin actividad de nuestra aplicacion, es el tiempo inactivo de la PC
// fun莽茫o para sair do aplicativo quando o n煤mero padr茫o 'x' de segundos passa sem atividade
// do teclado ou mouse.
// aten莽茫o! N脙O 脡 O TEMPO sem atividade do nosso aplicativo, 茅 o tempo inativo do PC
Static oDlg, oTimerExit
Static nInterval
****************************************************************************************************************************
Function Fnct_Prueba()
聽 聽 Local oGet1
聽 聽 Local cVar1 := spac(10)
聽 聽 Public nSecondsToOut:= 55 //(segundos)
聽 聽 nInterval:=1*60000 聽//(1 x 60000 = 1 minuto)
聽 聽 Define Dialog oDlg 聽resource "oDlg_Prueba"
聽 聽 聽 聽 聽Redefine get oGet1 Var cVar1 Id 100 聽of oDlg
聽 聽 Activate Dialog oDlg on init (oGet1:SetFocus(),Fnct_StartCounterTime() )
Return ( Nil )
***********************************************************************************************************************
Function Fnct_StartCounterTime ()
聽 聽Define Timer oTimerExit of oDlg Interval nInterval Action ( iif( sysIdleSecs()>nSecondsToOut,fExit(),))
聽 聽oTimerExit:Activate()
Return NIL
********************************************************************************************************************
function fExit()
聽 聽 oTimerExit:Deactivate()
聽 聽 oTimerExit:End()
聽 聽 msgAlert('Tu Sesi贸n Finaliz贸 Por Inactividad.','Fin de Sesi贸n')
聽 聽 oDlg:End()
聽 聽 quit
return .t.
*********************************************************************************************************************
// 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 typedef struct tagLASTINPUTINFO {
// 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 UINT cbSize;
// 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 DWORD dwTime;
// 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 } LASTINPUTINFO, *PLASTINPUTINFO;
WINUSERAPI BOOL WINAPI GetLastInputInfo(PLASTINPUTINFO);
typedef 聽BOOL (WINAPI *GETLASTINPUTINFO_)(PLASTINPUTINFO);
HB_FUNC( SYSIDLESECS )
{
聽 聽HINSTANCE handle= LoadLibrary("user32.dll");
聽 聽if ( handle)
聽 聽{
聽 聽 聽 GETLASTINPUTINFO_ pFunc;
聽 聽 聽 pFunc = GetProcAddress( handle,"GetLastInputInfo" );
聽 聽 聽 if (pFunc)
聽 聽 聽 {
聽 聽 聽 聽 聽LASTINPUTINFO lpi;
聽 聽 聽 聽 聽lpi.cbSize = sizeof(LASTINPUTINFO);
聽 聽 聽 聽 聽if (!pFunc(&lpi))
聽 聽 聽 聽 聽{
聽 聽 聽 聽 聽 聽 hb_retni(0);
聽 聽 聽 聽 聽}
聽 聽 聽 聽 聽else
聽 聽 聽 聽 聽{
聽 聽 聽 聽 聽 聽 hb_retnd( ( DOUBLE ) ( GetTickCount() - lpi.dwTime ) * 0.001 );
聽 聽 聽 聽 聽}
聽 聽 聽 }
聽 聽else
聽 聽 聽 {
聽 聽 聽 聽 聽hb_retni(0);
聽 聽 聽 }
聽 聽}
聽 聽if (handle)
聽 聽 聽 {
聽 聽 聽 聽 聽FreeLibrary( handle);
聽 聽 聽 }
}
#pragma ENDDUMP
***********************************************************************************************+"Los errores en programaci贸n, siempre est谩n entre la silla y el teclado..."
Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin
Carora, Estado Lara, Venezuela.
Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin
Carora, Estado Lara, Venezuela.