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
Quit the program when time out (like screen saver)
Quit the program when time out (like screen saver)
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)
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)
-
- Posts: 65
- Joined: Tue Apr 14, 2009 9:26 pm
- Location: Brasil
Re: Quit the program when time out (like screen saver)
hello, see my class tinativo()
William Adami
William Adami
Code: Select all
* 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
Re: Quit the program when time out (like screen saver)
Dear William,
Thanks for nice class and example. It's really useful for me.
Regards,
Dutch
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)
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)
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: Quit the program when time out (like screen saver)
cuando hay actividad es posible insertar una imagen o imágenes que caminan en la pantalla como si fuera un anuncio?WilliamAdami wrote:hello, see my class tinativo()
William Adami
Code: Select all
* 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
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Re: Quit the program when time out (like screen saver)
João Santos - São Paulo - Brasil
Re: Quit the program when time out (like screen saver)
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.
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. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7