How to program a batch program to determine if a the screensaver is running or if the user went to sleep, or locked the computer?
In bash in Ubuntu Linux I am using the code: /gnome-screensaver-command -q | grep "is active" to determine if screensaver is running.
Note: I am not seeking recommendations for books, tools, software libraries...
Unless there is a better approach, I am working off of this script to look for processes running. But I have to find the name of the screensaver process.
@echo off
set pn=%1
echo looking for %pn%
tasklist /FI "IMAGENAME eq %pn%" 2>NUL | find /I /N "%pn%">NUL
if %ERRORLEVEL%==0 (
echo Found program running
) else (
echo NOT FOUND running
)
The name of the screensaver process will vary by which screensaver is running, but it should always end in
.scr.The default Windows 10 screensavers have the following process names:
When the computer is locked, the process
LogonUI.exeruns.