发送WM_SETTINGCHANGE消息以刷新桌面 [英] Send WM_SETTINGCHANGE message to refresh desktop
问题描述
我设法通过此一线程序以编程方式更改了我的桌面背景:
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
消息(我可以看到键HKCU\Control Panel\Desktop\Wallpaper
正在更新).如何发送此消息以触发墙纸刷新? 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 HKCU\Control Panel\Desktop\Wallpaper
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?
我尝试了这个,但是不起作用:
I tried this but it doesn't work:
DllCall("user32.dll", "lresult", "SendMessage", _
"int", 0xffff, _
"int", 0x001a, _
"int", 0x0014, _
"str", "HKCU\Control Panel")
0xffff
用于将消息广播到每个窗口,0x001a
代表WM_SETTINGCHANGE
,0x0014
是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屋!