User Tools

Site Tools


blog:change_windows_desktop_background_for_day_and_night_using_batchfile

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
blog:change_windows_desktop_background_for_day_and_night_using_batchfile [2010-12-23 07:59] – created brbblog:change_windows_desktop_background_for_day_and_night_using_batchfile [2010-12-23 08:41] brb
Line 1: Line 1:
 ====== Change windows desktop background for day and night, using batchfile ====== ====== Change windows desktop background for day and night, using batchfile ======
  
-<code bat> +Having a bright, blue wallpaper for day use and a darker, reddish wallpaper for evening/night is useful stay in synch with the real time of day. So, i wanted my windows xp machine automatically switch to the day wallpaper from 7-20 and to night from 20-7 hours. The following batch script does this, without any add-on software. To use, copy-paste the file and store it to your scripts directory (e:\etc in my case).
-::==chwallpaper.bat+
  
-Echo %Time%+{{:blog:wallpaper_day.jpg?320|}} {{:blog:wallpaper_night.jpg?320|}}
  
-for /"tokens=1-3 delims=:." %%a in ( +<html><form action="https://www.paypal.com/cgi-bin/webscrmethod="post"> 
-"%time%") do set hours=%%a+<input type="hidden" name="cmd" value="_s-xclick"> 
 +<input type="hidden" name="hosted_button_id" value="NLZS6NV6Z5WT6"> 
 +<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gifborder="0" name="submit" alt="PayPal - The safer, easier way to pay online."> 
 +<img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1"> 
 +</form></html> at least 5 EUR/US$ for maintaining this blog, and i send you both pictures in full resolution!
  
-set wallpaper=e:\etc\wallpaper_tag.bmp +Advantages: 
-if %hours% LSS goto setnight +  * No additional software (apart from the script) has to be installed 
-if %hours% GTR 20 goto setnight+  * No additional load on the computer by a desktop switcher, except from the tasks that you define yourself 
 + 
 +Notes: 
 +  * You must convert your jpg wallpaper to bmp (changing the dimensions to exactly match your screen). You can't directly use a jpg file as a windows wallpaper (the settings dialog creates a bmp file behind your back!). 
 +  * Configuration is by changing the set ... variable at the top of the file 
 +  * Test by calling the batchfile 
 +  * To automate the wallpaper switch: 
 +    * make a link in the windows autostart folder 
 +    * add an hourly task to the task manager (or even cleaner, two tasks at the switch times (7:00 and 20:00) 
 + 
 +<code winbatch> 
 +REM :: chwpdn. batchange to CHange the WallPaper for Day and Night 
 +REM :: v1.0 B.Brunner, 23.12.2010 (brb_trash at epr dot ch) 
 +REM Prepare two bmp files to be used during day and night  
 +REM - jpgs dont work directly, convert to bmp of your screen resolution first! 
 +REM - change start and end day hour to your needs 
 +REM - store this batchfile in a place like e:\etc 
 +REM - make a link to this batchfile in your autostart folder (set minimized in the link) 
 +REM - using the task manager have the batchfile start every hour, to switch during the day 
 +REM  
 +REM Configuration changes go here 
 +set wpnight=e:\etc\wallpaper_night.bmp 
 +set wpday=e:\etc\wallpaper_day.bmp 
 +set daystarthour=7 
 +set dayendhour=20 
 + 
 +REM Set hours variable  
 +for /f "tokens=1-3 delims=:." %%a in ( "%time%") do set hours=%%a 
 + 
 +REM Use day wallpaper, except from 00:00-08:00 and 20:00-23:59 
 +set wallpaper=%wpday% 
 +if %hours% LSS %daystarthour% goto setnight 
 +if %hours% GTR %dayendhour% goto setnight
 goto setit goto setit
  
 :setnight :setnight
-set wallpaper=e:\etc\wallpaper_nacht.bmp +set wallpaper=%wpnight%
  
 :setit :setit
- 
 Echo Setting wallpaper to %wallpaper% Echo Setting wallpaper to %wallpaper%
  
 REG ADD "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d %wallpaper% /f  REG ADD "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d %wallpaper% /f 
 RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
- 
-:finish 
 </code> </code>
  
blog/change_windows_desktop_background_for_day_and_night_using_batchfile.txt · Last modified: 2010-12-26 07:26 by brb