找回密码
 加入
搜索
查看: 1512|回复: 4

[系统综合] SystemParametersInfo\IActiveDesktop(与壁纸相关的部分)

  [复制链接]
发表于 2019-1-10 23:02:32 | 显示全部楼层 |阅读模式
本帖最后由 gz13802424 于 2019-1-14 23:37 编辑

设备壁纸的方法有二个SystemParametersInfo和IActiveDesktop
方法一:SystemParametersInfo是通过DLL调用来实现
方法二:IActiveDesktop是通过COM组件来实现

---------------------------------------方法一:SystemParametersInfo---------------------------------------
在学习通过au3设置壁纸时在网上搜索到以下的示例

$Spi_SetDeskWallPaper = 0x14
$SPIF_SENDWININICHANGE = 0x0002
$tPaperPath = DllStructCreate("char[260]")
DllStructSetData($tPaperPath, 1, $szPaperPath)
$iResult = DllCall("user32.dll", "int", "SystemParametersInfo", "bool", $Spi_SetDeskWallPaper, "uint", 0, "struct*", $tPaperPath, "uint", $SPIF_SENDWININICHANGE)

但是这个示例的代码,只可以把 非中文路径非中文文件名称 的文件设置为壁纸
通过下面的修改才可以支持 中文路径中文文件名称

$Spi_SetDeskWallPaper = 0x14
$SPIF_UPDATEINIFILE = 0x0001
$SPIF_SENDWININICHANGE = 0x0002
$tPaperPath = DllStructCreate("wchar[260]")

DllStructSetData($tPaperPath, 1, $szPaperPath)
$iResult = DllCall("user32.dll", "int", "SystemParametersInfoW", "bool", $Spi_SetDeskWallPaper, "uint", 0,  "struct*", $tPaperPath, "uint", $SPIF_UPDATEINIFILE + $SPIF_SENDWININICHANGE)

---------------------------------------方法二:IActiveDesktop---------------------------------------
关于IActiveDesktop的调用,C语言调用的示例子不少,但是AU3调用的示例就基本上找不到,后来经过反复调整搜索的关键字,总算在AU3的外文论坛上找到一个大神书写的示例
下面的代码蓝色内容为我自己学习时添加上去的部分

#interface "IActiveDesktop"
Global Const $sCLSID_ActiveDesktop = "{75048700-EF1F-11D0-9888-006097DEACF9}"
Global Const $sIID_IActiveDesktop = "{F490EB00-1240-11D1-9888-006097DEACF9}"
Global Const $tagIActiveDesktop = _
                "ApplyChanges hresult(dword);" & _
                "GetWallpaper hresult(wstr;uint;dword);" & _
                "SetWallpaper hresult(wstr;dword);" & _
                "GetWallpaperOptions hresult(struct*;dword);" & _
                "SetWallpaperOptions hresult(struct*;dword);" & _
                "GetPattern hresult(wstr;uint;dword);" & _
                "SetPattern hresult(wstr;dword);" & _
                "GetDesktopItemOptions hresult(struct*;dword);" & _
                "SetDesktopItemOptions hresult(struct*;dword);" & _
                "AddDesktopItem hresult(struct*;dword);" & _
                "AddDesktopItemWithUI hresult(hwnd;struct*;dword);" & _
                "ModifyDesktopItem hresult(struct*;dword);" & _
                "RemoveDesktopItem hresult(struct*;dword);" & _
                "GetDesktopItemCount hresult(int*;dword);" & _
                "GetDesktopItem hresult(int;struct*;dword);" & _
                "GetDesktopItemByID hresult(ulong_ptr;struct*;dword);" & _
                "GenerateDesktopItemHtml hresult(wstr;struct*;dword);" & _
                "AddUrl hresult(hwnd;wstr;struct*;dword);" & _
                "GetDesktopItemBySource hresult(wstr;struct*;dword);"
;===============================================================================

Global Const $AD_APPLY_SAVE = 0x00000001
Global Const $AD_APPLY_HTMLGEN = 0x00000002
Global Const $AD_APPLY_REFRESH = 0x00000004
Global Const $AD_APPLY_ALL = 0x00000007 ;(AD_APPLY_SAVE | AD_APPLY_HTMLGEN | AD_APPLY_REFRESH)
Global Const $AD_APPLY_FORCE = 0x00000008
Global Const $AD_APPLY_BUFFERED_REFRESH = 0x00000010

