FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Cerrar Aplicaci贸n cuando no se use
Posts: 72
Joined: Tue Oct 02, 2012 04:36 PM
Cerrar Aplicaci贸n cuando no se use
Posted: Thu Oct 31, 2013 09:42 PM

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

Posts: 408
Joined: Sun Aug 13, 2006 05:38 AM
Re: Cerrar Aplicaci贸n cuando no se use
Posted: Mon Jan 13, 2014 05:30 PM

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

Saludos

Quique
Posts: 68
Joined: Tue Apr 14, 2009 09:26 PM
Re: Cerrar Aplicaci贸n cuando no se use
Posted: Wed Jan 15, 2014 08:38 PM
Hola, mira mi classe tinativo:

Saludos

William Adami


Code (fw): Select all Collapse
* 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 ENDDUMP
Posts: 282
Joined: Mon Oct 10, 2005 08:55 AM
Re: Cerrar Aplicaci贸n cuando no se use
Posted: Thu Jan 16, 2014 04:06 PM

William,
He probado la utilidad y funciona muy bi茅n, me ser谩 util.
Gracias por el aporte. :shock:

Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Cerrar Aplicaci贸n cuando no se use
Posted: Thu Jan 16, 2014 05:07 PM

William, Excelente!!!

Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion