发送 WM_SETTINGCHANGE 消息刷新桌面 [英] Send WM_SETTINGCHANGE message to refresh desktop

查看:31
本文介绍了发送 WM_SETTINGCHANGE 消息刷新桌面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法通过这个单行程序以编程方式更改了我的桌面背景:

I managed to programmatically change my desktop background via this one-liner:

DllCall("user32.dll", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $CmdLine[1], "int", 0)

…通过将所需的壁纸拖放到已编译的脚本上.

… by drag and drop of the desired wallpaper onto the compiled script.

我有另一个程序可以更改桌面,但由于某种原因未能发送 WM_SETTINGCHANGE 消息(我可以看到密钥 HKCUControl PanelDesktopWallpaper更新).如何发送此消息以触发壁纸刷新?WM_SETTINGCHANGE 是正确的消息吗?还是第一个脚本是唯一的方法?

I have another program that changes the desktop but for some reason fails to send the WM_SETTINGCHANGE message (I can see the key HKCUControl PanelDesktopWallpaper getting updated). How can I send this message to trigger a wallpaper refresh? Is WM_SETTINGCHANGE the correct message? Or is the first script the only way?

我试过了,但没有用:

DllCall("user32.dll", "lresult", "SendMessage", _
     "int", 0xffff, _
     "int", 0x001a, _
     "int", 0x0014, _
     "str", "HKCUControl Panel")

0xffff 用于向每个窗口广播消息,0x001a 代表WM_SETTINGCHANGE0x0014 是代码spi_setdeskwallpaper.Windows 7 中的任务栏闪烁,但墙纸没有变化.

0xffff is for broadcasting the message to every window, 0x001a stands for WM_SETTINGCHANGE, 0x0014 is the code for spi_setdeskwallpaper. The taskbar in Windows 7 flickers but the wallpaper doesn't change.

如果你用 C、C++ 或 Visual Basic 解决我的问题,我会自己把它转换成 AutoIt(我只需要被调用函数的数字代码).

If you solve my problem in C, C++ or Visual Basic I'll convert it to AutoIt myself (I just need the numerical codes of the called functions).

推荐答案

#include <SendMessage.au3>
#include <WindowsConstants.au3>

Dim $hWnd = WinGetHandle('[CLASS:Progman]')
_SendMessage($hWnd, $WM_COMMAND, 0x0001A220)

应该可以.如果没有,请告诉我,以便我更新此答案.

Should work. Let me know if it doesn't, so I can update this answer.

这篇关于发送 WM_SETTINGCHANGE 消息刷新桌面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