Page 1 of 1

Auto-Close Application On Timer (Resolved)

Posted: Fri May 01, 2020 11:28 am
by RiazKhan
I need to activate a timer to close files and applications when the time is over.

I would like to set a timer to 60 minutes or more, automatically close the application if the user does not interact with the application, upon detection of no keyboard input and no mouse movement.

I have auto-backup routines and various data updates to execute, but the procedure fails due to no access to data files.

As seen over many years and years, the clients never log off or exit application before leaving offices.
I want to close applications and free data files for further processing.
I have seen this forum for a possible solution but did not find any help.

Thank you in advance for any guidance

Re: Auto-Close Application On Timer

Posted: Fri May 01, 2020 12:07 pm
by Horizon

Re: Auto-Close Application On Timer

Posted: Fri May 01, 2020 2:45 pm
by RiazKhan
Yes, Thanks Hakan Onemli

This is fine and works very well..
I have converted tinativo to LIB and attached it to my application.

Will upload on to servers and check results....

Regards

Re: Auto-Close Application On Timer (Resolved)

Posted: Sat May 02, 2020 8:19 am
by Marc Venken
Hello,

I'm interested also in this app.

Can you confirm it's working and maybe share the code/lib that has a working code ?

How did you implement it into your app?

Re: Auto-Close Application On Timer (Resolved)

Posted: Sat May 02, 2020 10:10 am
by RiazKhan
Hello Mark,

Yes, I tested this extensively yesterday, in many scenarios.
It detects non-keyboard and non-mouse movement for the period defined.
It works as desired, I just activated the timer on the main window of the application.
It is activated as soon as the application is executed.

The timer is activated and valid as..

If the application is at the main windows. (Works)
If the application is in any dialog or at a GET. (Works)
If the application is minimized. (Works)
If the user has the application open of any dialog and waiting at a GET and working on a xls worksheet. (Works)

My code is below as the MAIN.PRG

Code: Select all

#include "FiveWin.Ch"

//   Declare Static Variables

   STATIC nWait_Time,cThe_Func,lTime_Cont 

*---------------------------------------------------------------------------*
 FUNCTION Main( CompPara, YearPara )
*---------------------------------------------------------------------------*

// Assign parameters to variables

   nWait_Time  := 5400000                    // = 90 Minutes  // Time to wait until calling function
   cThe_Func   := "iRtrn:=Exit(.T.)"         // Name of the function to be called when Timer time is reached
   lTime_Cont  := .F.                        // After executing the function, continue to monitor Keep as .F.

// Define main window and activate..  
   DEFINE WINDOW oMainWnd TITLE  S_Name MENU BuildMenu() ICON oIco MDI

      }
      }    your routines....
      }

   ACTIVATE WINDOW oMainWnd MAXIMIZED ON INIT (  BuildTimer( oMainWnd ) )
                  

Return( Nil )                  
                  
*---------------------------------------------------------------------------*
 FUNCTION BuildTimer( oDlg )
*---------------------------------------------------------------------------*

TinaTivo():New(nWait_Time,cThe_Func,lTime_Cont)    // Add tinativo.lib To MAK File
 
Return( Nil )
 

Mark, I do not how to upload the lib or the prg files here on the forum.
If you can share your email address, it can be sent to you.

Regards

Re: Auto-Close Application On Timer (Resolved)

Posted: Sat May 02, 2020 10:26 am
by cnavarro
Send me at zip file with sources, mak, and lib and I upload your work to "Fivewin Contributions" repository

Re: Auto-Close Application On Timer (Resolved)

Posted: Sat May 02, 2020 10:36 am
by RiazKhan
Thanks, Navarro
Regards

Re: Auto-Close Application On Timer (Resolved)

Posted: Sat May 02, 2020 10:39 am
by Marc Venken
cnavarro wrote:Send me mail zip file with sources, mak, and lib and I upload your work to "Fivewin Contributions" repository
I will wait for the upload to contributions, so please send to him.

Thanks

Re: Auto-Close Application On Timer (Resolved)

Posted: Sat May 02, 2020 10:45 am
by RiazKhan
Already sent via email to cristobal
Regards

Re: Auto-Close Application On Timer (Resolved)

Posted: Sat May 02, 2020 2:16 pm
by cnavarro