Global Const $AD_GETWP_BMP = 0x00000000 ;Get a bitmap.
Global Const $AD_GETWP_IMAGE = 0x00000001 ;Get an image.
Global Const $AD_GETWP_LAST_APPLIED = 0x00000002 ;Get the type of wallpaper that was last applied

Global Const $WPSTYLE_CENTER      = 0x0     ;居中
Global Const $WPSTYLE_TILE        = 0x1     ;平铺
Global Const $WPSTYLE_STRETCH     = 0x2     ;拉伸
Global Const $WPSTYLE_KEEPASPECT  = 0x3     ;高度自适应
Global Const $WPSTYLE_CROPTOFIT   = 0x4     ;宽度自适应
Global Const $WPSTYLE_SPAN        = 0x5     ;跨屏

;;;;;;;;;;;;;;;;;;; Example ;;;;;;;;;;;;;;;;;;;;;;;;;;;
$oActiveDesktop = ObjCreateInterface($sCLSID_ActiveDesktop, $sIID_IActiveDesktop, $tagIActiveDesktop)

;读取壁纸
$DesktopWallPaper_File = ""
$oActiveDesktop.GetWallpaper($DesktopWallPaper_File, 256, $AD_GETWP_BMP)

$_tagWALLPAPEROPT = DllStructCreate("struct;DWORD dwSize;DWORD dwStyle;endstruct")
DllStructSetData($_tagWALLPAPEROPT, "dwSize", DllStructGetSize($_tagWALLPAPEROPT))
;读取壁纸样式
$oActiveDesktop.GetWallpaperOptions($_tagWALLPAPEROPT, 0)


DllStructSetData($_tagWALLPAPEROPT, "dwStyle", $WPSTYLE_SPAN)
;设置壁纸样式
$oActiveDesktop.SetWallpaperOptions($_tagWALLPAPEROPT, 0)

$sFile = FileOpenDialog("Select New Wallpaper", "", "Images (*.jpg;*.bmp;*.png;*.gif;*.whatever)") ; whatever
If $sFile Then
        $oActiveDesktop.SetWallpaper($sFile, 0)
        $oActiveDesktop.ApplyChanges($AD_APPLY_ALL)
EndIf


---------------------------------------分 割  线---------------------------------------
在win7、win10的环境下,使用1个以上的屏幕变成非常简单,而且当使用两个以上的屏幕时,每个屏幕是可以分别设置为不同的壁纸


在这里求助各路大神,如果通过api来实现为每个屏幕单独设置独立的壁纸















本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2019-1-11 20:36:38 | 显示全部楼层
官网找的, 你可以试试。
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <ScreenCapture.au3>
#include <Constants.au3>
#include <Misc.au3>
#NoTrayIcon

Opt("GUIOnEventMode", 1)

;Baisc Settings
Global $Class_Blacklist = "|BasicWindow|SideBar_AppBarWindow|SideBar_AppBarBullet|Progman|Button|ThunderRT6FormDC|ROCKETDOCK|"
Global $Num_Of_Desktop = IniRead(@ScriptDir & "\Data.ini", "Setings", "Num_Of_Desktop", "4")
Global $Gui_Size = IniRead(@ScriptDir & "\Data.ini", "Setings", "Gui_Size", "80")
Global $Slide_Trans = True
Global $Fade_Trans = False
Global $Debug = False
Global $Trans_Speed = 400

;Stuff  that user should be able to control
Global $DesktopSize = WinGetClientSize("Program Manager")
Global Const $Ratio = $DesktopSize[0] / $DesktopSize[1]
Global $Desktop_Data[$Num_Of_Desktop][1]
Global $Desktop_Pic[$Num_Of_Desktop]
Global $Curent_Desktop = 0
Global $Sticky_Window
Global $Hover_Wait_Timer
Global $Form1, $Hover_Form
IniWrite(@ScriptDir & "\Data.ini", "Wallpaper", "Desktop_Default", _Wallpaper_Get())

For $x = 0 To $Num_Of_Desktop - 1
        $Desktop_Data[$x][0] = IniRead(@ScriptDir & "\Data.ini", "Wallpaper", "Desktop_" & $x + 1, _Wallpaper_Get())
        ConsoleWrite($Desktop_Data[$x][0] & @CRLF)
Next

Global $Form_Size_X = (($Gui_Size * $Ratio) * $Num_Of_Desktop) + ($Num_Of_Desktop * 5)
Global $Form_Size_Y = $Gui_Size + 10
Global $Default_Gui_Pos = IniRead(@ScriptDir & "\Data.ini", "Setings", "Default_Gui_Pos", $DesktopSize[0] - 25 & "," & $DesktopSize[1] - $Form_Size_Y - 32)
$Default_Gui_Pos = StringSplit($Default_Gui_Pos, ",")

$Form1 = GUICreate("", $Form_Size_X + 45, $Form_Size_Y, $Default_Gui_Pos[1], $Default_Gui_Pos[2], $WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)
GUISetBkColor(0xccccff)
$Slide_Button = GUICtrlCreateButton("<", 5, 20, 15, $Form_Size_Y - 25)
$Exit_Button = GUICtrlCreateButton("X", 5, 5, 15, 15)
$Slide_Button2 = GUICtrlCreateButton(">", $Form_Size_X + 25, 20, 15, $Form_Size_Y - 25)
$Exit_Button2 = GUICtrlCreateButton("X", $Form_Size_X + 25, 5, 15, 15)
;GUICtrlCreateLabel("", 0,0, $Form_Size_X + 25, $Form_Size_X, -1, $GUI_WS_EX_PARENTDRAG)

;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor($Slide_Button, 0xaaaaff)
GUICtrlSetBkColor($Slide_Button2, 0xaaaaff)
GUICtrlSetBkColor($Exit_Button, 0xaaaaff)
GUICtrlSetBkColor($Exit_Button2, 0xaaaaff)

GUICtrlSetOnEvent($Slide_Button, "_Slide")
GUICtrlSetOnEvent($Exit_Button, "_Exit")
GUICtrlSetOnEvent($Slide_Button2, "_Slide")
GUICtrlSetOnEvent($Exit_Button2, "_Exit")

For $x = 0 To $Num_Of_Desktop - 1
        $Desktop_Pic[$x] = GUICtrlCreatePic($Desktop_Data[$x][0], (($Gui_Size * $Ratio) * $x) + (5 * ($x)) + 25, 5, $Gui_Size * $Ratio, $Gui_Size)
Next

$Hover_Form = GUICreate("", $Gui_Size * $Ratio, $Gui_Size, 30, 5, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW + $WS_EX_MDICHILD, $Form1)
GUISetBkColor(0xFFFFFF)

$Fade_Form = GUICreate("", $DesktopSize[0], $DesktopSize[1], 0, 0, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)
$Fade_Form_Pic = GUICtrlCreatePic("", 0, 0, 0, 0)

GUISetState(@SW_HIDE, $Fade_Form)
GUISetState(@SW_SHOW, $Form1)
GUISetState(@SW_SHOW, $Hover_Form)
WinSetTrans($Form1, "", 255)
WinSetTrans($Fade_Form, "", 255)
WinSetTrans($Hover_Form, "", 120)
WinSetOnTop($Form1, "", 1)

While 1
        Sleep(10)
        $Msg = _Effects()
        If $Msg Then _ChangeDesktop($Msg)
        _CheckWallpaper()
        _CheckHotKeys()
WEnd

Func _CheckWallpaper()
        If $Desktop_Data[$Curent_Desktop][0] <> _Wallpaper_Get() Then
                If @OSVersion = "WIN_VISTA" Then
                        IniWrite(@ScriptDir & "\Data.ini", "Wallpaper", "Desktop_" & $Curent_Desktop + 1, _Wallpaper_Get())
                        $Desktop_Data[$Curent_Desktop][0] = _Wallpaper_Get()
                Else
                        FileCopy(_Wallpaper_Get(), @ScriptDir & "\Desktop_" & $Curent_Desktop & ".bmp")
                        IniWrite(@ScriptDir & "\Data.ini", "Wallpaper", "Desktop_" & $Curent_Desktop + 1, @ScriptDir & "\Desktop_" & $Curent_Desktop & ".bmp")
                        $Desktop_Data[$Curent_Desktop][0] = @ScriptDir & "\Desktop_" & $Curent_Desktop & ".bmp"
                EndIf
        EndIf
