recognize user away

I want the app automaticlly do something if the user has no input
(neither keyboard nor mouse) for some time (i.e. the user has gone
away from the computer). How can I do this?

···

--
Qiangning Hong
http://www.hongqn.com
Registered Linux User #396996

Use a timer.

Philippe

···

On Wednesday 26 April 2006 01:55 pm, Qiangning Hong wrote:

I want the app automaticlly do something if the user has no input
(neither keyboard nor mouse) for some time (i.e. the user has gone
away from the computer). How can I do this?

--
Qiangning Hong
http://www.hongqn.com
Registered Linux User #396996

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

--
_________________________
Philippe C. Martin
www.snakecard.com
_________________________

you mean bind a timer-refresh handler for every controls in the app?
too many code to write...

···

On 4/27/06, Philippe C. Martin <pmartin@snakecard.com> wrote:

Use a timer.

--
Qiangning Hong
http://www.hongqn.com
Registered Linux User #396996

One timer handler should do it. I guess you could trap mouse/keyboard events
(and still let them go to the controls) and reset your timer there.

Philippe

···

On Wednesday 26 April 2006 02:02 pm, Qiangning Hong wrote:

On 4/27/06, Philippe C. Martin <pmartin@snakecard.com> wrote:
> Use a timer.

you mean bind a timer-refresh handler for every controls in the app?
too many code to write...

--
Qiangning Hong
http://www.hongqn.com
Registered Linux User #396996

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

--
_________________________
Philippe C. Martin
www.snakecard.com
_________________________

Qiangning Hong wrote:

I want the app automaticlly do something if the user has no input
(neither keyboard nor mouse) for some time (i.e. the user has gone
away from the computer). How can I do this?

If you want to do it for just your app then you might be able to do it by watching for events being delivered to the app object. It gets a chance to handle any events that are not caught by any other handler in the window or containers where the event happens.

If you want to do it for the whole system then you'll need to do some platforms specific things as wx doesn't have any support for this built-in.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

you mean bind a timer-refresh handler for every controls in the app?
too many code to write...

I don't know if this will work, but, in theory, an idle event is emitted whenever the event cue becomes empty. This can only happen if there are events, which indicate the user is interacting with the app. If you set a timer in the idle event , and re-set it each time you get an idle event, then when it goes off, it should indicate inactivity.

The first complication I see is that a timer event is an event, and so may set off an idle event.....

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

If the timer event sets a flag, and the idle event checks whether the timer
event flag is set, and if so, checks how much time elapsed since the flag was
set, and unsets the flag if not enough time elapsed ...

Horst

···

On Thursday 27 April 2006 08:40, Christopher Barker wrote:

I don't know if this will work, but, in theory, an idle event is emitted
whenever the event cue becomes empty. This can only happen if there are
events, which indicate the user is interacting with the app. If you set
a timer in the idle event , and re-set it each time you get an idle
event, then when it goes off, it should indicate inactivity.

The first complication I see is that a timer event is an event, and so
may set off an idle event.....

Horst Herb <subscriptions <at> gnumed.net> writes:

> I don't know if this will work, but, in theory, an idle event is emitted
> whenever the event cue becomes empty. This can only happen if there are
> events, which indicate the user is interacting with the app. If you set
> a timer in the idle event , and re-set it each time you get an idle
> event, then when it goes off, it should indicate inactivity.
>
> The first complication I see is that a timer event is an event, and so
> may set off an idle event.....

If the timer event sets a flag, and the idle event checks whether the timer
event flag is set, and if so, checks how much time elapsed since the flag was
set, and unsets the flag if not enough time elapsed ...

Horst

if you want to do this on windows (xp in particular) and you want to detect if
the user has made no input on any input device to any application, the way msn
messenger detects if you've been "away", then you'll need win32all and ctypes
and then you can do this:

import win32gui
from ctypes import *

GetTickCount = windll.kernel32.GetTickCount
GetLastInputInfo = windll.user32.GetLastInputInfo

class LASTINPUTINFO(Structure):
  _fields_ = [("cbSize", c_uint), ("dwTime", c_uint)]

lastInputInfo = LASTINPUTINFO()
lastInputInfo.cbSize = sizeof(lastInputInfo)

def getLastInpuTime():
   GetLastInputInfo(byref(lastInputInfo))
   return float(GetTickCount()-lastInputInfo.dwTime)/1000

if __name__ == '__main__':
   import time
   
   while True:
      print "Last input time:", getLastInputTime()
      time.sleep(1)
  
run it and wait a while before typing or moving the mouse, it returns the number
of seconds since the last input on any input device. if you only need to detect
idle time for your app, then do it as specified in the previous message.

/r

···

On Thursday 27 April 2006 08:40, Christopher Barker wrote: