OchoNueve Posted June 26, 2009 Posted June 26, 2009 Hey guys. I am looking for a way to refresh the desktop with AutoIT. I don't know if this can be done my a simple RegWrite() or not. The problem I am running into is that I wrote a program that changes the wallpaper by using RegWrite(), but this change does not occur until after I log off and log back in. I need the change to happen immediately! I can't do it by going through "Display Proporties" because I want this to be done "quietly"...without the user finding out. Any help? Thanks. [font="Times New Roman"]Ocho.[/font]
colafrysen Posted June 26, 2009 Posted June 26, 2009 (edited) I am NOT Sure but i think that the program userinit.exe applies all your settings at login. I do not know if its a great idea to call it after it has been executed once though, as it might overwrite all the changes made since last login. Edit: Spelling Edited June 26, 2009 by colafrysen [font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
OchoNueve Posted June 26, 2009 Author Posted June 26, 2009 colafrysen said: I am NOT Sure but i think that the program userinit.exe applies all your settings at login.I do not know if its a great idea to call it after it has been executed once though, as it might overwrite all the changes made since last login.Edit: SpellingThis would work but like you said I don't think it would be a good idea to run again . [font="Times New Roman"]Ocho.[/font]
colafrysen Posted June 26, 2009 Posted June 26, 2009 Well, it might be worth a test. Try logging of (to save all changes), then logg on, make a change, run userinit then check if the changes was erased. [font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
DCCD Posted June 26, 2009 Posted June 26, 2009 Else SendKeepActive("Program Manager") For $i = 1 to 5;How many times Sleep(1000) Send("{F5}") Next . [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group
Authenticity Posted June 26, 2009 Posted June 26, 2009 #include <SendMessage.au3> #include <WindowsConstants.au3> Dim $hWnd = WinGetHandle('[CLASS:Progman]') _SendMessage($hWnd, $WM_COMMAND, 0x0001A220)
OchoNueve Posted June 26, 2009 Author Posted June 26, 2009 @Thanubis - didn't work CODE RegWrite($wllpprLocation,"Wallpaper","REG_SZ",$newLocation) Local $bOld = Opt("WinSearchChildren", True) Local $a = WinList("[CLASS:SHELLDLL_DefView]") For $i = 1 To UBound($a) - 1 DllCall("user32.dll", "long", "SendMessage", "hwnd", $a[$i][1], "int", 0x111, "int", 28931, "int", 0) Next Opt("WinSearchChildren", $bOld) @Authenticity - didn't work CODE RegWrite($wllpprLocation,"Wallpaper","REG_SZ",$newLocation) Dim $hWnd = WinGetHandle('[CLASS:Progman]') _SendMessage($hWnd, $WM_COMMAND, 0x0001A220) @DCCD - don't know what you mean Am I doing something wrong? I included all the extra files need. Any ideas? [font="Times New Roman"]Ocho.[/font]
Authenticity Posted June 27, 2009 Posted June 27, 2009 #652536Read this post, at the bottom of the post the user sends a broadcast message and updates the system ini file so the change takes effect immediately.
DCCD Posted June 27, 2009 Posted June 27, 2009 Quote @DCCD - don't know what you mean>> OchoNueve said: Hey guys. I am looking for a way to refresh the desktop with AutoIT. Quote changes the wallpaper by using RegWrite()Use the SystemParametersInfo API functionAutoIt search engine will help you find the information you are looking for! [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group
OchoNueve Posted June 27, 2009 Author Posted June 27, 2009 @DCCD and @Authenticity I can't check until monday...i will let you know if it works then. Thanks guys. [font="Times New Roman"]Ocho.[/font]
OchoNueve Posted June 29, 2009 Author Posted June 29, 2009 @Authenticity I was reading the post you told me and this is what I found, Valuater: Quote RegWrite('HKCU\Control Panel\Desktop','Wallpaper','reg_sz',$sFile) DllCall("User32.dll","int","SystemParametersInfo","int",20,"int",0,"str",$sFile,"int",0) and Achilles (Saying he would change these two lines to): Quote Global Const $SPI_SETDESKWALLPAPER = 0x0014 Global Const $SPIF_UPDATEINIFILE = 0x0001 Global Const $SPIF_SENDCHANGE = 0x0002 ; Set wallpaper $tBuffer = DllStructCreate("char Text[" & StringLen($sTemp) + 1 & "]") DllStructSetData($tBuffer, "Text", $sTemp) _WinAPI_SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, DllStructGetPtr($tBuffer), BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE)) I tried playing around and reading about the functions they are using but since I have no idea what they do my code didn't work. Am I at least looking at the right functions? [font="Times New Roman"]Ocho.[/font]
Authenticity Posted June 29, 2009 Posted June 29, 2009 (edited) http://msdn.microsoft.com/en-us/library/ms...28VS.85%29.aspx BOOL WINAPI SystemParametersInfo( __in UINT uiAction, __in UINT uiParam, __inout PVOID pvParam, __in UINT fWinIni ); MSDN said: Sets the desktop wallpaper. The value of the pvParam parameter determines the new wallpaper. To specify a wallpaper bitmap, set pvParam to point to a NULL-terminated string containing the full path to the bitmap file. Setting pvParam to "" removes the wallpaper. Setting pvParam to SETWALLPAPER_DEFAULT or NULL reverts to the default wallpaper. The pvParam parameter can specify a .jpg file. Windows Server 2003 and Windows XP/2000: The pvParam parameter cannot specify a .jpg file. I guess you didn't fully fill the requirements or something else is not correct. If you're using SystemParametersInfoW() then pvParam is of type "wstr". If you're using SystemParametersInfoA() then pvParam is of type "str". If I'm not wrong using SystemParametersInfo() by default will invoke SystemParametersInfoW() so you'll need to use "wstr". About the rest read the documentation and here are the constants you may use: #define SPI_SETDESKWALLPAPER 0x0014 #define SPIF_UPDATEINIFILE 0x0001 #define SPIF_SENDWININICHANGE 0x0002 #define SPIF_SENDCHANGE SPIF_SENDWININICHANGE Edited June 29, 2009 by Authenticity
OchoNueve Posted June 29, 2009 Author Posted June 29, 2009 (edited) @Authenticity OK, so here is what I got so far CODE $SPI_SETDESKWALLPAPER = 0x0014 $SPIF_UPDATEINIFILE = 0x0001 $wallpaper = "C:\Documents and Settings\username\Desktop\Stonehenge.bmp" _WinAPI_SystemParametersInfo($SPI_SETDESKWALLPAPER,0,$wallpaper,$SPIF_UPDATEINIFILE) For what I understand, this will change the wallpaper to "Stonehenge.bmp" AND update the INI file which means that the change will take place immediately. I see my desktop "refresh" but the wallpaper stays the same. Edited June 30, 2009 by OchoNueve [font="Times New Roman"]Ocho.[/font]
OchoNueve Posted June 29, 2009 Author Posted June 29, 2009 @Authenticity I am soooooo sorry for wasting your time!!! The problem I was having was that the $wallpaper variable had the wrong name so the function was not finding the correct path!! I am so smart .... NOT Thank you for all your help bro, I really appreciate it! [font="Times New Roman"]Ocho.[/font]
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