Automatic logoff

Discussion forum about all things Gupta, OpenText and the community.
jdurban
Germany
Posts: 29
Joined: 09 Oct 2018, 09:30
Location: Karlsruhe, Germany

Automatic logoff

Post by jdurban » 02 Dec 2019, 14:59

hello,
does anybody has an idea how to implement an automatic logoff?
When the app is not used for a specific time then the app should be automatically closed and the user logged off. The login screen should appear again - How it is at many other apps.
I can set a timer and stop it when a object receives a message - but then I have to catch all messages to Interrupt the timer.
Maybe I could check the message queue with a timer, when a message occur then reset timer, if no message occur for a specific time then close app.. but how can I do this?
regards
Jürgen

User avatar
Charlie
Canada
Posts: 637
Joined: 07 Mar 2017, 18:52
Location: Fredericton, New Brunswick, Canada

Re: Automatic logoff

Post by Charlie » 02 Dec 2019, 15:48

G'day,

I dug this out of some old source code. Not sure if that still works, but give it a spin and see (and let us know?) how it goes :

Code: Select all

Library name: USER32.DLL
	ThreadSafe: No
	Function: GetMessagePos
		Description:
		Export Ordinal: 0
		Returns
			Number: DWORD
		Parameters

...

On SAM_Timer
	If nCursorPos = GetMessagePos( )
		Set nIdleTime = nIdleTime + 1
	Else
		Set nIdleTime = 0
		Set nCursorPos = GetMessagePos( )
	If nIdleTime >= 60
		Call SalQuit ( )


jdurban
Germany
Posts: 29
Joined: 09 Oct 2018, 09:30
Location: Karlsruhe, Germany

Re: Automatic logoff

Post by jdurban » 02 Dec 2019, 20:15

Hi Charlie,
hm, the code snippet is not complete an the functioen GetMessagePos retrieves not the position of a message in the queue, it retrieves coordinates of the last mouse location..
Maybe it's part of asolution but not enough for me..
Maybe it's the same idea I have: On WM_MOUSEMOVE I kill and set the timer again. But when the mouse is not moved the timer is not killed and after the timer message was send the app shows the Login Dialog (if user only uses keyboard: bad!). Works well but not when a dialog is open. This case you have to handle, as I have read somewhere, with WM_ENTERIDLE but this doesn't work. Next question would be: what about message boxes?
I'm looking in MS - documentation a function like "GetAppState" maybe I'll find something - then I tell you!
regards
Jürgen

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 2912
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Automatic logoff

Post by Dave Rabelink » 02 Dec 2019, 20:34

Here a sample on session idle detection:

https://wiki.tdcommunity.net/index.php/ ... _idle_time
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

jdurban
Germany
Posts: 29
Joined: 09 Oct 2018, 09:30
Location: Karlsruhe, Germany

Re: Automatic logoff

Post by jdurban » 02 Dec 2019, 21:03

Hi Dave,
many thanks, I'll try the sample. Meanwhile I found GetLastInputInfo, too, but I my c-experience is to small to define the parameter, I would fail...
regards Jürgen

ninelabs
Australia
Posts: 9
Joined: 29 Mar 2017, 01:52
Location: Perth, Australia

Re: Automatic logoff

Post by ninelabs » 03 Dec 2019, 06:07

Hi Jürgen,
We have a class (picture class) that we use for both maintenance (forced shutdown) and idle detection. We simply add it to the main form and that's it - it handles everything else. I have attached it, however it won't compile due to missing library files etc, however it is quite simple and you should be able to follow it and implement your own :) Hopefully this helps!
Cheers,
Tristan
Idle Detection.zip
You do not have the required permissions to view the files attached to this post.

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 2912
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Automatic logoff

Post by Dave Rabelink » 03 Dec 2019, 06:44

Hi ninelabs,

Is this the same functionality as given here?

viewtopic.php?f=58&t=39455


I wonder if the sourcecode of reginput.dll is available.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

ninelabs
Australia
Posts: 9
Joined: 29 Mar 2017, 01:52
Location: Perth, Australia

Re: Automatic logoff

Post by ninelabs » 04 Dec 2019, 01:34

Hi Dave,

That is where I got RegInput.dll from - thanks for linking that - I couldn't find the original thread anymore! I then implemented the class so that it was easy for us to add to each of our apps, and also added a little extra functionality so that we can force shutdown etc. Timed message box was so that user input was not required to get to the SalQuit() call. Don't know if/where the source would be sorry.

Cheers,

Tristan

User avatar
H3PO4
Germany
Posts: 264
Joined: 10 Mar 2017, 07:53
Location: Rohlstorf, Germany

Re: Automatic logoff

Post by H3PO4 » 04 Dec 2019, 07:56

Hi,

attached is my 'inactivity detector'.

Maybe this could help.

Henning
AutoLogoffTest.zip
You do not have the required permissions to view the files attached to this post.

jdurban
Germany
Posts: 29
Joined: 09 Oct 2018, 09:30
Location: Karlsruhe, Germany

Re: Automatic logoff

Post by jdurban » 11 Dec 2019, 18:13

thanks to all,
meanwhile the problem is solved in this way that customer really want's something different...
Maybe I will try later the given solution, it's an very interresting Point!
regards Jürgen

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests