Exit the program if they do not move your mouse to press any

Post Reply
User avatar
HATHAL
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh
Contact:

Exit the program if they do not move your mouse to press any

Post by HATHAL »

Code: Select all

Call my screen entry program identification number or
Exit the program if they do not move your mouse to press any keys for a period of time
*********************************
file 1
*****
/*
TIMERAC.CH 
Timer Action  VER 1
BY HATHAL http://WWW.LIVESYSTEM.NET
AT 2012-5-20
*/
 *********************************
#xcommand DEFINE TIME OUT <oTIMERAC> OF <oWnd> SECOND <nSec> ACTION <bAction> ;
       => ;
          <oTIMERAC> := TimerAc():SetAc(<nSec>,<oWnd>,[<{bAction}>])

// *********************
#xcommand DEFINE TIME OUT TO <oActIon2> OF <oWnd> SECOND <nSec> ACTION <bAction> ;
       => ;
          TimerAc():ACTION2(<nSec>,<oWnd>,[<{bAction}>],<oActIon2>) 
*********************************************************
file 2
*******
#include "FiveWin.ch"
/*
TIMERAC.PRG CLASS 
Timer Action VER 1
BY HATHAL http://WWW.LIVESYSTEM.NET
AT 2012-5-20
*/ 
//----------------------------------------------------------------------------//
CLASS TimerAc
   DATA nSec
   DATA Action_View
   DATA start_out_sec
   DATA oTimer_Ac
   DATA bAction
   DATA oWnd_Ac
   DATA start_out
   METHOD ACTION2(nSec,oWnd,bAction,oActIon2)
   METHOD SetAc(nSec,oWnd_Ac,bAction)
   METHOD KeyMov()   
   METHOD StartAc() 
   METHOD time_out()
ENDCLASS
//----------------------------------------------------------------------------//
  ***************
 METHOD ACTION2(nSec,oWnd,bAction,oActIon2)
   oActIon2:oWnd_Ac:=oWnd
  oActIon2:Action_View:=.F.
  oActIon2:start_out = second()+nSec //second
  oActIon2:bAction:=bAction
  ::oWnd_Ac:=oWnd
RETURN NIL
************************* 
METHOD SetAc(nSec,oWnd_Ac,bAction)  CLASS TimerAc
   DEFAULT nSec :=10 // second
   ::oWnd_Ac :=oWnd_Ac
   ::start_out :=nSec
   ::start_out_sec :=::start_out
   ::start_out :=second()+ ::start_out_sec
   ::Action_View :=.f.
   ::bAction := bAction
//   ::KeyMov()
return Self
***************
METHOD  KeyMov()  CLASS TimerAc
if ! Empty(::oWnd_Ac ) 
      IF ::oWnd_Ac != nil
 ::oWnd_Ac:bKeyDown = { | nKey | ::start_out :=second()+ ::start_out_sec )}
 ::oWnd_Ac:bMMoved := {|nRow, nCol| ::start_out :=second()+ ::start_out_sec ) }
      ENDIF
endif
 return Self
***************
METHOD  StartAc()  CLASS TimerAc
      ::KeyMov()
         DEFINE TIMER oTimer_Ac ACTION (::time_out())
       ACTIVATE TIMER oTimer_Ac
return  Self
// ****************************
METHOD time_out() CLASS TimerAc  
     if ::start_out<=second()
    *********
    if ::Action_View=.f.
    ******
      if ::bAction != nil
      ::Action_View =.t.
      if ::bAction != nil
        Eval(::bAction)
       endif          
::start_out = second() +::start_out_sec
      ::Action_View =.f.
      endif
    ******
    endif
    ************
     endif     
return nil
// ****************************
file 3
*******
*********************************
/*
Timer Action TEST.PRG  VER 1
BY HATHAL http://WWW.LIVESYSTEM.NET
AT 2012-5-20
*/
*********************************
#include "FiveWin.ch"
#include "TIMERAC.ch"
STATIC O_Action
*****************************
function Main()
LOCAL oWnd
     DEFINE WINDOW oWnd TITLE "Test Timer Action WITH KEYBOURD NOT  DOWN  AND MOUSE NOT  MOVE"
    DEFINE TIME OUT O_Action OF oWnd SECOND 4 ACTION lGetPassword(oWnd)
       ACTIVATE WINDOW oWnd ;
    ON INIT (O_Action:StartAc())
return nil
************************************
 function lGetPassword(oWnd)
   local oDlg, oGet, oFont
   local cPassword := Space( 10 )
   local nTries    := 0
   local lGo       := .f.
   LOCAL MY_PASSWORD:="HATHAL" // WRITE ANY PASSOWD 
 DO WHILE lGo=.f.
   DEFINE DIALOG oDlg ;
      FROM 5, 5 TO 30, 80 ;
      TITLE "Please Identify" 
       DEFINE TIME OUT TO O_Action  OF oDlg SECOND 5 ACTION msginfo("new timer Action")
   @ 1, 2 SAY "Write FiveWin to go ahead..." OF oDlg
   @ 2, 2 GET oGet VAR cPassword OF oDlg PASSWORD
   @ 3, 5 BUTTON "&Continue" OF oDlg ;
      ACTION ( nTries++,;
               lGo := Upper( AllTrim( cPassword ) ) == MY_PASSWORD,;
               If( nTries > 3 .or. lGo, oDlg:End(),;
                   ( MsgAlert( "Wrong password! " ), oGet:SetFocus() ) ) )

   ACTIVATE DIALOG oDlg CENTERED
     End Do
 DEFINE TIME OUT TO  O_Action OF oWnd SECOND 10 ACTION lGetPassword("N1")
 return lGo
 ******************************
Post Reply