Eu tinha um código feito em minigui aqui que detecta a inatividade do teclado e mouse e também ao termino de um determinado tempo ele executa uma função simulando uma proteção de tela.
Veja se ele server pra vocês:
#include "minigui.ch"
static oWnd, oTimerTime, oLabel, oLabel2
*************
function main
*************
define window oWnd title "Teste de teclado e mouse" MAIN
@50, 20 Label oLabel Value "" AUTOSIZE TRANSPARENT
@90, 20 Label oLabel2 Value "Se o teclado ou mouse for usado o contador será reiniciado..." AUTOSIZE TRANSPARENT
DEFINE TIMER Timer1 INTERVAL 1000 ACTION{ || VER_TEMPO() }
end window
activate window oWnd
return NIL
*************************
static function VER_TEMPO
*************************
oWnd.oLabel.value := "Vou executar a proteção de tela em " + hb_ntos(int(11 - sysidlesecs())) + " segundos"
if sysidlesecs() > 10
oWnd.Timer1.enabled := .F.
msgstop( "executando a proteção de tela" )
oWnd.Timer1.enabled := .t.
endif
return NIL
**----------------------------------------------------------------------
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
/*
typedef struct tagLASTINPUTINFO {
UINT cbSize;
DWORD dwTime;
} LASTINPUTINFO, *PLASTINPUTINFO;
*/
WINUSERAPI BOOL WINAPI GetLastInputInfo(PLASTINPUTINFO);
typedef BOOL (WINAPI *GETLASTINPUTINFO_)(PLASTINPUTINFO);
HB_FUNC( SYSIDLESECS )
{
HINSTANCE handle= LoadLibrary("user32.dll");
if ( handle)
{
GETLASTINPUTINFO_ pFunc;
pFunc = GetProcAddress( handle,"GetLastInputInfo" );
if (pFunc)
{
LASTINPUTINFO lpi;
lpi.cbSize = sizeof(LASTINPUTINFO);
if (!pFunc(&lpi))
{
hb_retni(0);
}
else
{
hb_retnd( ( DOUBLE ) ( GetTickCount() - lpi.dwTime ) * 0.001 );
}
}
else
{
hb_retni(0);
}
}
if (handle)
{
FreeLibrary( handle);
}
}
#pragma ENDDUMP
**----------------------------------------------------------------------
Vejam que na rotina em C++ tem um código comentado. Se precisarem tirem este comentário.
Bom, espero ter ajudado.
Abraços,
Rossine.