Jump to content

Recommended Posts

Posted (edited)

I'm writing a companion app to my MercMon program ( http://www.shrum.net/code/mercmon ).

I located the registry value for wallpaper but I need to instruct windows to 'refresh' the desktop in order for the change to take effect and I don't know how to do that.

TIA

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Posted

Hi,

something like this?

$screensaver = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "SCRNSAVE.EXE")
If FileExists($screensaver) Then Run($screensaver & " /s")

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Posted (edited)

No. Let me clarify. Specifically, I'm doing something like this:

regwrite ("hkcu\control panel\desktop",  "Wallpaper", "REG_SZ", "c:\kewl.jpg")

However, that isn't enough to trigger the actual wallpaper change.

I need to tell Windows to 'refresh' the wallpapere, read the wallpaper settings and pull the new file.

Granted, I'll set the util to pull from a folder of files or a specific file but that I know how to do.

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Posted

DllCall("User32.dll", "int", "SystemParametersInfo", "int", 20, "int", 0, "string", "PATH TO IMAGE", "int", 0x01)

Change path to image to, um, the path to the image. Images have to be a bmp when using this. I use pictview's commandline program to convert images in my wallpaper script.

You may also want to adjust the tile/center/stretch options, which are at...

$s_style/tile is a 1 or a 0.

1, 1 is tiled

2, 0 is stretched

1, 0 is centered

RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", $s_style)

RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", $s_tile)

Posted (edited)

Woot xcal, that works.

Sort of a bummer that you have to call to bmp files.

There has to be a way to convert the JPG to BMP natively as Windows is doing that already when you go thru the Display control panel.

Any ideas?

EDIT: no problem...figure I can copy the currently defined BMP to a folder (open.bmp/closed.bmp) and switch it back when the orientation is changed...this works better as the user won't have to do anythin in my app...just change the desktop thru the control panel.

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Posted (edited)

No idea how windows does it natively, but it's simple and invisible with pictview's commandline app. Here's my function for applying walls:

Func applyimage($s_path, $s_style, $s_tile)
    $apply_type = StringRight($s_path, 4)
    If $apply_type = ".jpg" Or _
            $apply_type = ".gif" Or _
            $apply_type = ".png" Then
        FileDelete(@WindowsDir & "\xwall.bmp")
        RunWait(@ScriptDir & "\pvw32con.exe " & '"' & $s_path & '"' & " -w --oo " & '"' & @WindowsDir & "\xwall.bmp" & '"', _
                @ScriptDir, @SW_HIDE)
    Else
        FileCopy($s_path, @WindowsDir & "\xwall.bmp", 1)
    EndIf
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", $s_style)
    RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", $s_tile)
    Sleep(250)
    DllCall("User32.dll", "int", "SystemParametersInfo", _
            "int", 20, _
            "int", 0, _
            "string", @WindowsDir & "\xwall.bmp", _
            "int", 0x01)
EndFunc

Really simple to add more $apply_type 's.

Edited by xcal
  • 1 month later...
Posted

What about this registry entry for using JPGs?

"HKEY_CURRENT_USER\Control Panel\Desktop", "ConvertedWallpaper", "Reg_SZ", "C:\directory\kewl.jpg"

I had success with this registry setting back when I used AutoIt v2, however refreshing the desktop was my problem.

Posted

What about this registry entry for using JPGs?

"HKEY_CURRENT_USER\Control Panel\Desktop", "ConvertedWallpaper", "Reg_SZ", "C:\directory\kewl.jpg"

I had success with this registry setting back when I used AutoIt v2, however refreshing the desktop was my problem.

Although its not a direct call, you can add the following to refresh the desktop...

Run("rundll32.exe"& " " & "shell32.dll,Control_RunDLL desk.cpl")
WinWait("Display Properties")
WinActivate("Display Properties")
Send("{ENTER}")
  • 1 month later...
Posted

F5 does not work in this situation. At least, not in my experience. F5 only refreshes files on the desktop, not the wallpaper.

ACalcutt's suggestion of "RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters ,1 ,True" seems to work fine for updating the desktop for me.

  • 1 month later...

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
  • Recently Browsing   0 members

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