How can I detect a change in wallpaper as a result of a Windows 7 slideshow?

I am writing a program that needs to know when the desktop wallpaper changes. After some searching, I found a partial solution: http://www.neowin.net/forum/topic/567779-net-detect-wallpaper-change/

Essentially, he says to listen to the WM_SETTINGCHANGE message and check the wallpaper. Unfortunately, this message does not seem to be sent when the wallpaper changes as a result of the Windows 7 wallpaper slide show. In fact, not a single message is sent to my application at all for this (the only time I saw WndProc not to receive constant messages :) )

So my question is to poll the registry and wallpaper file for changes, is there any way to detect when this will happen? Does anyone know where I can find API documents that list which function is being called?

+4
source share
3 answers

In fact, I figured out a workaround for the problem. In fact, there is a registry notification mechanism, so you can raise an event when the specified key / value changes. HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper is the key. This does not change when the slideshow changes the wallpaper, but the file in this place changes. By monitoring the file for changes, you may be notified of this change.

By the way, the whole essence of the application that I encoded was based on this, so omitting it would not be an option :).

Thank you for your answer, though - they helped to reassure my conscience that I had to go through such a circular way of doing something.

+2
source

This is a good question, and I left it unanswered for a while to find out if anyone knows something that I don’t have.

But, unfortunately, I think you will find that it is not possible to receive notifications corresponding to this event. The wallpaper slideshow does not actually change the system theme or any system settings, so the WM_SETTINGCHANGE message WM_SETTINGCHANGE not sent. It is designed to happen in the background and does not require notification of any application. If the user has chosen the "slide show" option, it is reasonable to assume that they expect the background to change at periodic intervals, no interaction or notification is required. In short, in at least 99% of cases, your application should not respond otherwise than as a result of changes in wallpaper associated with the slide show option.

The best I can think of is to determine the interval that they indicated at which to change the wallpaper, and then attach your application to the appropriate time when that time is up. In essence, you will have to create and respond to your own notifications.

A poll of the registry should be very discouraged. This is not only completely undocumented and therefore prone to hacking future versions of Windows (or even Windows updates!), But it is also not a reliable indicator. If there is any alternative (including a complete lack of functionality), then the path I would take.

+1
source

I have a better idea, for a little time I wrote a small program that automatically changes my background to LogonScreen and wants to improve it with the ability to automatically detect which wallpapers are in the background and set the same when windows change my background. So, I started my investigation and found:

  • % USERDIR% \ AppData \ Roaming \ Microsoft \ Windows \ Themes - a place for the current transcoded image from bg and slideshow.ini, which contains a little information about the current topic
  • % USERDIR% \ AppData \ Local \ Microsoft \ Windows \ Themes - a folder containing the themes installed on this system.

So, the algorithm is as follows:

  • read the .ini slideshow and get the value in [Slideshow]
  • read all the theme files and compare the [Slideshow] value for each theme, and if it is equal, we found the current theme file
  • from the file of the current topic, the read value Interval = 1800000 (in my case it is 30 minutes) (BTW, the interval placed after [Slide show], so this can be done in the same iteration of the lines)
  • Read the time change from the current image to bg:% USERDIR% \ AppData \ Roaming \ Microsoft \ Windows \ Themes \ TranscodedWallpaper.jpg
  • So, we have the time for the next change (current_time - modify_time + Interval) and can execute any code when changing the wallpaper (also do not forget about the catches when changing the settings or changing, as this can cause exceptions, we can double-check this file every minute or what something like this)
  • And if you try to write the same program, do not forget the size of the compressed image, because it requires a maximum of 256 KB.
+1
source

Source: https://habr.com/ru/post/1346544/


All Articles