Auto logoff

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • PawelR

    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
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Auto logoff

    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 AddMessageFilte r 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]
    - mvp@spam.guard. caspershouse.co m

    "PawelR" <pawelratajczak @poczta.onet.pl > wrote in message
    news:MPG.19f741 ef569dd4e898968 b@news.tpi.pl.. .[color=blue]
    > 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[/color]


    Comment

    • Girish Bharadwaj

      #3
      Re: Auto logoff

      Nicholas Paldino [.NET/C# MVP] wrote:
      [color=blue]
      > 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 AddMessageFilte r 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.
      >
      >[/color]
      Or,..
      You can write a screen saver.. Let windows take care of activating you
      and when it does.. log off the user..
      :)


      --
      Girish Bharadwaj

      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: Auto logoff

        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]
        - mvp@spam.guard. caspershouse.co m

        "Girish Bharadwaj" <girishb@nowher e> wrote in message
        news:eYywxXykDH A.2528@TK2MSFTN GP10.phx.gbl...[color=blue]
        > Nicholas Paldino [.NET/C# MVP] wrote:
        >[color=green]
        > > Pawel,
        > >
        > > Figuring out inactivity in an application is difficult, at best.[/color][/color]
        What[color=blue][color=green]
        > > you will want to do is probably hook into the applications main message[/color][/color]
        loop[color=blue][color=green]
        > > (by implementing the IMessageFilter interface and registering it on the
        > > Application through the static AddMessageFilte r method). In there, you
        > > would look for any mouse movement messages, and any keystroke messages.[/color][/color]
        You[color=blue][color=green]
        > > 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[/color][/color]
        fire[color=blue][color=green]
        > > after your timeout period, for example, set the timer to fire every[/color][/color]
        three[color=blue][color=green]
        > > 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.
        > >
        > >[/color]
        > Or,..
        > You can write a screen saver.. Let windows take care of activating you
        > and when it does.. log off the user..
        > :)
        >
        >
        > --
        > Girish Bharadwaj
        >[/color]


        Comment

        • Girish Bharadwaj

          #5
          Re: Auto logoff

          Nicholas Paldino [.NET/C# MVP] wrote:[color=blue]
          > 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?
          >
          >[/color]
          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

          Comment

          • Nicholas Paldino [.NET/C# MVP]

            #6
            Re: Auto logoff

            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 SetWindowsHookE x
            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]
            - mvp@spam.guard. caspershouse.co m

            "Girish Bharadwaj" <girishb@nowher e> wrote in message
            news:%233R%2392 ykDHA.2432@TK2M SFTNGP10.phx.gb l...[color=blue]
            > Nicholas Paldino [.NET/C# MVP] wrote:[color=green]
            > > Girish,
            > >
            > > That's a great hack! I mean, it is hackish, but its actually a[/color][/color]
            great[color=blue][color=green]
            > > 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?
            > >
            > >[/color]
            > Heheh.. I agree. Its a hack. :)
            > As for the two problems, if you agree that a Screen saver is the way to[/color]
            go..[color=blue]
            > 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
            >[/color]


            Comment

            Working...