#NoTrayIcon
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GDIPlus.au3>
#include <INet.au3>
#include <GDIPlusEx.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <Timers.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <Constants.au3>
Dim $DeskICO= iniread("Config.ini","deskico","Deskico","")
If $deskico =1 Then
Global $hWndManager = WinGetHandle("Program Manager")
Global $hWndDesktop = ControlGetHandle("Program Manager", "", 1)
Global $LVS_Style = _WinAPI_GetWindowLong($hWndDesktop, $GWL_STYLE)
Global $inifile, $iSet, $iRefresh, $SNAPTOGRID
If $SNAPTOGRID Then $SNAPTOGRID = $LVS_EX_SNAPTOGRID
If IsNumber($SNAPTOGRID) Then _SendMessage($hWndDesktop, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_SNAPTOGRID, $SNAPTOGRID)
If BitAND($LVS_Style, $LVS_AUTOARRANGE) Then _WinAPI_SetWindowLong($hWndDesktop, $GWL_STYLE, $LVS_Style - $LVS_AUTOARRANGE);取消自动排列
If $iRefresh Then DllCall("shell32.dll", "none", "SHChangeNotify", "long", 0x8000000, "int", 0, "ptr", 0, "ptr", 0);刷新图标
$Readini = IniReadSection('DeskTopIco.ini', '图标位置')
For $i = 1 To $Readini[0][0]
$ss = StringSplit($Readini[$i][1], ',')
_SendMessage($hWndDesktop, $LVM_SETITEMPOSITION, $i - 1, BitOR(BitShift($ss[2], -16), BitAND($ss[1], 0xffff)))
Next
Next
EndIf
;更换墙纸
Dim Const $BMPCLSID = '{557CF400-1A04-11D3-9A73-0000F81EF32E}';指定BMP的图像编码器,测试N次为个值是固定的,所以直接用,大家也可以用_GDIPlus_EncodersGetCLSID('BMP')
Dim Const $hWndDesktop = ControlGetHandle("Program Manager", "", 1)
Dim Const $LVS_Style = _WinAPI_GetWindowLong($hWndDesktop, $GWL_STYLE)
Dim $hMatrix
_GDIPlus_Startup();启动GDI+
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;=============================================================================桌面背景
Local $arry[1]
Local $count=0
$Wallpaper= iniread("Config.ini","Wallpaper","Wallpaper","")
$search=FileFindFirstFile($Wallpaper&"*.*")
while 1
$file=FileFindNextFile($search)
if @error then ExitLoop
_ArrayAdd($arry,$file)
$count=$count+1
WEnd ;循環目錄中的所有文件
$rnd=Random(1,$count,1) ; 產生隨機數
$wpaper=$arry[$rnd] ;隨機圖片
$hImage = _GDIPlus_BitmapCreateFromFile($Wallpaper&$wpaper)
$Dimension = _GDIPlus_ImageGetDimension($hImage)
If $Dimension[0] <> @DesktopWidth Or $Dimension[1] <> @DesktopHeight Then
_PicChangeSize($Wallpaper&$wpaper, @ScriptDir & '\' & @DesktopWidth & 'x' & @DesktopHeight & '.jpg', @DesktopWidth, @DesktopHeight)
_WinAPI_DeleteObject($hImage)
$hImage = _GDIPlus_BitmapCreateFromFile(@ScriptDir & '\' & @DesktopWidth & 'x' & @DesktopHeight & '.jpg')
EndIf
SetWallpaper();设置桌面壁纸
Func SetWallpaper()
$hMatrix = _GDIPlus_MatrixCreate();创建并初始化矩阵对象
$tParams = _GDIPlus_ParamInit(1);初始化编码器的参数列表,
$tData = DllStructCreate("int Quality");创建一个数据结构,用来设置JPG的质量
DllStructSetData($tData, "Quality", 100);设置JPG的质量为100
_GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, DllStructGetPtr($tData));将上面创建的值添加到编码器参数列表中
$pParams = DllStructGetPtr($tParams);返回数据结构指针
_GDIPlus_ImageSaveToFileEx($hImage, @ScriptDir & "\Wallpaper.bmp", $BMPCLSID, 0);把位图对象保存为BMP文件
RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", 2);0为居中 1为拉伸 2为平铺
RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TitleWallpaper", "REG_SZ", "1")
RegWrite('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper', 'REG_SZ', @ScriptDir & "\Wallpaper.bmp")
$Bmp_Path = RegRead('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper')
DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 1, "str", $Bmp_Path, "int", 1)
EndFunc ;==>SetWallpaper
Func _PicChangeSize($sFile, $sFile_new, $new_W, $new_H)
Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage)
Local $hBmp = _GDIPlus_BitmapCreateFromGraphics($new_W, $new_H, $hGraphics)
Local $hImage_New = _GDIPlus_ImageGetGraphicsContext($hBmp)
_GDIPlus_GraphicsDrawImageRect($hImage_New, $hImage, 0, 0, $new_W, $new_H)
_GDIPlus_ImageSaveToFile($hBmp, $sFile_new)
_GDIPlus_GraphicsDispose($hImage_New)
_GDIPlus_BitmapDispose($hBmp)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_ImageDispose($hImage)
EndFunc ;==>_PicChangeSize
;====================================
;返回图像的高度和宽度
;====================================
Func GetPicH($Pic)
Return _GDIPlus_ImageGetHeight($Pic);返回图像对象的高度
EndFunc ;==>GetPicH
Func GetPicW($Pic)
Return _GDIPlus_ImageGetWidth($Pic);返回图像对象的宽度
EndFunc ;==>GetPicW
;====================================
;退出程序并释放相关资源
;====================================
Func Quit()
_GDIPlus_MatrixDispose($hMatrix);释放资源
_WinAPI_DeleteObject($hImage);释放资源
_GDIPlus_Shutdown();关闭GDI+
Exit
EndFunc ;==>Quit
换桌面墙纸跟自动排列桌面图标的, 为什么会报这个错,哪位大神帮忙看下! |