I use the following to change the standby timeout of my monitor on logoff/logon. You can easily change those
Run lines to the script that re-enables your mouse:
Code: Select all
WM_WTSSESSION_CHANGE(wParam, lParam, Msg, hWnd){
static init:=(DllCall( "Wtsapi32.dll\WTSRegisterSessionNotification", UInt, A_ScriptHwnd, UInt, 1) && OnMessage(0x02B1, "WM_WTSSESSION_CHANGE"))
,_:={base:{__Delete: "WM_WTSSESSION_CHANGE"}}
if !(_)
DllCall("Wtsapi32.dll\WTSUnRegisterSessionNotification", "UInt", hWnd)
If (wParam=0x6 || wParam=0x7){ ;Logoff or lock
Run, powercfg -change -monitor-timeout-ac 1,,Hide ;Set monitor standby timeout to 1 minute
}Else If (wParam=0x5 || wParam=0x8){ ;Logon or unlock
Run, powercfg -change -monitor-timeout-ac 20,,Hide ;Set monitor standby timeout to 20 minutes
}
/*
wParam::::::
WTS_CONSOLE_CONNECT := 0x1 ; A session was connected to the console terminal.
WTS_CONSOLE_DISCONNECT := 0x2 ; A session was disconnected from the console terminal.
WTS_REMOTE_CONNECT := 0x3 ; A session was connected to the remote terminal.
WTS_REMOTE_DISCONNECT := 0x4 ; A session was disconnected from the remote terminal.
WTS_SESSION_LOGON := 0x5 ; A user has logged on to the session.
WTS_SESSION_LOGOFF := 0x6 ; A user has logged off the session.
WTS_SESSION_LOCK := 0x7 ; A session has been locked.
WTS_SESSION_UNLOCK := 0x8 ; A session has been unlocked.
WTS_SESSION_REMOTE_CONTROL := 0x9 ; A session has changed its remote controlled status. To determine the status, call GetSystemMetrics and check the SM_REMOTECONTROL metric.
*/
}