LeMarchand Posted June 17, 2021 Posted June 17, 2021 For ages I've been using MonitorES to start my screensaver on lock and 3RVX to use shortcuts for volume up/down etc. Recently played with AutoHotkey, which replaced 3RVX and pauses media on lock, which MonitorES should be able to do but doesn't. Been trying to duplicate MonitorES's "start screensaver on lock" capability in both AHK and be using scheduled tasks, but just can't find a way to both pause media and invoke the screensaver on lock. Anyone got any bright ideas?
andy_b Posted June 17, 2021 Posted June 17, 2021 A copy and paste / merge of a couple of scripts I found - but seems to do what you want? ; GLOBAL SETTINGS =============================================================================================================== #Warn #NoEnv #SingleInstance Force OnExit, EOF ; SCRIPT ======================================================================================================================== SessionChange(true) return ; FUNCTIONS ===================================================================================================================== SessionChange(notify := true) { static WTS_CURRENT_SERVER := 0 static NOTIFY_FOR_ALL_SESSIONS := 1 if (notify) { if !(DllCall("wtsapi32.dll\WTSRegisterSessionNotificationEx", "ptr", WTS_CURRENT_SERVER, "ptr", A_ScriptHwnd, "uint", NOTIFY_FOR_ALL_SESSIONS)) throw Exception("WTSRegisterSessionNotificationEx", -1) OnMessage(0x02B1, "WM_WTSSESSION_CHANGE") } else { OnMessage(0x02B1, "") if !(DllCall("wtsapi32.dll\WTSUnRegisterSessionNotificationEx", "ptr", WTS_CURRENT_SERVER, "ptr", A_ScriptHwnd)) throw Exception("WTSUnRegisterSessionNotificationEx", -1) } return true } WM_WTSSESSION_CHANGE(wParam, lParam, Msg, hWnd){ static init:=(DllCall( "Wtsapi32.dll\WTSRegisterSessionNotification", UInt, A_ScriptHwnd, UInt, 1) && OnMessage(0x02B1, "WM_WTSSESSION_CHANGE")) If (wParam=0x6 || wParam=0x7){ ;Logoff or lock Run, powercfg -change -monitor-timeout-ac 1,,Hide ;Set monitor standby timeout to 1 minute SendMessage,0x112,0xF170,2,,Program Manager ;Monitor Standby } Else If (wParam=0x5 || wParam=0x8){ ;Logon or unlock Run, powercfg -change -monitor-timeout-ac 20,,Hide ;Set monitor standby timeout to 20 minutes } } ; EXIT ========================================================================================================================== EOF: SessionChange(false) ExitApp 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now