Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows API to trigger wallpaper shuffle

Is there a way to trigger a shuffle in windows wallpaper slideshow? Preferably something I can use from .net

EDIT: so I'm trying to use the IActiveDesktop interface, I got it from here, I tried to use it like this:

public static IActiveDesktop GetActiveDesktop()
{
    Type typeActiveDesktop = Type.GetTypeFromCLSID(new Guid("{75048700-EF1F-11D0-9888-006097DEACF9}"));
    return (IActiveDesktop) Activator.CreateInstance(typeActiveDesktop);
}

and then calling it like this:

IActiveDesktop dt = GetActiveDesktop();
dt.ApplyChanges(AD_APPLY.ALL | AD_APPLY.FORCE | AD_APPLY.BUFFERED_REFRESH);

nothing happens when I run the code, no errors too.

like image 561
Madd0g Avatar asked Mar 24 '12 16:03

Madd0g


2 Answers

Try the following:

Your theme located in C:\Users\USERNAME\AppData\Local\Microsoft\Windows\Themes\.theme

Open the .theme file and update a Shuffle flag in the [Slideshow] section:

[Slideshow]     
Shuffle=1

Then use IActiveDesktop interface to reload theme, call ApplyChange with the following parameters:

AD_APPLY_ALL | AD_APPLY_FORCE | AD_APPLY_BUFFERED_REFRESH

like image 149
Flot2011 Avatar answered Nov 18 '22 13:11

Flot2011


OH WAIT, just discovered you just want to shuffle. Flot2011's answer is the way to go.

You can find the full path to the current user's theme via:

HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\CurrentTheme

If there's any api for this, it probably won't be exposed yet. Best thing I will do if I were you is to simulate a click of the 'Next desktop background' option in the Desktop Context Menu. There are several ways to do this, but I will suggest you use GetDesktopWindow api, simulate a right mouse click and send the 'n' key. I am not completely sure about what effect this will achieve but it should work.

Also take a look at this: http://www.technixupdate.com/keyboard-shortcut-or-hotkey-to-switch-to-next-windows-7-desktop-wallpaper/

like image 1
Chibueze Opata Avatar answered Nov 18 '22 14:11

Chibueze Opata