EndFunc   ;==>_CheckWallpaper

Func _CheckHotKeys()
        If _IsPressed(27) And _IsPressed(11) And _IsPressed(12) Then
                $Sticky_Window = WinGetHandle("")
                If $Curent_Desktop = $Num_Of_Desktop - 1 Then
                        _ChangeDesktop(0)
                Else
                        _ChangeDesktop($Curent_Desktop + 1)
                EndIf

                Do
                        Sleep(1)
                Until _IsPressed(27) = 0 Or _IsPressed(11) = 0 Or _IsPressed(12) = 0
        ElseIf _IsPressed(25) And _IsPressed(11) And _IsPressed(12) Then
                $Sticky_Window = WinGetHandle("")
                If $Curent_Desktop = 0 Then
                        _ChangeDesktop($Num_Of_Desktop - 1)
                Else
                        _ChangeDesktop($Curent_Desktop - 1)
                EndIf

                Do
                        Sleep(1)
                Until _IsPressed(25) = 0 Or _IsPressed(11) = 0 Or _IsPressed(12) = 0
        EndIf
EndFunc   ;==>_CheckHotKeys

Func _Effects()
        Local $cur_desktop

        $Ginfo = GUIGetCursorInfo($Form1)
        If Not @error Then
                For $x = 0 To $Num_Of_Desktop - 1
                        If $Ginfo[4] = $Desktop_Pic[$x] Then
                                $a_pos = ControlGetPos($Form1, "", $Desktop_Pic[$x])
                                $f_pos = WinGetPos($Form1)
                                WinMove($Hover_Form, "", $f_pos[0] + $a_pos[0] + 1, $f_pos[1] + $a_pos[1] + 1, $a_pos[2], $a_pos[3])
                                $Hover_Wait_Timer = 0
                                $cur_desktop = String($x)
                                ExitLoop
                        EndIf
                Next

                If $x = $Num_Of_Desktop And TimerDiff($Hover_Wait_Timer) > 500 And $Hover_Wait_Timer > 0 Then
                        $a_pos = ControlGetPos($Form1, "", $Desktop_Pic[$Curent_Desktop])
                        $f_pos = WinGetPos($Form1)
                        WinMove($Hover_Form, "", $f_pos[0] + $a_pos[0] + 1, $f_pos[1] + $a_pos[1] + 1, $a_pos[2], $a_pos[3])
                        $Hover_Wait_Timer = 0
                ElseIf $x = $Num_Of_Desktop And $Hover_Wait_Timer = 0 Then
                        $Hover_Wait_Timer = TimerInit()
                EndIf

                If $Ginfo[2] And $Ginfo[4] = 0 And WinActive($Form1) Then
                        $a_pos = WinGetPos($Form1)
                        While _IsPressed(01)
                                If @error Then ExitLoop
                                $a_pos[1] = MouseGetPos(1) - $Ginfo[1]
                                If $a_pos[1] >= $DesktopSize[1] - $a_pos[3] Then $a_pos[1] = $DesktopSize[1] - $a_pos[3]
                                If $a_pos[1] <= 0 Then $a_pos[1] = 0
                                WinMove($Form1, "", $a_pos[0], $a_pos[1])
                                If MouseGetPos(0) > $DesktopSize[0] / 2 And $a_pos[0] <= 0 Then
                                        $a_pos[0] = ($DesktopSize[0] - $a_pos[0]) - $a_pos[2]
                                ElseIf MouseGetPos(0) < $DesktopSize[0] / 2 And $a_pos[0] + $a_pos[2] >= $DesktopSize[0] Then
                                        $a_pos[0] = ($DesktopSize[0] - $a_pos[0]) - $a_pos[2]
                                EndIf
                                Sleep(10)
                        WEnd
                        IniWrite(@ScriptDir & "\Data.ini", "Setings", "Default_Gui_Pos", $a_pos[0] & "," & $a_pos[1])
                EndIf
        EndIf

        $Ginfo = GUIGetCursorInfo($Hover_Form)
        If @error Then Return

        If (WinActive($Form1) Or WinActive($Hover_Form)) And $Ginfo[0] > 0 And $Ginfo[0] < $Form_Size_X And $Ginfo[1] > 0 And $Ginfo[1] < $Form_Size_Y And $Ginfo[2] Then Return $cur_desktop
EndFunc   ;==>_Effects

Func _Slide()
        Local $i_dir, $s_dir = 0
        Switch @GUI_CtrlId
                Case $Slide_Button
                        If GUICtrlRead($Slide_Button) = "<" Then $i_dir = 1
                        $s_dir = "Right"
                Case $Slide_Button2
                        If GUICtrlRead($Slide_Button2) = ">" Then $i_dir = 1
                        $s_dir = "Left"
        EndSwitch

        If $i_dir = 0 Then
                _WinSlide($Form1, $s_dir, $i_dir, 15, 25)
        Else
                _WinSlide($Form1, $s_dir, $i_dir, 15, 20)
        EndIf

        If GUICtrlRead($Slide_Button) = ">" Then
                GUICtrlSetData($Slide_Button, "<")
                GUICtrlSetData($Slide_Button2, ">")
        Else
                GUICtrlSetData($Slide_Button, ">")
                GUICtrlSetData($Slide_Button2, "<")
        EndIf

        Return
EndFunc   ;==>_Slide

Func _WinSlide($s_hwnd, $s_dir, $i_dir, $i_speed = 10, $i_Stop = 0)
        Local $a_pos = WinGetPos($Form1)
        Local $i_sleeptime = 10
        Local $i_step

        Switch $i_dir
                Case 0
                        Switch $s_dir
                                Case "Left"
                                        For $x = $a_pos[2] - $i_Stop To $i_Stop Step -1 * _Sub($i_Stop, $a_pos[2]) / $i_speed
                                                WinMove($s_hwnd, "", $x - $a_pos[2], $a_pos[1])
                                                Sleep($i_sleeptime)
                                        Next
                                        WinMove($s_hwnd, "", $i_Stop - $a_pos[2], $a_pos[1])
                                Case "Right"
                                        For $x = $DesktopSize[0] - ($a_pos[2] - $i_Stop) To $DesktopSize[0] - $i_Stop Step _Sub($DesktopSize[0] - ($a_pos[2] - $i_Stop), $DesktopSize[0] - $i_Stop) / $i_speed
                                                WinMove($s_hwnd, "", $x, $a_pos[1])
                                                Sleep($i_sleeptime)
                                        Next
                                        WinMove($s_hwnd, "", $DesktopSize[0] - $i_Stop, $a_pos[1])
                                Case "Up"
                                        For $x = $a_pos[3] To $i_Stop Step -1 * _Sub($i_Stop, $a_pos[3]) / $i_speed
                                                WinMove($s_hwnd, "", $a_pos[0], $x - $a_pos[3])
                                                Sleep($i_sleeptime)
                                        Next
                                        WinMove($s_hwnd, "", $a_pos[0], $i_Stop - $a_pos[3])
                                Case "Down"
                                        For $x = $DesktopSize[1] - $a_pos[3] To $DesktopSize[1] - $i_Stop Step _Sub($DesktopSize[1] - $a_pos[3], $DesktopSize[1] - $i_Stop) / $i_speed
                                                WinMove($s_hwnd, "", $a_pos[0], $x)
                                                Sleep($i_sleeptime)
                                        Next
                                        WinMove($s_hwnd, "", $a_pos[0], $DesktopSize[1] - $i_Stop)
                        EndSwitch
                Case Else
                        Switch $s_dir
                                Case "Left"
                                        For $x = $i_Stop To $a_pos[2] - $i_Stop Step _Sub($i_Stop, $a_pos[2]) / $i_speed
                                                WinMove($s_hwnd, "", $x - $a_pos[2], $a_pos[1])
                                                Sleep($i_sleeptime)
                                        Next
                                        WinMove($s_hwnd, "", 0 - $i_Stop, $a_pos[1])
                                Case "Right"
                                        For $x = $DesktopSize[0] - $i_Stop To $DesktopSize[0] - ($a_pos[2] + $i_Stop) Step -1 * _Sub($DesktopSize[0] - ($a_pos[2] + $i_Stop), $DesktopSize[0] - $i_Stop) / $i_speed
                                                WinMove($s_hwnd, "", $x, $a_pos[1])
                                                Sleep($i_sleeptime)
                                        Next
                                        WinMove($s_hwnd, "", $DesktopSize[0] - $a_pos[2] + $i_Stop, $a_pos[1])
                                Case "Up"
                                        For $x = $i_Stop To $a_pos[3] Step _Sub($i_Stop, $a_pos[3]) / $i_speed
                                                WinMove($s_hwnd, "", $a_pos[0], $x - $a_pos[3])
                                                Sleep($i_sleeptime)
                                        Next
                                        WinMove($s_hwnd, "", $a_pos[0], 0 - $i_Stop)
                                Case "Down"
                                        For $x = $DesktopSize[1] - $i_Stop To $DesktopSize[1] - $a_pos[3] + $i_Stop Step -1 * _Sub($DesktopSize[1] - $a_pos[3], $DesktopSize[1] - $i_Stop) / $i_speed
                                                WinMove($s_hwnd, "", $a_pos[0], $x)
                                                Sleep($i_sleeptime)
                                        Next
                                        WinMove($s_hwnd, "", $a_pos[0], $DesktopSize[1] - $a_pos[3])
                        EndSwitch
        EndSwitch
        Return
