Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to execute a script when a computer is locked?


  • Please log in to reply
16 replies to this topic
HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Detect when workstation gets locked :)
OnMessage(0x2b1,"WM_WTSSESSION_CHANGE")

Gui,+LastFound
hwnd:=WinExist()
DllCall("Wtsapi32.dll\WTSRegisterSessionNotification","UInt",hwnd,"UInt",0)

Gui,Add,ListView,r20 w300,ACTION|INFO
Gui,Show
Return

GuiClose:
ExitApp


WM_WTSSESSION_CHANGE(wParam,lParam){
	static _0x1:="WTS_CONSOLE_CONNECT" ;A session was connected to the console terminal.
	,_0x2:="WTS_CONSOLE_DISCONNECT" ;A session was disconnected from the console terminal.
	,_0x3:="WTS_REMOTE_CONNECT" ;A session was connected to the remote terminal.
	,_0x4:="WTS_REMOTE_DISCONNECT" ;A session was disconnected from the remote terminal.
	,_0x5:="WTS_SESSION_LOGON" ;A user has logged on to the session.
	,_0x6:="WTS_SESSION_LOGOFF" ;A user has logged off the session.
	,_0x7:="WTS_SESSION_LOCK" ;A session has been locked.
	,_0x8:="WTS_SESSION_UNLOCK" ;A session has been unlocked.
	,_0x9:="WTS_SESSION_REMOTE_CONTROL" ;A session has changed its remote controlled status. To determine the status, call GetSystemMetrics and check the SM_REMOTECONTROL metric.
	LV_Add("",wParam,_0x%wParam%)
}


Maria-
  • Members
  • 17 posts
  • Last active: Jul 22 2009 09:05 PM
  • Joined: 29 May 2009
urghhh..... still stuck :cry: