Author | Topic: Automatically log off the application after certain time of inactivity | |
---|---|---|
Jacob John | Automatically log off the application after certain time of inactivity on Tue, 13 Oct 2020 17:32:18 +0530 Hi, Is it possible to Automatically log off the application after certain time of user inactivity ? Its a multi threaded application. But there may be background events running. I want to log out the application if there is no keyboard or mouce events for last 30 minutes. Is there any option for this in Thread ? Regards Kiron | |
Itai Ben-Artzi | Re: Automatically log off the application after certain time of inactivity on Tue, 13 Oct 2020 11:07:24 -0700 In the main PRG: #DEFINE TIMEOUT_DEFAULT 2700 45 Min @ 60 Seconds LOCAL nTimeOut := TIMEOUT_DEFAULT nPreviousSeconds := seconds() seconds after midnight * Do while MyTerminate nEventNo := AppEvent(@mp1,@mp2,@oXbp, nTimeOut) IF oXbp != NIL oXbp:handleEvent(nEventNo,mp1,mp2) ENDIF check for idle program nSeconds = seconds() delta time counter IF nEventNo == 0 move the time condition for non-idle user. nSeconds -= nPreviousSeconds nSeconds += 1 IF nSeconds > 0 .and. nSeconds >= nTimeOut .and. nTimeOut > 0 this works only if user is idle. no user activity for specified period of time: exit program MyTerminate := .F. ENDIF ELSE reset time counter nPreviousSeconds := nSeconds ENDIF Enddo **************** -Itai | |
Jacob John | Re: Automatically log off the application after certain time of inactivity on Sat, 17 Oct 2020 15:23:08 +0530 Ben, Ok. Let me try. Thank you Kiron On Tue, 13 Oct 2020 11:07:24 -0700, Itai Ben-Artzi wrote: >In the main PRG: > >#DEFINE TIMEOUT_DEFAULT 2700 45 Min @ 60 Seconds >* >* >LOCAL nTimeOut := TIMEOUT_DEFAULT >* >* >nPreviousSeconds := seconds() seconds after midnight >* > Do while MyTerminate > nEventNo := AppEvent(@mp1,@mp2,@oXbp, nTimeOut) > IF oXbp != NIL > oXbp:handleEvent(nEventNo,mp1,mp2) > ENDIF > > check for idle program > nSeconds = seconds() delta time counter > IF nEventNo == 0 move the time condition for non-idle user. > nSeconds -= nPreviousSeconds > nSeconds += 1 > IF nSeconds > 0 .and. nSeconds >= nTimeOut .and. nTimeOut > 0 >this works only if user is idle. > no user activity for specified period of time: exit program > MyTerminate := .F. > ENDIF > ELSE > reset time counter > nPreviousSeconds := nSeconds > ENDIF > Enddo >**************** >-Itai | |
Jacob John | Re: Automatically log off the application after certain time of inactivity on Tue, 20 Oct 2020 19:46:29 +0530 Hi, In our application, each window run in a seperate event loop. So if none of the window are open, this is working. But any other window is open this is not working. Is there any solution for this ? Regards Kiron On Sat, 17 Oct 2020 15:23:08 +0530, Jacob John wrote: >Ben, > >Ok. Let me try. > >Thank you >Kiron > >On Tue, 13 Oct 2020 11:07:24 -0700, Itai Ben-Artzi wrote: > >>In the main PRG: >> >>#DEFINE TIMEOUT_DEFAULT 2700 45 Min @ 60 Seconds >>* >>* >>LOCAL nTimeOut := TIMEOUT_DEFAULT >>* >>* >>nPreviousSeconds := seconds() seconds after midnight >>* >> Do while MyTerminate >> nEventNo := AppEvent(@mp1,@mp2,@oXbp, nTimeOut) >> IF oXbp != NIL >> oXbp:handleEvent(nEventNo,mp1,mp2) >> ENDIF >> >> check for idle program >> nSeconds = seconds() delta time counter >> IF nEventNo == 0 move the time condition for non-idle user. >> nSeconds -= nPreviousSeconds >> nSeconds += 1 >> IF nSeconds > 0 .and. nSeconds >= nTimeOut .and. nTimeOut > 0 >>this works only if user is idle. >> no user activity for specified period of time: exit program >> MyTerminate := .F. >> ENDIF >> ELSE >> reset time counter >> nPreviousSeconds := nSeconds >> ENDIF >> Enddo >>**************** >>-Itai | |
Osvaldo Ramirez | Re: Automatically log off the application after certain time of inactivity on Tue, 20 Oct 2020 11:37:36 -0600 On 20/10/20 8:16, Jacob John wrote: > > Hi, > > In our application, each window run in a seperate event loop. So if > none of the window are open, this is working. But any other window is > open this is not working. Is there any solution for this ? > > Regards > Kiron > > On Sat, 17 Oct 2020 15:23:08 +0530, Jacob John wrote: > >> Ben, >> >> Ok. Let me try. >> >> Thank you >> Kiron >> >> On Tue, 13 Oct 2020 11:07:24 -0700, Itai Ben-Artzi wrote: >> >>> In the main PRG: >>> >>> #DEFINE TIMEOUT_DEFAULT 2700 45 Min @ 60 Seconds >>> * >>> * >>> LOCAL nTimeOut := TIMEOUT_DEFAULT >>> * >>> * >>> nPreviousSeconds := seconds() seconds after midnight >>> * >>> Do while MyTerminate >>> nEventNo := AppEvent(@mp1,@mp2,@oXbp, nTimeOut) >>> IF oXbp != NIL >>> oXbp:handleEvent(nEventNo,mp1,mp2) >>> ENDIF >>> >>> check for idle program >>> nSeconds = seconds() delta time counter >>> IF nEventNo == 0 move the time condition for non-idle user. >>> nSeconds -= nPreviousSeconds >>> nSeconds += 1 >>> IF nSeconds > 0 .and. nSeconds >= nTimeOut .and. nTimeOut > 0 >>> this works only if user is idle. >>> no user activity for specified period of time: exit program >>> MyTerminate := .F. >>> ENDIF >>> ELSE >>> reset time counter >>> nPreviousSeconds := nSeconds >>> ENDIF >>> Enddo >>> **************** >>> -Itai You can Run a general main loop function, for each thread that you run, and then you can have a total control ? HTH Osvaldo | |
Jim Lee | Re: Automatically log off the application after certain time of inactivity on Tue, 20 Oct 2020 20:19:11 +0200 hi, you can QUIT in every Window nEvent:= AppEvent(@mp1,@mp2,@oXbp, nTimeOut) DO CASE CASE nEvent = xbe_None DO_Quit() OTHERWISE oXbp:handleEvent( nEvent, mp1, mp2 ) ENDCASE | |
Carlos Santos | Re: Automatically log off the application after certain time of inactivity on Wed, 21 Oct 2020 20:32:59 +0200 Hi Jacob, I use in main function: .. XbpApplication():systemPowerStatus := { |nChange| HandlePower(nChange) } .. FUNCTION HandlePower( nChange ) IF nChange == 4 .OR. nChange == 5 M->menugeral := .T. PostAppEvent( xbeK_ESC ) PostAppEvent( xbeP_Keyboard,xbeK_ESC,,M->appwindow ) CriaEventos( {K_ESC,K_ESC} ) PostAppEvent( xbeK_F12 ) Bip() ENDIF * IF nChange == 6 .OR. nChange == 7 .OR. nChange == 18 * ? "Resuming" * ENDIF RETURN XPP_POWERQUERY_GRANT Jacob John wrote in message news:oj5boflhp9rfvblhemdtleveilpsg149fv@4ax.com... >Hi, > >Is it possible to Automatically log off the application after certain >time of user inactivity ? Its a multi threaded application. > >But there may be background events running. I want to log out the >application if there is no keyboard or mouce events for last 30 >minutes. > >Is there any option for this in Thread ? > >Regards >Kiron |