EndFunc   ;==>_WinSlide

Func _Sub($s_Num1, $s_Num2)
        If $s_Num1 > $s_Num2 Then Return $s_Num1 - $s_Num2
        Return $s_Num2 - $s_Num1
EndFunc   ;==>_Sub

Func _Exit()
        Exit
EndFunc   ;==>_Exit

Func _Wallpaper_Change($s_BitmapImage, $l_params = 0)
        Local $ai_Ret
        $ai_Ret = DllCall('user32.dll', 'long', 'SystemParametersInfoA', 'long', 20, 'long', 0, 'str', $s_BitmapImage, 'long', $l_params)
        RegWrite('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper', 'REG_SZ', $s_BitmapImage)
        Return $ai_Ret[0]
EndFunc   ;==>_Wallpaper_Change

Func _Wallpaper_Get()
        Return RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "WallPaper")
EndFunc   ;==>_Wallpaper_Get

Func _ScreenShot()
        Local $Reset_WinStyle = False
        ;_SetWinStat($Form1, 1)
        ;_SetWinStat($Hover_Form, 1)
        If _IsPressed(10) Then
                $Old_EX_STYLE = _WinAPI_GetWindowLong($Sticky_Window, $GWL_EXSTYLE) ;tnx komalo for this trick :P
                WinSetTrans($Sticky_Window, "", 255)
                Sleep(50)
                $Reset_WinStyle = True
        EndIf

        _ScreenCapture_Capture(@TempDir & "\Desktop_" & $Curent_Desktop & ".bmp", 0, 0, $DesktopSize[0], $DesktopSize[1], False)
        If $Reset_WinStyle Then _WinAPI_SetWindowLong($Sticky_Window, $GWL_EXSTYLE, $Old_EX_STYLE)

        GUICtrlSetImage($Desktop_Pic[$Curent_Desktop], @TempDir & "\Desktop_" & $Curent_Desktop & ".bmp")
        GUICtrlSetImage($Fade_Form_Pic, @TempDir & "\Desktop_" & $Curent_Desktop & ".bmp")
        WinSetTrans($Hover_Form, "", 120)
        ;_SetWinStat($Form1, 2)
        ;_SetWinStat($Hover_Form, 2)

        If $Fade_Trans Or $Slide_Trans Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Fade_Form, "int", 0, "long", 0x00080000)
EndFunc   ;==>_ScreenShot

