Welcome, guest | Sign In | My Account | Store | Cart

Simple script that will allow you to locate and run the set screensaver from python, if available.

Python, 11 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import os, win32com.client

def runScreensaver():
    strComputer = "."
    objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
    objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
    colItems = objSWbemServices.ExecQuery("Select * from Win32_Desktop")
    for objItem in colItems:
        if objItem.ScreenSaverExecutable:
            os.system(objItem.ScreenSaverExecutable + " /start")
            break

1 comment

Mathieu 11 years, 3 months ago  # | flag

This doesn't work for me, although that might be due to the fact that I'm a total newb and have no idea what's happening in this code. Could you possibly explain what's happening?

I tried my own simplified version of code to run a screensaver ...

import subprocess
subprocess.call(['C:\WINDOWS\System32\ssText3d.scr'])

however it only manages to popup the screensaver's property window (the same happened using a batch file). It's unfortunately not as easy as running the scr file due to Vista (or other Windows OS) limitations against non-Windows programs trying to run screensavers.