Jmsilva Posted April 29, 2015 Report Share Posted April 29, 2015 Olá pessoal, alguém sabe com criar uma rotina que após um certo tempo sem uso do sistema, ele fecha automaticamente. pensei em usar Thread():new(), mas deu seguinte erro: Error: Unresolved external '_HB_FUN_THREAD'. Alguém sabe qual a lib tem a classe. Jmsilva xharbour/Fivewin 11/10 Daryabite 1 Quote Link to comment Share on other sites More sharing options...
kapiaba Posted April 29, 2015 Report Share Posted April 29, 2015 http://forums.fivetechsupport.com/viewtopic.php?f=6&t=28635&p=160524&hilit=CERRAR+PROGRAMA#p160524 http://forums.fivetechsupport.com/viewtopic.php?f=6&t=27560&p=155963&hilit=CERRAR+PROGRAMA#p155963 Quote Link to comment Share on other sites More sharing options...
kapiaba Posted April 29, 2015 Report Share Posted April 29, 2015 * By William Adami * 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 Quote Link to comment Share on other sites More sharing options...
Valdir Posted June 22, 2016 Report Share Posted June 22, 2016 Boas... Amigos Joãos.... Funfou certinho. Obrugado. kapiaba 1 Quote Link to comment Share on other sites More sharing options...
kapiaba Posted March 25, 2019 Report Share Posted March 25, 2019 Relembrar é viver. Valdir 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.