找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 31143|回复: 7

[其他] 发个设置壁纸的小工具SetWallPaper

[复制链接]
发表于 2009-4-1 00:55:38 | 显示全部楼层 |阅读模式
前两天用AutoIt写的,转成命令行工具了~
  1. :: 设置壁纸
  2. SetWallPaper.exe "c:\Test.bmp"
  3. :: SetWallPaper.exe "c:\Test.jpg"

  4. :: 获取壁纸所在路径。
  5. SetWallPaper.exe /where
复制代码
  1. #AutoIt3Wrapper_Change2CUI=y
  2. #include <GDIPlus.au3>
  3. Global Const $Spi_SetDeskWallPaper = 0x14
  4. Global Const $Spi_GetDeskWallPaper = 0x73
  5. Global Const $Spif_SendChange = 2
  6. Global Const $sHelp = @ScriptName & ' [bitmap path|/where]' & @CrLf
  7. If $CmdLine[0] = 0 Then
  8. ConsoleWrite($sHelp)
  9. Exit(0)
  10. ElseIf $CmdLine[0] <> 1 Then
  11. ConsoleWrite($sHelp)
  12. Exit(-1)
  13. EndIf
  14. Switch $CmdLine[1]
  15. Case "/where"
  16. ConsoleWrite(_GetDesktopWallPaper() & @CrLf)
  17. Exit(0)
  18. Case Else
  19. If not FileExists($CmdLine[1]) Then Exit(1)
  20. If _SetDesktopWallPaper($CmdLine[1]) Then Exit(0)
  21. Exit(1)
  22. EndSwitch
  23. Func _SetDesktopWallPaper($szPaperPath, $iSendChange = 2)
  24. Local $iResult, $tPaperPath
  25. If not _IsBMP($szPaperPath) Then
  26.   _JpgToBmp($szPaperPath, @TempDir & "\WallPaper.bmp")
  27.   $szPaperPath = @TempDir & "\WallPaper.bmp"
  28. EndIf
  29. $tPaperPath = DllStructCreate("char[260]")
  30. DllStructSetData($tPaperPath, 1, $szPaperPath)
  31. $iResult = DllCall("user32.dll", "int", "SystemParametersInfo", _
  32.   "uint", $Spi_SetDeskWallPaper, _
  33.   "uint", 0, _
  34.   "ptr", DllStructGetPtr($tPaperPath), _
  35.   "uint", $iSendChange)
  36. $tPaperPath = 0
  37. Return $iResult[0] <> 0
  38. EndFunc ;==>_SetDesktopWallPaper()
  39. Func _GetDesktopWallPaper()
  40. Local $buffer = DllStructCreate("char[260]"), $szResult
  41. DllCall("user32.dll", "int", "SystemParametersInfo", _
  42.   "uint", $Spi_GetDeskWallPaper, _
  43.   "uint", DllStructGetSize($buffer), _
  44.   "ptr", DllStructGetPtr($buffer), _
  45.   "uint", 0)
  46. $szResult = DllStructGetData($buffer, 1)
  47. $buffer = 0
  48. Return $szResult
  49. EndFunc ;==>_GetDesktopWallPaper()
  50. Func _IsBMP($szFile)
  51. If StringRegExp($szFile, "(?i)\.bmp$") Then Return True
  52. EndFunc ;==>_IsBMP()
  53. Func _JpgToBmp($Jpg,$Bmp)
  54. Local $hImage, $CLSID
  55. _GDIPlus_Startup()
  56. $hImage = _GDIPlus_ImageLoadFromFile($Jpg)
  57. $CLSID = _GDIPlus_EncodersGetCLSID("BMP")
  58. _GDIPlus_ImageSaveToFileEx($hImage,$Bmp, $CLSID)
  59. _GDIPlus_ShutDown()
  60. EndFunc ;==>_JpgToBmp()
复制代码


点此下载 目录:batch tools,认证密码:bathome

[ 本帖最后由 pusofalse 于 2009-6-19 00:41 编辑 ]
发表于 2009-4-1 03:21:25 | 显示全部楼层
只能指定一张壁纸路径吗  不能指定整个文件夹随机换
发表于 2009-4-1 11:25:37 | 显示全部楼层

回复 2楼 的帖子

自己随便写个批处理来配合一下这个工具即可
发表于 2009-4-4 09:17:16 | 显示全部楼层

回复 2楼 的帖子

可以用:
链接: https://pan.baidu.com/s/1eOWBsB0NXNr7PwUbqjiRjA 提取码: 6hf6

Random wallpaper, Next wallpaper, Previous wallpaper

Parameter is a folder or a BMP, JPG or GIF file. If it is a folder, all subfolders are searched to choose one picture which is set as desktop wallpaper. If you have JPG or GIF wallpapers, you must enable Active desktop. (Right-click on the desktop and check 'Show web content').
The command "Random wallpaper" chooses a file randomly. Commands "Next wallpaper" or "Previous wallpaper" select next/previous file in a folder according to how the files are stored on your hard disk.

例:

HotkeyP -Random wallpaper "C:\WINDOWS\Web\WALLPAPER\"
HotkeyP -Random wallpaper "C:\WINDOWS\Web\WALLPAPER\Windows XP.jpg"
HotkeyP -Next wallpaper "C:\WINDOWS\Web\WALLPAPER\"
发表于 2009-4-5 11:14:38 | 显示全部楼层
非常好啊 谢谢楼主
发表于 2009-4-6 11:13:28 | 显示全部楼层
好东西,收了。谢楼主!
发表于 2009-7-7 18:27:34 | 显示全部楼层
看看,看看,看看,看看,看看,

评分

参与人数 1PB -1 收起 理由
keen -1 严禁纯水!

查看全部评分

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 05:06 , Processed in 0.021237 second(s), 9 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表