Jump to content

Refresh Desktop


Recommended Posts

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]
Link to comment
Share on other sites

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 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]
Link to comment
Share on other sites

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

This would work but like you said I don't think it would be a good idea to run again :D .

[font="Times New Roman"]Ocho.[/font]
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

@Thanubis - didn't work :D

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 :D

Am I doing something wrong? I included all the extra files need. Any ideas?

[font="Times New Roman"]Ocho.[/font]
Link to comment
Share on other sites

@DCCD - don't know what you mean

>>

Hey guys. I am looking for a way to refresh the desktop with AutoIT.

:D

changes the wallpaper by using RegWrite()

Use the SystemParametersInfo API function

AutoIt search engine will help you find the information you are looking for! :D

Link to comment
Share on other sites

@Authenticity

I was reading the post you told me and this is what I found,

Valuater:

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):

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]
Link to comment
Share on other sites

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
);

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 by Authenticity
Link to comment
Share on other sites

@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 by OchoNueve
[font="Times New Roman"]Ocho.[/font]
Link to comment
Share on other sites

@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]
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...