diff --git a/System-Automation-Scripts/Wallpaper Setter/README.md b/System-Automation-Scripts/Wallpaper Setter/README.md new file mode 100644 index 00000000..84d03f59 --- /dev/null +++ b/System-Automation-Scripts/Wallpaper Setter/README.md @@ -0,0 +1,20 @@ +### Wallpaper setter + + +#### This script can be used to change the wallpaper on a **Windows PC**.It takes a jpg file as input and sets it as the desktop wallpaper + +#### How to use this script? + +Go to the commant prompt and type the following : + +python Wallpaper.py -l "Your_jpg_file" + +Example : + +python Wallpaper.py -l awesome.jpg + +#### Output you get: + +Your desktop wallpaper gets changed + +#### PS: Provide absolute path if the wallpaper is in other directory than the current one. Would prefer running this script from wallpaper folder. \ No newline at end of file diff --git a/System-Automation-Scripts/Wallpaper Setter/Sample_wallpaper_setter.PNG b/System-Automation-Scripts/Wallpaper Setter/Sample_wallpaper_setter.PNG new file mode 100644 index 00000000..c4c5856d Binary files /dev/null and b/System-Automation-Scripts/Wallpaper Setter/Sample_wallpaper_setter.PNG differ diff --git a/System-Automation-Scripts/Wallpaper Setter/wallpaper_setter.py b/System-Automation-Scripts/Wallpaper Setter/wallpaper_setter.py new file mode 100644 index 00000000..13512ed1 --- /dev/null +++ b/System-Automation-Scripts/Wallpaper Setter/wallpaper_setter.py @@ -0,0 +1,36 @@ +import ctypes +import os +import argparse +import sys + +# Code to add the cli +parser = argparse.ArgumentParser() +parser.add_argument("-l", "--jpgfile", required=True, help="JPG File") +args = vars(parser.parse_args()) + + +#Storing the absolute path of the jpg file provided by the user +filename = args['jpgfile'] + +# To make sure a jpg file has been provided +if filename.endswith(".jpg"): + + + + # Code to get the absolute path of the jpg file + def getabsolutepath(filename): + path = os.path.abspath(filename) + return path + + #The code for setting wallpaper in SystemParametersInfoW function is 20 + SPI_SETDESKWALLPAPER = 20 + + #Main code to change the wallpaper + output_from_wallpaper_change = ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, getabsolutepath(filename), 0) + + if output_from_wallpaper_change == 1: + print("Your wallpaper has been changed successfully!!!") + else: + print("Sorry cant set this file as your wallpaper") +else: + sys.exit("Enter a jpg file only please")