469,950 Members | 2,480 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Auto logoff

Hello Group,
To my apps user must logon.
How make auto logoff after any time when user is not active?

Please send me samples or link to samples.
Thx.
Pawel
Nov 15 '05 #1
5 9173
Pawel,

Figuring out inactivity in an application is difficult, at best. What
you will want to do is probably hook into the applications main message loop
(by implementing the IMessageFilter interface and registering it on the
Application through the static AddMessageFilter method). In there, you
would look for any mouse movement messages, and any keystroke messages. You
would also have a timer which would be reset every time one of these
messages came in. If the timer ever fires (the timer would br set to fire
after your timeout period, for example, set the timer to fire every three
minutes if you want your application to quit after three minutes of
inactivity), then you know the app was inactive, and you can log out.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"PawelR" <pa************@poczta.onet.pl> wrote in message
news:MP************************@news.tpi.pl...
Hello Group,
To my apps user must logon.
How make auto logoff after any time when user is not active?

Please send me samples or link to samples.
Thx.
Pawel

Nov 15 '05 #2
Nicholas Paldino [.NET/C# MVP] wrote:
Pawel,

Figuring out inactivity in an application is difficult, at best. What
you will want to do is probably hook into the applications main message loop
(by implementing the IMessageFilter interface and registering it on the
Application through the static AddMessageFilter method). In there, you
would look for any mouse movement messages, and any keystroke messages. You
would also have a timer which would be reset every time one of these
messages came in. If the timer ever fires (the timer would br set to fire
after your timeout period, for example, set the timer to fire every three
minutes if you want your application to quit after three minutes of
inactivity), then you know the app was inactive, and you can log out.

Hope this helps.

Or,..
You can write a screen saver.. Let windows take care of activating you
and when it does.. log off the user..
:)
--
Girish Bharadwaj

Nov 15 '05 #3
Girish,

That's a great hack! I mean, it is hackish, but its actually a great
mechanism. Here are the problems with that though:

- There is only one screen saver on the system, so you will eliminate
another one (which might be needed or desired)
- Is there a way from within the screen saver to indicate that it should
stop, or can you just exit the program?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Girish Bharadwaj" <girishb@nowhere> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
Nicholas Paldino [.NET/C# MVP] wrote:
Pawel,

Figuring out inactivity in an application is difficult, at best. What you will want to do is probably hook into the applications main message loop (by implementing the IMessageFilter interface and registering it on the
Application through the static AddMessageFilter method). In there, you
would look for any mouse movement messages, and any keystroke messages. You would also have a timer which would be reset every time one of these
messages came in. If the timer ever fires (the timer would br set to fire after your timeout period, for example, set the timer to fire every three minutes if you want your application to quit after three minutes of
inactivity), then you know the app was inactive, and you can log out.

Hope this helps.

Or,..
You can write a screen saver.. Let windows take care of activating you
and when it does.. log off the user..
:)
--
Girish Bharadwaj

Nov 15 '05 #4
Nicholas Paldino [.NET/C# MVP] wrote:
Girish,

That's a great hack! I mean, it is hackish, but its actually a great
mechanism. Here are the problems with that though:

- There is only one screen saver on the system, so you will eliminate
another one (which might be needed or desired)
- Is there a way from within the screen saver to indicate that it should
stop, or can you just exit the program?

Heheh.. I agree. Its a hack. :)
As for the two problems, if you agree that a Screen saver is the way to go..
For one, I would just write the "settings" for that saver to provide a
list of screen savers available and a time out on them as well. Of
course the idea now is that you will have two times one when the logoff
screensaver comes active and the *real* screen saver also becomes
active. And after a certain time out, the real screen saver is killed by
the logoff screen saver and logged off..
You can do that since its similar to one of those marquee screen savers..
or else,
the poster can write his own cool screen saver (a chance to play with
DirectX maybe).. :)

Seriously, I would expect a place where you need a auto logoff mechanism
to be deployed would not be too averse to having a screensaver set to
such a thing .. since this makes most sense in a kiosk kind of env and
there system admin is king.. :)
--
Girish Bharadwaj

Nov 15 '05 #5
Girish,

Even easier. When the screen saver is run, it posts a message of type
WM_SYSCOMMAND, where the wParam parameter is the value SC_SCREENSAVE. This
message can be processed if you set a hook using the SetWindowsHookEx
function which would filter the windows messages.

However, this still limits your timeout to whatever the screen saver is
set to, which is a pain.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Girish Bharadwaj" <girishb@nowhere> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Nicholas Paldino [.NET/C# MVP] wrote:
Girish,

That's a great hack! I mean, it is hackish, but its actually a great mechanism. Here are the problems with that though:

- There is only one screen saver on the system, so you will eliminate
another one (which might be needed or desired)
- Is there a way from within the screen saver to indicate that it should
stop, or can you just exit the program?

Heheh.. I agree. Its a hack. :)
As for the two problems, if you agree that a Screen saver is the way to

go.. For one, I would just write the "settings" for that saver to provide a
list of screen savers available and a time out on them as well. Of
course the idea now is that you will have two times one when the logoff
screensaver comes active and the *real* screen saver also becomes
active. And after a certain time out, the real screen saver is killed by
the logoff screen saver and logged off..
You can do that since its similar to one of those marquee screen savers..
or else,
the poster can write his own cool screen saver (a chance to play with
DirectX maybe).. :)

Seriously, I would expect a place where you need a auto logoff mechanism
to be deployed would not be too averse to having a screensaver set to
such a thing .. since this makes most sense in a kiosk kind of env and
there system admin is king.. :)
--
Girish Bharadwaj

Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Arun Goel | last post: by
4 posts views Thread by John Ortt | last post: by
4 posts views Thread by Smithers | last post: by
1 post views Thread by =?Utf-8?B?UnVkeQ==?= | last post: by
6 posts views Thread by =?Utf-8?B?Zmh1bnRlcg==?= | last post: by
3 posts views Thread by =?Utf-8?B?Zmh1bnRlcg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.