[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[其他] 换桌面背景(墙纸)命令行工具 WallpaperChanger

此工具用 C# 编写, 运行需要安装 .NET 2.0 以上. 换桌面命令行语法简单, 并且支持 bmp, jpg, gif 等多种格式图片, 而且可以支持 url 图片地址.
语法:
WallpaperChanger.exe [file] [style]
file: 图片地址, 支持 URL
style: 0, 平铺; 1, 居中; 2, 拉伸.
下载 来源于 http://www.sg20.com/wallpaperchanger/
核心原代码在此处可下载
http://www.codeproject.com/dotnet/SettingWallpaperDotNet.asp

附一段将桌面墙纸和 http://cn.bing.com/ 同步的 batch:
  1. @echo off & setlocal enableDelayedExpansion
  2. for /f "delims=:" %%n in ('findstr /n /b /e :text "%~0"') do set jump=%%n
  3. >download.vbs (
  4.   for /f "skip=%jump% usebackq delims=" %%l in ("%~0") do echo %%l
  5. )
  6. <nul set /p=Downloading file: http://cn.bing.com/default.htm ...
  7. wscript download.vbs "http://cn.bing.com/default.htm" cn.bing.htm
  8. echo.&echo Downloading complete.
  9. for /f "skip=2 delims=" %%s in ('find "g_img={url:" cn.bing.htm') do (
  10.   set "sec=%%s"
  11.   for /f "tokens=2 delims='" %%a in ("!sec:*g_img=g_img!") do (
  12.     <nul set /p=Setting new wallpaper: http://cn.bing.com/%%a ...
  13.     WallpaperChanger.exe http://cn.bing.com/%%a 2
  14.   )
  15. )
  16. exit /b
  17. :text
  18. iLocal = LCase(WScript.Arguments(1))
  19. iRemote = LCase(WScript.Arguments(0))
  20. Set xPost = CreateObject("Microsoft.XMLHTTP")
  21. xPost.Open "GET",iRemote,0
  22. xPost.Send()
  23. Set sGet = CreateObject("ADO"&"DB.Stream")
  24. sGet.Mode = 3
  25. sGet.Type = 1
  26. sGet.Open()
  27. strE = xPost.responseBody
  28. sGet.Write strE
  29. sGet.SaveToFile iLocal,2
复制代码
Wallpaper Changer Command Line Utility

Description

WallpaperChanger is a command line utility for changing the wallpaper (desktop background) in Windows. The intent of this program is not to be a standalone wallpaper program (it is too cumbersome to use for that). It is intended to be used as a "helper" utility program for another program or script.

For example, I wrote this program for use with a Java program I was writing to change the desktop wallpaper. I ran into a problem trying to get Java to change the desktop wallpaper. The best way to do it is to use one of the Windows system libraries (dlls). I decided to implement a command line utility program in C# to set a new wallpaper. My Java program executes this external utility program when it sets the wallpaper.

Use
The program takes two arguments: the file (including path) to use as wallpaper, and the style (Tiled, Centered, Stretched)
Syntax is: [file] [style]

        [file] is the complete path to the file
        [style] is an integer (if no style is specified it defaults to Stretched):
        0 for Tiled
        1 for Centered
        2 for Stretched

If the style argument is not specified it will default to Stretched.

The file type can be any of the standard picture types (bmp, jpg, gif, etc.). The program will automatically convert the file to a bmp file (required by windows) and place it within the users temp directory.

The program has a return code - 0 for normal, 1 for error

An error code will be returned if the program had an exception, for example invalid syntax, invalid file name, invalid style type, etc.

Requirements
Because WallpaperChanger is written in C#, it requires the .NET Framework (specifically version 2.0 or later) to be installed.  Version 2 of the framework adds a new method that greatly speeds up some image processing (the wallpaper changer was ridiculously slow before).  If you do not have the .NET Framework installed, you can get it from Windows Update or from the Microsoft website.

The .NET Framework download page can be found here:
http://msdn.microsoft.com/netframework/downloads/updates/default.aspx

Download

Download the WallpaperChanger here

This program is free for use and distribution. It is delivered "as-is". I have tested the program and have been using it without problem in my own wallpaper changing program.

If you have questions or comments, feel free to email: [email=ph-web@sg20.com]ph-web@sg20.com[/email]

The code in the program was based off of the code in a CodeProject article found at:
http://www.codeproject.com/dotnet/SettingWallpaperDotNet.asp

Last Modified: 2007-09-04
1

评分人数

返回列表