Jump to content



Photo

Sending WM_SETTINGCHANGE message to refresh desktop

WM_SETTINGCHANGE refresh desktop

  • Please log in to reply
8 replies to this topic

#1 Marcooo

Marcooo

    Seeker

  • Active Members
  • 6 posts

Posted 22 June 2012 - 11:46 AM

Hello everybody, this is my first post and I'm quite new to the world of AutoIt.

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

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


(via drag 'n' drop of the desired wallpaper onto the compiled script).

However, this code does even too much for my needs. In fact I have another software that changes the desktop but, for some unknown-to-me reasons, fails to send the WM_SETTINGCHANGE message (I can see the key HKCU\Control Panel\Desktop\Wallpaper getting updated in fact, by the way).
So I ask you: how can I write a simple script that sends this message and thus triggers the wallpaper refresh? And will it work or the first script is the only "real"/"correct" way to proceed programmatically?

I tried this but it doesn't work:

#include-once Global $MAX_VALUE_NAME = 1024 Global $HWND_BROADCAST = 0xffff Global $WM_SETTINGCHANGE = 0x001A Global $SMTO_ABORTIFHUNG = 0x0002 Global $SMTO_NORMAL = 0x0000 Global $MSG_TIMEOUT = 5000 DllCall("user32.dll", "lresult", "SendMessageTimeoutW", _ "hwnd", $HWND_BROADCAST, _ "dword", $WM_SETTINGCHANGE, _ "ptr", 0, _ "wstr", "Environment", _ "dword", $SMTO_ABORTIFHUNG, _ "dword", $MSG_TIMEOUT, _ "dword_ptr*", 0)


Many thanks in advance to whomever will help me!







#2 AZJIO

AZJIO

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,081 posts

Posted 22 June 2012 - 12:10 PM

Marcooo
Link
Find the function _ChangeWallpaper, the search works fine.

#3 Marcooo

Marcooo

    Seeker

  • Active Members
  • 6 posts

Posted 22 June 2012 - 01:00 PM

Ok, that works fine, but is a full-fledged script well beyond my needs, as I wrote above even that one-liner does too much for me.
I'm just interested in sending the WM_SETTINGCHANGE message. Unfortunately these pages http://msdn.microsoft.com/en-us/library/windows/desktop/ms644952(v=vs.85).aspx and http://msdn.microsoft.com/en-us/library/windows/desktop/ms725497(v=vs.85).aspx are a bit too technical for me...

Edited by Marcooo, 22 June 2012 - 01:02 PM.


#4 Marcooo

Marcooo

    Seeker

  • Active Members
  • 6 posts

Posted 22 June 2012 - 02:33 PM

I see I could use the function SendMessage function, too. However this code does nothing:


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


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 a little but the wallpaper doesn't change, why?

#5 Marcooo

Marcooo

    Seeker

  • Active Members
  • 6 posts

Posted 23 June 2012 - 08:51 AM

bump

#6 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 8,954 posts

Posted 23 June 2012 - 11:08 AM

Why int int int str?

Why not hwnd uint wparam lparam?

#7 Marcooo

Marcooo

    Seeker

  • Active Members
  • 6 posts

Posted 23 June 2012 - 11:14 AM

Why int int int str?

Why not hwnd uint wparam lparam?

Because it gives a parsing error

#8 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 8,954 posts

Posted 23 June 2012 - 11:20 AM

Well I know dll functions do not like getting the wrong parameter types passed to them
so perhaps you should check your error codes after the call.

#9 Marcooo

Marcooo

    Seeker

  • Active Members
  • 6 posts

Posted 23 June 2012 - 01:19 PM

I tried checking the error code with this:
$aResult = DllCall("user32.dll", "int", "PostMessage", "int", 0xffff, "int", 0x001a, "int", 0x0014, "str", "HKCUControl PanelDesktop") msgbox(0,"",$aResult[0])

and it returns 0.
So I should assume that WM_SETTINGCHANGE is really sent, yet it doesn't produce the effect I expect?





Also tagged with one or more of these keywords: WM_SETTINGCHANGE, refresh, desktop

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users