未加星标

Lightweight Powershell Windows Desktop Background Rotator script

字体大小 | |
[系统(windows) 所属分类 系统(windows) | 发布者 店小二04 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

windows Desktop Background Rotator is a Powershell script for Windows that loads a wallpaper from a pool whenever it is run.

Windows itself ships with options to rotate backgrounds regularly, but the options are somewhat limited in this regard. While you can configure the operating system to rotate a pool of images as desktop backgrounds, there is no option to further customize the selection.

Say you would like to use different wallpapers for different times of the year. Can be done, but you need to adjust the pool of wallpaper images manually each time, or switch to different themes for that.

There are plenty of programs out there to change wallpapers. To name a few:Bgcall, Jellybean , WallPapa , Color Desker ,Wallperizer, andWally.

Windows Desktop Background Rotator
Lightweight Powershell Windows Desktop Background Rotator script

One of the main ideas of Windows Desktop Background Rotator is to use different pools of background images based on time periods.

You can configure the script to load a pool of background images for Christmas, Summer, Halloween, or any other time period or day you like.

The script has an advantage over dedicated programs for the job, as it runs only for as long as it needs to change the wallpaper on the desktop. Once done, it does not use any system resources anymore which is better obviously than a resident program that needs to run all the time even though it may change the background only once a day or even less frequently than that.

Downside is that you need to configure the script using an editor. It is not too difficult, but if you never came into contact with scripts before, it may be overwhelming.

Let me walk you through the steps of doing that:

First thing you do is download the script from the project's GitHub page. Note that it downloads with the .txt extension automatically which you need to remove either when the download prompt appears, or later on the system.

The Powershell script uses the folder Desktop Backgrounds within Pictures by default. You can keep it at that, and move your wallpapers there, or edit the path in the script. The function Get-Default-Pool sets the path there.


Lightweight Powershell Windows Desktop Background Rotator script

My suggestion is to keep the default path, as it makes things easier. It is easy enough to copy your wallpaper images to the folder, or folders under the structure.

The next step depends on whether you want to use different pools of wallpaper images that the program loads depending on the date. If you don't skip the following step.

Step 1: Set up the folders for the different wallpaper pools
Lightweight Powershell Windows Desktop Background Rotator script

Add folders to the main Desktop Backgrounds folder, e.g. Christmas, Birthday, Halloween and so on, and place your wallpaper images there.

A typical folder structure could look like this:

Desktop Backgrounds Christmas wallpaper1.jpg secondwallpaper.jgg Halloween halloween1.jpg scary.png Step 2: Add the function to the script
Lightweight Powershell Windows Desktop Background Rotator script

You need to add the following function to the script.

Function Get-StarWars-Pool {

Get-ChildItem "$([Environment]::GetFolderPath(`"MyPictures`"))\Desktop Backgrounds\Starwars"

}

Make sure you replace "Starwars" with the folder name that you are using on your system. Place the new function below the Get-Default-Pool function so that it looks like this

Function Get-Default-Pool {

Get-ChildItem "$([Environment]::GetFolderPath(`"MyPictures`"))\Desktop Backgrounds" -Recurse | Where-Object {! $_.PSIsContainer -And $_.FullName -NotMatch "Starwars"}

}

Function Get-StarWars-Pool {

Get-ChildItem "$([Environment]::GetFolderPath(`"MyPictures`"))\Desktop Backgrounds\Starwars"

}

Add | Where-Object {! $_.PSIsContainer -And $_.FullName -NotMatch "Starwars" to the default function to block it from selecting backgrounds from the date-based folders. Change Starwars to the pool name that you have set.

Step 3: Add a start and end date
Lightweight Powershell Windows Desktop Background Rotator script

Locate the $Dates array, and add start and end date information to it.

$Dates = @(

@{

"StartDate" = "2-01"

"EndDate" = "2-28"

"Pool" = "Starwars"

})

This would pull background images from the Starwars folder from February 1 to February 28. Repeat this step for any other wallpaper pool that you have added to the script.

Two date pools would look like this:

$Dates = @(

@{

"StartDate" = "2-01"

"EndDate" = "2-28"

"Pool" = "Starwars"

}

@{

"StartDate" = "12-01"

"EndDate" = "12-26"

"Pool" = "Christmas"

})

Step 4: Set Tile, Center, Stretch or NoChange (Optional)
Lightweight Powershell Windows Desktop Background Rotator script

The script uses stretch automatically when it comes to loading wallpapers. If you think that is fine, skip this step. If you want another value instead, do the following:

Locate [Wallpaper.Setter]::SetWallpaper($ImageToUse.FullName, 2) near the end of the script, and change the 2 to another value. 0 means tile. 1 means center. 2 means stretch. 3 means no change. Step 5: run the script
Lightweight Powershell Windows Desktop Background Rotator script

I suggest you run the script to check if it works correctly. This can be done by right-clicking the edited Powershell script and selecting run with PowerShell from the context menu.

If you don't get an error, e.g. nothing happens, you may use it manually, or, set up a scheduled task instead to automate the process.

Step 6: creating a scheduled task

To create a new scheduled task, do the following:

Tap on the Windows-key, type Task Scheduler, and select the entry from the list of results. Select Action > Create Task. Add a name, and optional description to the task on the first tab of the Create Task window. Switch to the Triggers tab, and click on the New button. Click on"on a schedule" at the top, and select on startup, or any of the other options there. This determines when the script is run by Windows. You can enable delay and repeat under advanced. Delay would change the background after the selected time period, repeat would run it regularly. Click ok. Switch to the Actions tab and click on the New button there. Add the Windows Desktop Background Rotator script under Program/script, and click ok. Click on ok to complete the setup.

Windows will run the script from now on based on the parameters that you have defined.

Closing Words

Setup of the script is not overly complicated, but it is not as easy as using a user interface to set up wallpaper pools. The main advantage the script offers is that it runs only when it changes wallpaper images on your desktop, and that you can define time-based periods in which custom wallpaper pools are used.

Now Read: The best wallpaper downloaders for Windows

本文系统(windows)相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术

主题: WindowsGitGitHubPowerShellWord
分页:12
转载请注明
本文标题:Lightweight Powershell Windows Desktop Background Rotator script
本站链接:http://www.codesec.net/view/533195.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(windows) | 评论(0) | 阅读(37)