Func _ChangeDesktop($s_desktop)
        Local $win, $x
        If $s_desktop = $Curent_Desktop Then Return

        $win = _GetWindows()
        _ScreenShot()

        If $win[0] > UBound($Desktop_Data, 2) - 1 Then ReDim $Desktop_Data[$Num_Of_Desktop][$win[0] + 1]
        For $x = 1 To UBound($Desktop_Data, 2) - 1
                $Desktop_Data[$Curent_Desktop][$x] = ""
        Next

        For $x = 1 To $win[0]
                $Desktop_Data[$Curent_Desktop][$x] = $win[$x]
                If $win[$x] = "" Then ContinueLoop
                _SetWinStat($win[$x], 1)
        Next

        For $x = UBound($Desktop_Data, 2) - 1 To 1 Step -1
                If $Desktop_Data[$s_desktop][$x] = "" Then ContinueLoop
                _SetWinStat($Desktop_Data[$s_desktop][$x], 2)
        Next

        If _IsPressed(10) Then _SetWinStat($Sticky_Window, 2)

        If $Desktop_Data[$s_desktop][0] <> _Wallpaper_Get() Then _Wallpaper_Change($Desktop_Data[$s_desktop][0], 3)

        If $Fade_Trans Then
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Fade_Form, "int", $Trans_Speed, "long", 0x00090000)
        ElseIf $Slide_Trans Then
                If $s_desktop > $Curent_Desktop Then
                        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Fade_Form, "int", $Trans_Speed, "long", 0x00050002)
                Else
                        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Fade_Form, "int", $Trans_Speed, "long", 0x00050001)
                EndIf
        EndIf
        $Curent_Desktop = $s_desktop
EndFunc   ;==>_ChangeDesktop

Func _SetWinStat($h_wnd, $i_stat)
        Switch $i_stat
                Case 1
                        _WinAPI_ShowWindow($h_wnd, @SW_HIDE)
                Case 2
                        _WinAPI_ShowWindow($h_wnd, @SW_SHOW)
        EndSwitch
EndFunc   ;==>_SetWinStat

Func _GetWindows()
        Local $aWindows, $i, $s_return, $i_count

        $aWindows = WinList()
        For $i = 1 To $aWindows[0][0]
                If $aWindows[$i][0] = "" Then ContinueLoop
                If Not _WinAPI_IsWindowVisible($aWindows[$i][1]) Then ContinueLoop
                If StringInStr($Class_Blacklist, _WinAPI_GetClassName($aWindows[$i][1]) & "|") Then ContinueLoop
                If _IsPressed(10) And $aWindows[$i][1] = $Sticky_Window Then ContinueLoop

                $i_count += 1
                If $Debug Then ConsoleWrite($i_count & ": " & $aWindows[$i][1] & " -> " & $aWindows[$i][0] & @CRLF)
                $s_return &= $aWindows[$i][1] & Chr(1)
        Next

        Return StringSplit(StringTrimRight($s_return, 1), Chr(1))
EndFunc   ;==>_GetWindows

Func OnAutoitExit()
        For $y = 0 To UBound($Desktop_Data, 1) - 1
                For $x = 0 To UBound($Desktop_Data, 2) - 1
                        If $Desktop_Data[$y][$x] = "" Then ContinueLoop
                        _SetWinStat($Desktop_Data[$y][$x], 2)
                Next
        Next

        _Wallpaper_Change(IniRead(@ScriptDir & "\Data.ini", "Wallpaper", "Desktop_Default", _Wallpaper_Get()), 3)
EndFunc   ;==>OnAutoitExit
 楼主| 发表于 2019-1-11 21:14:08 | 显示全部楼层
haijie1223 发表于 2019-1-11 20:36
官网找的, 你可以试试。

一时半刻没找到双屏的机器来折腾,但是初步运行的结果很惊艳


这个程序好像是自己创建多个屏幕

具体还得细细消化


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2019-1-12 16:46:16 | 显示全部楼层
补充添加了另外一种设置壁纸的方法,自己顶上去
 楼主| 发表于 2019-1-14 23:25:55 | 显示全部楼层

再补充了一些资料
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-23 03:38 , Processed in 0.077180 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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