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: 68
- 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 | Expand
* 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: 7110
- Joined: Thu Oct 18, 2012 7:17 pm
Re: Quit the program when time out (like screen saver)
WilliamAdami wrote:hello, see my class tinativo()
William AdamiCode: Select all | Expand
* 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
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
- karinha
- Posts: 7910
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Quit the program when time out (like screen saver)
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773