Marcooo Posted June 22, 2012 Share Posted June 22, 2012 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! Link to comment Share on other sites More sharing options...
AZJIO Posted June 22, 2012 Share Posted June 22, 2012 MarcoooLinkFind the function _ChangeWallpaper, the search works fine. My other projects or all Link to comment Share on other sites More sharing options...
Marcooo Posted June 22, 2012 Author Share Posted June 22, 2012 (edited) 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 June 22, 2012 by Marcooo Link to comment Share on other sites More sharing options...
Marcooo Posted June 22, 2012 Author Share Posted June 22, 2012 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? Link to comment Share on other sites More sharing options...
Marcooo Posted June 23, 2012 Author Share Posted June 23, 2012 bump Link to comment Share on other sites More sharing options...
JohnOne Posted June 23, 2012 Share Posted June 23, 2012 Why int int int str? Why not hwnd uint wparam lparam? AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Marcooo Posted June 23, 2012 Author Share Posted June 23, 2012 Why int int int str?Why not hwnd uint wparam lparam?Because it gives a parsing error Link to comment Share on other sites More sharing options...
JohnOne Posted June 23, 2012 Share Posted June 23, 2012 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. AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Marcooo Posted June 23, 2012 Author Share Posted June 23, 2012 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? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now