Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 01 AUG 2023 05:52:23PM Greg Helland wrote:

I thought I remembered someone posting a program that used IDLEPROC to check if the workstation has had not activity for X amount of minutes. If it was then logoff the user.

I have tried a few things but am missing something. The client wants to check if the time is after closing time (4:30pm) and if the workstation has been idle for 15 minutes then do a system DESTROY.

Anyone have anything like that? I am running in circles, I hate to say…..

Thanks,

Greg


At 01 AUG 2023 06:48PM Donald Bakke wrote:

I thought I remembered someone posting a program that used IDLEPROC to check if the workstation has had not activity for X amount of minutes. If it was then logoff the user.

I have tried a few things but am missing something. The client wants to check if the time is after closing time (4:30pm) and if the workstation has been idle for 15 minutes then do a system DESTROY.

Anyone have anything like that? I am running in circles, I hate to say…..

Thanks,

Greg

I think the TIMER event on the main application form would work well for this. We've implemented similar features with our apps. Nothing standardized as each client has had different requirements.

Don Bakke

SRP Computer Solutions, Inc.


At 01 AUG 2023 06:53PM Greg Helland wrote:

Thanks Don. TIMER won't tell me when was the last time the user had activity as far as I can tell. Am i missing something?


At 02 AUG 2023 09:27AM Andrew McAuley wrote:

There are multiple ways to address this. We use a promoted event with a timer. but you could probably implement with just a timer and a call to getLastInputInfo.

The Sprezzatura Group

The Sprezzatura Blog

World leaders in all things RevSoft


At 02 AUG 2023 09:32AM Donald Bakke wrote:

There are multiple ways to address this. We use a promoted event with a timer. but you could probably implement with just a timer and a call to getLastInputInfo.

The Sprezzatura Group

The Sprezzatura Blog

World leaders in all things RevSoft

Greg - Sorry to leave you hanging and not providing more (and useful) input. I had to leave my desk after posting my last response and am just now getting back to this. Fortunately Andrew already directed you to the GetLastInputInfo API, which is one of the solutions I would have offered. Another is to use other promoted events to track activity that matters (like CHAR, WINMSG/WM_SETCURSOR) and then set a global flag that your TIMER event would compare with. I prefer the Windows API solution because it makes the OS do the work rather than OI.

Don Bakke

SRP Computer Solutions, Inc.


At 02 AUG 2023 11:34AM Greg Helland wrote:

Thanks Andrew and Don. Appreciate you pointing me in the right direction.

Greg


At 03 AUG 2023 06:18AM Carl Pates wrote:

Hi Greg,

I believe the components you want are already in v10 (if you haven't got them let me know):

[list]

MSWIN_GETLASTINPUTINFO DLLPROTOTYPE

MSWIN_LASTINPUTINFO DLLSTRUCT

[/list]

There's also an insert I created that will be in v10.2.1:

compile insert msWin_LastInputInfo_Equates

/*

   ** Copyright (C) 2012-2023 Revelation Software Inc. All Rights Reserved **

   

   Author   Mr C

   Date     August 2023

   Purpose  Equates for use with Windows LASTINPUTINFO structure

   

   Comments

   ========

   

   Amended  Date       Reason

   =======  ====       ======

*/

///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////

#ifndef _MSWIN_LASTINPUTINFO_EQUATES_

#define _MSWIN_LASTINPUTINFO_EQUATES_

///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////



   declare function msWin_GetLastInputInfo

   $uses @APPID*DLLSTRUCT**MSWIN_LASTINPUTINFO



///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////



   // LASTINPUTINFO Structure equates - this structure is defined in the 

   // Windows API as:

   //

   // typedef struct tagLASTINPUTINFO {

   //    UINT  cbSize;

   //    DWORD dwTime;

   // } LASTINPUTINFO, *PLASTINPUTINFO;

      

   equ LASTINPUTINFO$   to "MSWIN_LASTINPUTINFO" 

     

   equ LII_POS_CBSIZE$   to 1

   equ LII_POS_DWTIME$   to 2

   

///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////

#endif

///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////

So here's a quick example I put together that you can use on a window TIMER event that shows you how they can be used:

   declare function msWin_GetTickCount

   $insert msWin_LastInputInfo_Equates

   $insert rti_Struct_Equates

   $insert logical



   // Stop the timer ...

   @ctrlEntID->timer = 0



   idleTimeOut = 60000 ; // ms - i.e. one minute - set this to what you want.



   lii = ""

   lii<LII_POS_CBSIZE$> = struct_Len( LASTINPUTINFO$ )



   lii = var_To_Struct( lii, LASTINPUTINFO$ )



   call msWin_GetLastInputInfo( lii )



   lii = struct_To_Var( lii, LASTINPUTINFO$ )



   now           = msWin_GetTickCount()

   lastInputTime = lii<LII_POS_DWTIME$>



   if ( now < lastInputTime ) then

      // We've probably clocked over the tick count - it's a DWORD (UINT)

      // so add UINT_MAX to it (we're 64-bits so we can handle this now

      // as a simple calc)

      idleTimeTimeElapsed = ( ( now + 0xFFFFFFFF ) - lastInputTime )

   end else

      idleTimeTimeElapsed = ( now - lastInputTime )

   end

   

   if ( idleTimeTimeElapsed >= idleTimeOut ) then

      // We're timed out ...

      call msg( @window, "IDLE" )

   end else

      // We need to reset the timer to fire at the next 

      // time we _might_ have input based on liTime

      timeRemaining = ( idleTimeOut - idleTimeTimeElapsed )

      @@window->timer = timeRemaining

   end



return 0

To kick it off just set the window TIMER property to 1

Regards

Carl Pates


At 03 AUG 2023 09:24AM Greg Helland wrote:

Thanks Carl. I will give it a go and let you know how it turns out.

Greg


At 03 AUG 2023 12:48PM Greg Helland wrote:

Hi Carl,

I don't have MSWIN_GETLASTINPUTINFO so if you can send that to me I would appreciate it. Send to ghelland@bleupelikan.com.

Thanks,

Greg


At 03 AUG 2023 05:10PM Carl Pates wrote:

  • third_party_content/community/commentary/forums_works/cc6bacb0b9868c45976e3f51e7557fa6.txt
  • Last modified: 2024/12/10 16:16
  • by 127.0.0.1