[python-win32] SOLVED: I want to get a message when the screen is locked/unlocked. How?
Ron Arts
ron.arts at neonova.nl
Tue Aug 25 22:53:23 CEST 2009
Tim Roberts schreef:
> Ron Arts wrote:
>> I want to logout the user from a remote session when the desktop is
>> locked, and log her in again when it is unlocked.
>>
>> There seem to be various ways of catching these events:
>>
>> - WTS API
>> - ISensLogon Interface (SENS)
>> - Using Service Control Manager (SCM) Notifications (only for services?)
>> - Winlogon Notification Packages (deprecated and removed from Vista)
>>
>> I currently am trying the following (using WTS API):
>>
>> if "wxMSW" in wx.PlatformInfo:
>> import win32ts
>> win32ts.WTSRegisterSessionNotification(self.GetHandle(),
>> win32ts.NOTIFY_FOR_THIS_SESSION)
>>
>> This does not throw errors at me, but now I am baffled as how I can
>> catch the WTS events.
>
> Your window will now receive WM_WTSSESSION_CHANGE messages. There's a
> sample at http://wiki.wxpython.org/MonitoringWindowsUsb that provides a
> wxPython mixin class that allows you to capture arbitrary window
> messages. When using this, you'd just say:
> self.addMsgHandler( WM_WTSSESSION_CHANGE, self.onSessionChange )
> self.hookWndProc()
>
> def onSessionChange( self, wParam, lParam ):
> ...
>
> WM_WTSSESSION_CHANGE is 0x02b1.
>
>
>> Also, is this the appropriate method as the docs state that it
>> requires Windows Terminal
>> Services loaded (which I don't have running).
>
> Starting with XP, all systems run with Windows Terminal Services
> enabled. That's how fast user switching is implemented, among other things.
>
Tim,
that's great, it works like a charm.
Thanks a lot!
Ron
--
NeoNova BV
innovatieve internetoplossingen
http://www.neonova.nl Science Park 140 1098 XG Amsterdam
info: 020-5611300 servicedesk: 020-5611302 fax: 020-5611301
KvK Amsterdam 34151241
Op dit bericht is de volgende disclaimer van toepassing:
http://www.neonova.nl/maildisclaimer
More information about the python-win32
mailing list