找回密码  加入

AUTOIT CN

搜索
查看: 176|回复: 4

[AU3基础] 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来实现为每个屏幕单独设置独立的壁纸















本帖子中包含更多资源

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

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

  9. Opt("GUIOnEventMode", 1)

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

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

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

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

  36. $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)
  37. GUISetBkColor(0xccccff)
  38. $Slide_Button = GUICtrlCreateButton("<", 5, 20, 15, $Form_Size_Y - 25)
  39. $Exit_Button = GUICtrlCreateButton("X", 5, 5, 15, 15)
  40. $Slide_Button2 = GUICtrlCreateButton(">", $Form_Size_X + 25, 20, 15, $Form_Size_Y - 25)
  41. $Exit_Button2 = GUICtrlCreateButton("X", $Form_Size_X + 25, 5, 15, 15)
  42. ;GUICtrlCreateLabel("", 0,0, $Form_Size_X + 25, $Form_Size_X, -1, $GUI_WS_EX_PARENTDRAG)

  43. ;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
  44. GUICtrlSetBkColor($Slide_Button, 0xaaaaff)
  45. GUICtrlSetBkColor($Slide_Button2, 0xaaaaff)
  46. GUICtrlSetBkColor($Exit_Button, 0xaaaaff)
  47. GUICtrlSetBkColor($Exit_Button2, 0xaaaaff)

  48. GUICtrlSetOnEvent($Slide_Button, "_Slide")
  49. GUICtrlSetOnEvent($Exit_Button, "_Exit")
  50. GUICtrlSetOnEvent($Slide_Button2, "_Slide")
  51. GUICtrlSetOnEvent($Exit_Button2, "_Exit")

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

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

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

  59. GUISetState(@SW_HIDE, $Fade_Form)
  60. GUISetState(@SW_SHOW, $Form1)
  61. GUISetState(@SW_SHOW, $Hover_Form)
  62. WinSetTrans($Form1, "", 255)
  63. WinSetTrans($Fade_Form, "", 255)
  64. WinSetTrans($Hover_Form, "", 120)
  65. WinSetOnTop($Form1, "", 1)

  66. While 1
  67.         Sleep(10)
  68.         $Msg = _Effects()
  69.         If $Msg Then _ChangeDesktop($Msg)
  70.         _CheckWallpaper()
  71.         _CheckHotKeys()
  72. WEnd

  73. Func _CheckWallpaper()
  74.         If $Desktop_Data[$Curent_Desktop][0] <> _Wallpaper_Get() Then
  75.                 If @OSVersion = "WIN_VISTA" Then
  76.                         IniWrite(@ScriptDir & "\Data.ini", "Wallpaper", "Desktop_" & $Curent_Desktop + 1, _Wallpaper_Get())
  77.                         $Desktop_Data[$Curent_Desktop][0] = _Wallpaper_Get()
  78.                 Else
  79.                         FileCopy(_Wallpaper_Get(), @ScriptDir & "\Desktop_" & $Curent_Desktop & ".bmp")
  80.                         IniWrite(@ScriptDir & "\Data.ini", "Wallpaper", "Desktop_" & $Curent_Desktop + 1, @ScriptDir & "\Desktop_" & $Curent_Desktop & ".bmp")
  81.                         $Desktop_Data[$Curent_Desktop][0] = @ScriptDir & "\Desktop_" & $Curent_Desktop & ".bmp"
  82.                 EndIf
  83.         EndIf
  84. EndFunc   ;==>_CheckWallpaper

  85. Func _CheckHotKeys()
  86.         If _IsPressed(27) And _IsPressed(11) And _IsPressed(12) Then
  87.                 $Sticky_Window = WinGetHandle("")
  88.                 If $Curent_Desktop = $Num_Of_Desktop - 1 Then
  89.                         _ChangeDesktop(0)
  90.                 Else
  91.                         _ChangeDesktop($Curent_Desktop + 1)
  92.                 EndIf

  93.                 Do
  94.                         Sleep(1)
  95.                 Until _IsPressed(27) = 0 Or _IsPressed(11) = 0 Or _IsPressed(12) = 0
  96.         ElseIf _IsPressed(25) And _IsPressed(11) And _IsPressed(12) Then
  97.                 $Sticky_Window = WinGetHandle("")
  98.                 If $Curent_Desktop = 0 Then
  99.                         _ChangeDesktop($Num_Of_Desktop - 1)
  100.                 Else
  101.                         _ChangeDesktop($Curent_Desktop - 1)
  102.                 EndIf

  103.                 Do
  104.                         Sleep(1)
  105.                 Until _IsPressed(25) = 0 Or _IsPressed(11) = 0 Or _IsPressed(12) = 0
  106.         EndIf
  107. EndFunc   ;==>_CheckHotKeys

  108. Func _Effects()
  109.         Local $cur_desktop

  110.         $Ginfo = GUIGetCursorInfo($Form1)
  111.         If Not @error Then
  112.                 For $x = 0 To $Num_Of_Desktop - 1
  113.                         If $Ginfo[4] = $Desktop_Pic[$x] Then
  114.                                 $a_pos = ControlGetPos($Form1, "", $Desktop_Pic[$x])
  115.                                 $f_pos = WinGetPos($Form1)
  116.                                 WinMove($Hover_Form, "", $f_pos[0] + $a_pos[0] + 1, $f_pos[1] + $a_pos[1] + 1, $a_pos[2], $a_pos[3])
  117.                                 $Hover_Wait_Timer = 0
  118.                                 $cur_desktop = String($x)
  119.                                 ExitLoop
  120.                         EndIf
  121.                 Next

  122.                 If $x = $Num_Of_Desktop And TimerDiff($Hover_Wait_Timer) > 500 And $Hover_Wait_Timer > 0 Then
  123.                         $a_pos = ControlGetPos($Form1, "", $Desktop_Pic[$Curent_Desktop])
  124.                         $f_pos = WinGetPos($Form1)
  125.                         WinMove($Hover_Form, "", $f_pos[0] + $a_pos[0] + 1, $f_pos[1] + $a_pos[1] + 1, $a_pos[2], $a_pos[3])
  126.                         $Hover_Wait_Timer = 0
  127.                 ElseIf $x = $Num_Of_Desktop And $Hover_Wait_Timer = 0 Then
  128.                         $Hover_Wait_Timer = TimerInit()
  129.                 EndIf

  130.                 If $Ginfo[2] And $Ginfo[4] = 0 And WinActive($Form1) Then
  131.                         $a_pos = WinGetPos($Form1)
  132.                         While _IsPressed(01)
  133.                                 If @error Then ExitLoop
  134.                                 $a_pos[1] = MouseGetPos(1) - $Ginfo[1]
  135.                                 If $a_pos[1] >= $DesktopSize[1] - $a_pos[3] Then $a_pos[1] = $DesktopSize[1] - $a_pos[3]
  136.                                 If $a_pos[1] <= 0 Then $a_pos[1] = 0
  137.                                 WinMove($Form1, "", $a_pos[0], $a_pos[1])
  138.                                 If MouseGetPos(0) > $DesktopSize[0] / 2 And $a_pos[0] <= 0 Then
  139.                                         $a_pos[0] = ($DesktopSize[0] - $a_pos[0]) - $a_pos[2]
  140.                                 ElseIf MouseGetPos(0) < $DesktopSize[0] / 2 And $a_pos[0] + $a_pos[2] >= $DesktopSize[0] Then
  141.                                         $a_pos[0] = ($DesktopSize[0] - $a_pos[0]) - $a_pos[2]
  142.                                 EndIf
  143.                                 Sleep(10)
  144.                         WEnd
  145.                         IniWrite(@ScriptDir & "\Data.ini", "Setings", "Default_Gui_Pos", $a_pos[0] & "," & $a_pos[1])
  146.                 EndIf
  147.         EndIf

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

  150.         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
  151. EndFunc   ;==>_Effects

  152. Func _Slide()
  153.         Local $i_dir, $s_dir = 0
  154.         Switch @GUI_CtrlId
  155.                 Case $Slide_Button
  156.                         If GUICtrlRead($Slide_Button) = "<" Then $i_dir = 1
  157.                         $s_dir = "Right"
  158.                 Case $Slide_Button2
  159.                         If GUICtrlRead($Slide_Button2) = ">" Then $i_dir = 1
  160.                         $s_dir = "Left"
  161.         EndSwitch

  162.         If $i_dir = 0 Then
  163.                 _WinSlide($Form1, $s_dir, $i_dir, 15, 25)
  164.         Else
  165.                 _WinSlide($Form1, $s_dir, $i_dir, 15, 20)
  166.         EndIf

  167.         If GUICtrlRead($Slide_Button) = ">" Then
  168.                 GUICtrlSetData($Slide_Button, "<")
  169.                 GUICtrlSetData($Slide_Button2, ">")
  170.         Else
  171.                 GUICtrlSetData($Slide_Button, ">")
  172.                 GUICtrlSetData($Slide_Button2, "<")
  173.         EndIf

  174.         Return
  175. EndFunc   ;==>_Slide

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

  180.         Switch $i_dir
  181.                 Case 0
  182.                         Switch $s_dir
  183.                                 Case "Left"
  184.                                         For $x = $a_pos[2] - $i_Stop To $i_Stop Step -1 * _Sub($i_Stop, $a_pos[2]) / $i_speed
  185.                                                 WinMove($s_hwnd, "", $x - $a_pos[2], $a_pos[1])
  186.                                                 Sleep($i_sleeptime)
  187.                                         Next
  188.                                         WinMove($s_hwnd, "", $i_Stop - $a_pos[2], $a_pos[1])
  189.                                 Case "Right"
  190.                                         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
  191.                                                 WinMove($s_hwnd, "", $x, $a_pos[1])
  192.                                                 Sleep($i_sleeptime)
  193.                                         Next
  194.                                         WinMove($s_hwnd, "", $DesktopSize[0] - $i_Stop, $a_pos[1])
  195.                                 Case "Up"
  196.                                         For $x = $a_pos[3] To $i_Stop Step -1 * _Sub($i_Stop, $a_pos[3]) / $i_speed
  197.                                                 WinMove($s_hwnd, "", $a_pos[0], $x - $a_pos[3])
  198.                                                 Sleep($i_sleeptime)
  199.                                         Next
  200.                                         WinMove($s_hwnd, "", $a_pos[0], $i_Stop - $a_pos[3])
  201.                                 Case "Down"
  202.                                         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
  203.                                                 WinMove($s_hwnd, "", $a_pos[0], $x)
  204.                                                 Sleep($i_sleeptime)
  205.                                         Next
  206.                                         WinMove($s_hwnd, "", $a_pos[0], $DesktopSize[1] - $i_Stop)
  207.                         EndSwitch
  208.                 Case Else
  209.                         Switch $s_dir
  210.                                 Case "Left"
  211.                                         For $x = $i_Stop To $a_pos[2] - $i_Stop Step _Sub($i_Stop, $a_pos[2]) / $i_speed
  212.                                                 WinMove($s_hwnd, "", $x - $a_pos[2], $a_pos[1])
  213.                                                 Sleep($i_sleeptime)
  214.                                         Next
  215.                                         WinMove($s_hwnd, "", 0 - $i_Stop, $a_pos[1])
  216.                                 Case "Right"
  217.                                         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
  218.                                                 WinMove($s_hwnd, "", $x, $a_pos[1])
  219.                                                 Sleep($i_sleeptime)
  220.                                         Next
  221.                                         WinMove($s_hwnd, "", $DesktopSize[0] - $a_pos[2] + $i_Stop, $a_pos[1])
  222.                                 Case "Up"
  223.                                         For $x = $i_Stop To $a_pos[3] Step _Sub($i_Stop, $a_pos[3]) / $i_speed
  224.                                                 WinMove($s_hwnd, "", $a_pos[0], $x - $a_pos[3])
  225.                                                 Sleep($i_sleeptime)
  226.                                         Next
  227.                                         WinMove($s_hwnd, "", $a_pos[0], 0 - $i_Stop)
  228.                                 Case "Down"
  229.                                         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
  230.                                                 WinMove($s_hwnd, "", $a_pos[0], $x)
  231.                                                 Sleep($i_sleeptime)
  232.                                         Next
  233.                                         WinMove($s_hwnd, "", $a_pos[0], $DesktopSize[1] - $a_pos[3])
  234.                         EndSwitch
  235.         EndSwitch
  236.         Return
  237. EndFunc   ;==>_WinSlide

  238. Func _Sub($s_Num1, $s_Num2)
  239.         If $s_Num1 > $s_Num2 Then Return $s_Num1 - $s_Num2
  240.         Return $s_Num2 - $s_Num1
  241. EndFunc   ;==>_Sub

  242. Func _Exit()
  243.         Exit
  244. EndFunc   ;==>_Exit

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

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

  254. Func _ScreenShot()
  255.         Local $Reset_WinStyle = False
  256.         ;_SetWinStat($Form1, 1)
  257.         ;_SetWinStat($Hover_Form, 1)
  258.         If _IsPressed(10) Then
  259.                 $Old_EX_STYLE = _WinAPI_GetWindowLong($Sticky_Window, $GWL_EXSTYLE) ;tnx komalo for this trick :P
  260.                 WinSetTrans($Sticky_Window, "", 255)
  261.                 Sleep(50)
  262.                 $Reset_WinStyle = True
  263.         EndIf

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

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

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

  273. Func _ChangeDesktop($s_desktop)
  274.         Local $win, $x
  275.         If $s_desktop = $Curent_Desktop Then Return

  276.         $win = _GetWindows()
  277.         _ScreenShot()

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

  282.         For $x = 1 To $win[0]
  283.                 $Desktop_Data[$Curent_Desktop][$x] = $win[$x]
  284.                 If $win[$x] = "" Then ContinueLoop
  285.                 _SetWinStat($win[$x], 1)
  286.         Next

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

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

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

  293.         If $Fade_Trans Then
  294.                 DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Fade_Form, "int", $Trans_Speed, "long", 0x00090000)
  295.         ElseIf $Slide_Trans Then
  296.                 If $s_desktop > $Curent_Desktop Then
  297.                         DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Fade_Form, "int", $Trans_Speed, "long", 0x00050002)
  298.                 Else
  299.                         DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Fade_Form, "int", $Trans_Speed, "long", 0x00050001)
  300.                 EndIf
  301.         EndIf
  302.         $Curent_Desktop = $s_desktop
  303. EndFunc   ;==>_ChangeDesktop

  304. Func _SetWinStat($h_wnd, $i_stat)
  305.         Switch $i_stat
  306.                 Case 1
  307.                         _WinAPI_ShowWindow($h_wnd, @SW_HIDE)
  308.                 Case 2
  309.                         _WinAPI_ShowWindow($h_wnd, @SW_SHOW)
  310.         EndSwitch
  311. EndFunc   ;==>_SetWinStat

  312. Func _GetWindows()
  313.         Local $aWindows, $i, $s_return, $i_count

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

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

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

  326. Func OnAutoitExit()
  327.         For $y = 0 To UBound($Desktop_Data, 1) - 1
  328.                 For $x = 0 To UBound($Desktop_Data, 2) - 1
  329.                         If $Desktop_Data[$y][$x] = "" Then ContinueLoop
  330.                         _SetWinStat($Desktop_Data[$y][$x], 2)
  331.                 Next
  332.         Next

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

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


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

具体还得细细消化


本帖子中包含更多资源

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

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

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

本版积分规则

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

GMT+8, 2019-1-23 10:11 , Processed in 0.107435 second(s), 15 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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