Quit the program when time out (like screen saver)

Quit the program when time out (like screen saver)

Postby dutch » Sat Mar 10, 2012 3:44 pm

Dear All,

My customer ask for automatic quit or logout after specific time (like screen saver).

How can I do it? Any idea most welcome..

Regards,
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Quit the program when time out (like screen saver)

Postby WilliamAdami » Sat Mar 10, 2012 4:10 pm

hello, see my class tinativo()

William Adami


Code: Select all  Expand view

* 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
*****************************************
* CLASSE PARA DETECTAR SE O SISTEMA ESTA
* INATIVO POR (N) SEGUNDOS, E SE ESTIVER,
* CHAMA UMA FUNCAO (PODE SER UMA FUNCAO
* DE LOGOFF , DESCANSO DE TELA , ETC..)
*****************************************
* AUTOR DA FUNۂO ORIGINAL :
* POMPEO (GUARATINGUETA)
* MIGRAۂO DA FUNۂO PARA CLASSE:
* WILLIAM DE BRITO ADAMI
*****************************************
#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







 
WilliamAdami
 
Posts: 68
Joined: Tue Apr 14, 2009 9:26 pm
Location: Brasil

Re: Quit the program when time out (like screen saver)

Postby dutch » Mon Mar 12, 2012 4:55 am

Dear William,

Thanks for nice class and example. It's really useful for me.

Regards,
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Quit the program when time out (like screen saver)

Postby Silvio.Falconi » Sat Apr 11, 2020 5:29 pm

WilliamAdami wrote:hello, see my class tinativo()

William Adami


Code: Select all  Expand view

* 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
*****************************************
* CLASSE PARA DETECTAR SE O SISTEMA ESTA
* INATIVO POR (N) SEGUNDOS, E SE ESTIVER,
* CHAMA UMA FUNCAO (PODE SER UMA FUNCAO
* DE LOGOFF , DESCANSO DE TELA , ETC..)
*****************************************
* AUTOR DA FUNۂO ORIGINAL :
* POMPEO (GUARATINGUETA)
* MIGRAۂO DA FUNۂO PARA CLASSE:
* WILLIAM DE BRITO ADAMI
*****************************************
#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







 


cuando hay actividad es posible insertar una imagen o imágenes que caminan en la pantalla como si fuera un anuncio?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6849
Joined: Thu Oct 18, 2012 7:17 pm

Re: Quit the program when time out (like screen saver)

Postby karinha » Sun Apr 12, 2020 1:45 am

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7352
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Quit the program when time out (like screen saver)

Postby driessen » Mon Apr 13, 2020 1:51 pm

Why making it so difficult.

It's quite easy.

Just start a timer. This timer checks for example every 30 seconds if a certain time has passed.
If so, just quit the program.

Not that difficult.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1399
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 42 guests