1. Home
  2. Windows Tips
  3. Automatically play pause media on system lock unlock on windows 10

Automatically Play/Pause Media on Lock/Unlock on Windows 10

The Netflix app will automatically pause if you minimize it, or if you lock your desktop. No other media app or player does this. We recently covered a little VLC player feature that will automatically pause playback if you minimize it but as far as playing and pausing anything when you lock/unlock your system goes, there’s no app that will do it out of the box. The good news is, you can use a script to play or pause a particular media player, and a scheduled task can be used to run the script when the system is locked and unlocked.

Play/pause media script

Out of the box, there is no command-line command that you can use to play/pause media. To work around this, you need to download a free command-line utility called CommandLineMedia. It’s available on Github. Go ahead and download and extract it. Move the extracted folder someplace you know you won’t delete it by accident.

Open a new Notepad file and paste the following in it. Replace the placeholder text with the actual path to the app and the name of the app you want to play/pause. Save it with the BAT file extension.

Script

cd "path to CommandLineMedia.exe"
clmcontrol App Name -pp

Example

cd C:\Users\fatiw\Desktop\CLMControl.1.1.0.0
clmcontrol VLC -pp

It’s a good idea to test this first because the app may not understand the name of the media app. The script we’ve given as an example will play or pause VLC player when it is run.

Scheduled task on system lock/unlock

Open the Task Scheduler and create a new task. Give the task a name that tells you what it’s for. It’s a good idea to mention the name of the app it will play/pause in the title. Go to the Triggers tab and open the ‘Begin the task’ dropdown. Select ‘On workstation lock’ and click OK. Go to the Actions tab and select the script you created by clicking the ‘Browse’ button next to the Program/Script. Click OK. When you lock your system, it will automatically pause the media app that the script targets.

To play the media player automatically when you unlock the system, you need to create a second task or you can add a second trigger to this same task. The trigger should be set to ‘On workstation unlock’. You don’t need to add a new action. The script can pause and play an app so just the one will do.