Hola AMIGOS....
Quiero cerrar mi Aplicaci贸n luego de cierto tiempo que no se use, alguien tendr谩 un ejemplo o implementado algo?
muchas gracias
Saludos
David
Hola AMIGOS....
Quiero cerrar mi Aplicaci贸n luego de cierto tiempo que no se use, alguien tendr谩 un ejemplo o implementado algo?
muchas gracias
Saludos
David
Se me ocurre utilizar un timer que vaya incrementando un contador, donde el contador determinar谩 cuando quieres que se apague, cada vez que realices un proceso borras el contador para que el timer vuelva a empezar, si no se usa, no se reinicia el contador y al llegar al tiempo esperado cierras el programa
* exemplo do uso da classe Tinativo
* Apos um tempo de inatividade do mouse
* e do teclado chama uma funcao qualquer.
#include "fivewin.ch"
static oWnd
*************
function main
*************
nTempo_espera:=10 //Tempo a ser esperado ate chamar a funcao
cNome_funcao:="LOGOFF()" //nome da funcao a ser chamada quando
//chegar no tempo de espera
lTimercontinua:=.f. //se apos executar a funcao , continua monitorando
//a inatividade do mouse e teclado.
define window oWnd title "Teste de teclado e mouse"
activate window oWnd on init tinativo():new(nTempo_espera,cNome_funcao, lTimerContinua)
return NIL
function logoff
msgalert("AQUI ENTRA SUA FUNCAO DE LOGOFF !","AVISO")
return nil
tinativo.prg
#include "fivewin.ch"
CLASS TINATIVO
DATA nTimeInpAntes
DATA nTimeInpDepois
DATA cTimeAtu
DATA nTempo
DATA oTimerTime
DATA cFunc
DATA lContinuar
METHOD NEW( nTime, cFuncao, lContinua ) CONSTRUCTOR
METHOD ver_tempo()
ENDCLASS
**********************
METHOD new(ntime,cFuncao,lContinua) CLASS TINATIVO
**********************
::cfunc:=cfuncao
::ntempo:=ntime
::lContinuar:=lContinua
::oTimerTime := TTimer():New( 1000, { || ::VER_TEMPO() } )
::oTimerTime:Activate()
::cTimeAtu := time()
::nTimeInpAntes := getInputState() // 0 = erro
return self
*************************
METHOD VER_TEMPO CLASS TINATIVO
*************************
::nTimeInpDepois := getInputState()
if ( ::nTimeInpDepois - ::nTimeInpAntes ) > 0
::nTimeInpAntes := getInputState()
::cTimeAtu := time()
endif
if ( CONVTIME(time()) - CONVTIME(::cTimeAtu) ) > ::ntempo
::oTimerTime:DeActivate()
aux:=::cfunc
* aqui executa a funcao
&aux
if ::lContinuar
::oTimerTime:Activate()
::cTimeAtu := time()
endif
endif
return NIL
FUNCTION CONVTIME(ZZ)
Z:=(VAL(LEFT(ZZ,2))*360)+(VAL(SUBSTR(ZZ,4,2))*60)+VAL(RIGHT(ZZ,2))
RETURN Z
**----------------------------------------------------------------------
#pragma BEGINDUMP
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
#include "windows.h"
#include "hbapi.h"
HB_FUNC( GETINPUTSTATE )
{
LASTINPUTINFO lpi;
lpi.cbSize = sizeof(LASTINPUTINFO);
if (!GetLastInputInfo(&lpi))
{
hb_retni(0);
}
hb_retni(lpi.dwTime);
}
#pragma ENDDUMPWilliam,
He probado la utilidad y funciona muy bi茅n, me ser谩 util.
Gracias por el aporte. ![]()
William, Excelente!!!