2

Question background:

I set my background to slideshow that changes every 10 minutes. It also choose the accent color automatically from my background and show the accent color on start, taskbar, and action center. These settings are slowing down my computer. Changing the background every 10 minutes is not that much of a problem, but adapting the selected color to the start menu, taskbar and action center seems to sort of restart taskbar which slows down the computer that moment. During normal use, this slowdown is shorter and doesn't affect anything, but when I'm in a game, this slowdown ruins my game. So, I need to change these setting before I enter a game. The fastest way to do this is in the following order: First I need to uncheck Automatically pick an accent color from background, so that my taskbar won't restart itself. Second, I switch the Background to single picture from slideshow. (If I firstly switch background to single picture, taskbar still restarts itself even though the same background and same accent colors). Of course, when I exited the game, I manually revert these changes again.

How can I do this with one (or two, one to make "game mode" changes and one to undo them) .bat file?

Screenshots of my settings:

My Background settings

My Colors settings1

My Colors settings2

What I tried:

I found Automatically pick an accent color from background setting in HKEY_CURRENT_USER\Control Panel\Desktop. There is a REG_DWORD called AutoColorization so, this batch script automatically switch the value between 0 (off) and 1 (on)

@echo off
setlocal enabledelayedexpansion

set KEY=HKEY_CURRENT_USER\Control Panel\Desktop
set VALUE=AutoColorization

REM Check current value of the registry key
for /f "tokens=3" %%i in ('reg query "%KEY%" /v "%VALUE%" ^| findstr "%VALUE%"') do (
  set /a CURRENT_VALUE=%%i
)

REM Toggle the value of the registry key
if !CURRENT_VALUE! equ 1 (
  set /a NEW_VALUE=0
) else (
  set /a NEW_VALUE=1
)

REM Update the registry key with the new value
reg add "%KEY%" /v "%VALUE%" /t REG_DWORD /d %NEW_VALUE% /f

REM Display the new value
echo %VALUE% set to %NEW_VALUE%

However, when I change registry key to 1 in this way, my the taskbar color does not update instantly, I have to wait for it to change to the next photo in the slideshow. But when I turn it on in the settings, the color update is applied instantly. This is what I mean by the "sort of restart" I mentioned above. I do not want to kill and restart explorer.exe entirely since it closes File Explorer windows etc. and also has more burden. So, I need to find how does this setting refresh the taskbar and find the code to refresh the same way.

I also find that Background switch in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers. There is a REG_DWORD called BackgroundType. 0 is Picture, 1 is Solid Color, and 2 is Slideshow.

However, when I change the value from the registry, nothing is applied. Background remains the same. As soon as I open the background tab in the settings, the registry entry returns to the old value. I probably need to change some other entries, but I can't find what they are.

Summary:

1-) When I change the accent color setting in the registry, I need to find a way to apply it directly to start, taskbar and action center (without taskkill)

2-) I need to find out which registry edits I need to make to change the background setting between Picture and Slideshow.

3-) I need to combine these settings into a batch file that will apply and change them sequentially.

Destroy666
  • 5,299
  • 7
  • 16
  • 35
  • 1
    As practical matter, if you're immersed in a game, likely running full screen, why would you care if the background changes? Just turn off background changes before playing, and start afterwards, which could be done in a three-line script to stop wallpaper changes, run game, then start wallpaper updating after game closes. – DrMoishe Pippik Apr 25 '23 at 17:27
  • 1
    I'm pretty sure you need to switch to at least PowerShell, if not C++/C# to use Windows APIs, to be able to achieve all your goals here. E.g. the registry without killing explorer part seems to be impossible with batch, unless you find some 3rd party CLI program that helps with that. – Destroy666 Apr 25 '23 at 19:20
  • @DrMoishePippik I would like to have more control on these settings for further use but I think changing only slideshow interval between 10 minutes and 1 day is enough to stop slowdown. – Halil Nebioğlu Apr 25 '23 at 19:26

1 Answers1

0

As @DrMoishePippik mentioned, to stop slowdown I just switch slideshow interval between my original value (10 minutes or 600000 ms on registry) and 1 day (or 86400000 ms on registry).

I'm using this script.

@echo off

setlocal

REM Check current value of Interval
for /f "tokens=2*" %%a in ('reg query "HKEY_CURRENT_USER\Control Panel\Personalization\Desktop Slideshow" /v "Interval" ^| find "Interval"') do set current_value=%%b
if %current_value% equ 86400000 (
    echo Interval is currently set to 86400000 
    set new_value=600000
    set new_value_text=10 MINUTES
) else (
    echo Interval is currently set 600000
    set new_value=86400000
    set new_value_text=1 DAY
)

REM Update Interval value
reg add "HKEY_CURRENT_USER\Control Panel\Personalization\Desktop Slideshow" /v "Interval" /t REG_DWORD /d %new_value% /f
    echo Interval value updated to %new_value% = %new_value_text%

REM Keep the window for 2 seconds
timeout 2
  • Please have a look at [Can I answer my own question?](https://superuser.com/help/self-answer) and come back two days later and check as answered if you have more than 15 reputation (See also: [Accept Your Own Answers](https://stackoverflow.blog/2009/01/06/accept-your-own-answers/). – help-info.de Apr 25 '23 at 19:55