Откопал на оф.форуме.
Как бы его модернизировать, чтобы в inputbox посылался пароль?
#include %A_ScriptDir%\lock.ahk
notify_lock_unlock()
on_lock()
{
msgbox, locked
}
on_unlock()
{
msgbox, unlocked
}
lock.ahk
;Initialize global constants
WTS_SESSION_LOCK := 0x7
WTS_SESSION_UNLOCK := 0x8
NOTIFY_FOR_ALL_SESSIONS := 1
NOTIFY_FOR_THIS_SESSION := 0
WM_WTSSESSION_CHANGE := 0x02B1
notify_lock_unlock()
{
Global WM_WTSSESSION_CHANGE
Global NOTIFY_FOR_ALL_SESSION
hw_ahk := FindWindowEx( 0, 0, "AutoHotkey", a_ScriptFullPath " - AutoHotkey v" a_AhkVersion )
OnMessage( WM_WTSSESSION_CHANGE, "Handle_WTSSESSION_CHANGE" )
success := DllCall( "wtsapi32.dll\WTSRegisterSessionNotification", "uint", hw_ahk, "uint", NOTIFY_FOR_ALL_SESSIONS )
if( ErrorLevel OR ! success )
{
success := DllCall( "wtsapi32.dll\WTSUnRegisterSessionNotification", "uint", hw_ahk )
;If DLL registration fails, wait 20 seconds and try again
Sleep, 20000
notify_lock_unlock()
;MsgBox, [WTSRegisterSessionNotification] failed: EL = %ErrorLevel%
}
return
}
Handle_WTSSESSION_CHANGE( p_w, p_l, p_m, p_hw )
; p_w = wParam ;Session state change event
; p_l = lParam ;Session ID
; p_m = Msg ;WM_WTSSESSION_CHANGE
; p_hw = hWnd ;Handle to Window
{
Global WTS_SESSION_LOCK
Global WTS_SESSION_UNLOCK
If ( p_w = WTS_SESSION_LOCK )
{
on_lock()
}
Else If ( p_w = WTS_SESSION_UNLOCK )
{
on_unlock()
}
}
FindWindowEx( p_hw_parent, p_hw_child, p_class, p_title )
{
return, DllCall( "FindWindowEx", "uint", p_hw_parent, "uint", p_hw_child, "str", p_class, "str", p_title )
}