标题: [其他] 发个设置壁纸的小工具SetWallPaper [打印本页]
作者: pusofalse 时间: 2009-4-1 00:55 标题: 发个设置壁纸的小工具SetWallPaper
前两天用AutoIt写的,转成命令行工具了~- :: 设置壁纸
- SetWallPaper.exe "c:\Test.bmp"
- :: SetWallPaper.exe "c:\Test.jpg"
-
- :: 获取壁纸所在路径。
- SetWallPaper.exe /where
复制代码
- #AutoIt3Wrapper_Change2CUI=y
- #include <GDIPlus.au3>
- Global Const $Spi_SetDeskWallPaper = 0x14
- Global Const $Spi_GetDeskWallPaper = 0x73
- Global Const $Spif_SendChange = 2
- Global Const $sHelp = @ScriptName & ' [bitmap path|/where]' & @CrLf
- If $CmdLine[0] = 0 Then
- ConsoleWrite($sHelp)
- Exit(0)
- ElseIf $CmdLine[0] <> 1 Then
- ConsoleWrite($sHelp)
- Exit(-1)
- EndIf
- Switch $CmdLine[1]
- Case "/where"
- ConsoleWrite(_GetDesktopWallPaper() & @CrLf)
- Exit(0)
- Case Else
- If not FileExists($CmdLine[1]) Then Exit(1)
- If _SetDesktopWallPaper($CmdLine[1]) Then Exit(0)
- Exit(1)
- EndSwitch
- Func _SetDesktopWallPaper($szPaperPath, $iSendChange = 2)
- Local $iResult, $tPaperPath
- If not _IsBMP($szPaperPath) Then
- _JpgToBmp($szPaperPath, @TempDir & "\WallPaper.bmp")
- $szPaperPath = @TempDir & "\WallPaper.bmp"
- EndIf
- $tPaperPath = DllStructCreate("char[260]")
- DllStructSetData($tPaperPath, 1, $szPaperPath)
- $iResult = DllCall("user32.dll", "int", "SystemParametersInfo", _
- "uint", $Spi_SetDeskWallPaper, _
- "uint", 0, _
- "ptr", DllStructGetPtr($tPaperPath), _
- "uint", $iSendChange)
- $tPaperPath = 0
- Return $iResult[0] <> 0
- EndFunc ;==>_SetDesktopWallPaper()
- Func _GetDesktopWallPaper()
- Local $buffer = DllStructCreate("char[260]"), $szResult
- DllCall("user32.dll", "int", "SystemParametersInfo", _
- "uint", $Spi_GetDeskWallPaper, _
- "uint", DllStructGetSize($buffer), _
- "ptr", DllStructGetPtr($buffer), _
- "uint", 0)
- $szResult = DllStructGetData($buffer, 1)
- $buffer = 0
- Return $szResult
- EndFunc ;==>_GetDesktopWallPaper()
- Func _IsBMP($szFile)
- If StringRegExp($szFile, "(?i)\.bmp$") Then Return True
- EndFunc ;==>_IsBMP()
- Func _JpgToBmp($Jpg,$Bmp)
- Local $hImage, $CLSID
- _GDIPlus_Startup()
- $hImage = _GDIPlus_ImageLoadFromFile($Jpg)
- $CLSID = _GDIPlus_EncodersGetCLSID("BMP")
- _GDIPlus_ImageSaveToFileEx($hImage,$Bmp, $CLSID)
- _GDIPlus_ShutDown()
- EndFunc ;==>_JpgToBmp()
复制代码
点此下载 目录:batch tools,认证密码:bathome
[ 本帖最后由 pusofalse 于 2009-6-19 00:41 编辑 ]
作者: HoeKey 时间: 2009-4-1 03:21
只能指定一张壁纸路径吗 不能指定整个文件夹随机换
作者: Batcher 时间: 2009-4-1 11:25 标题: 回复 2楼 的帖子
自己随便写个批处理来配合一下这个工具即可
作者: tireless 时间: 2009-4-4 09:17 标题: 回复 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\"
作者: HoeKey 时间: 2009-4-5 11:14
非常好啊 谢谢楼主
作者: zzx786 时间: 2009-4-6 11:13
好东西,收了。谢楼主!
作者: Beauty00002 时间: 2009-7-7 18:27
看看,看看,看看,看看,看看,
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |