WinDynamicDesktop icon indicating copy to clipboard operation
WinDynamicDesktop copied to clipboard

windows/app theme does not referesh the system after switching!

Open ghost opened this issue 2 years ago • 40 comments

  • WDD Version: 5.1
  • OS Version: 11 lastest

Steps to Reproduce:

1.change light to dark mode 2. pressing start menu shows whitetext on white surface+app that needs to be updated doesnot referesh unless refreshed manuallY!

Are you using the Microsoft Store version of WDD?: No

ghost avatar Apr 09 '22 13:04 ghost

Can you check if the same behavior happens when you manually switch between light and dark themes in Windows 11 Personalization settings? If so, this is a bug in Windows rather than WDD.

t1m0thyj avatar Apr 09 '22 14:04 t1m0thyj

we checked this me and the other app developer, the problem is from your side(maybe the scripts or something)

ghost avatar Apr 09 '22 14:04 ghost

For me, this issue occurs on the latest Windows 11 Beta build (22593.1) with WDD 5.1. I tick "Enable Night Mode," apps such as browsers switch to dark as expected but the system UI and the background remains light.

snowtyler avatar Apr 10 '22 00:04 snowtyler

here is a demonstration: your app does not refresh the system theme properly so the app looks like this: wrongColor after refresh(the supposed look of the app): rightColor

maybe the problem is with the scripts instead of the main app? idk i am not that geek with software engineering! i use it for beautiful looks on my windows pc

ghost avatar Apr 15 '22 15:04 ghost

The same problem have bothered me for some time. I just found that when you change the SystemUsesLightTheme in the registry directly to false, the taskbar stay the same while the start menu and icons operate properly. I wonder what changes have been made when you change the color theme in the system settings.

oreomaker avatar Apr 24 '22 03:04 oreomaker

It seems like Microsoft has changed the behavior of the night mode shifting actions in recent preview versions.

LinHier avatar Aug 12 '22 13:08 LinHier

The problem is still relevant in the latest version of windows 22621.1105

shust avatar Jan 20 '23 08:01 shust

My system:

Version Windows 11 Pro Workstation (Insider Preview) Version 22H2 Installation Date ‎2023/‎1/‎22 OS Version 25281.1000 Experience Windows Feature Experience Pack 1000.25281.1000.0


I checked the registry mentioned in the script. Things come strange.

Here's how it comes:

  • If I change the color schedule manually in the Settings App, the registry value changes. Meanwhile the app windows and the taskbar changes color.
  • If I click refresh wallpaper in WDD, the registry value changes to the same value as manually triggered. Meanwhile, the app windows changes its color, but the taskbar remains the same. After a restart it will sync the registry.

I guess that the Settings App has got some other ways to communicate with the taskbar, bypassing the registry.

leostudiooo avatar Jan 22 '23 02:01 leostudiooo

Looking for a solution.

gaoyang avatar Feb 16 '23 01:02 gaoyang

I have the same issue. I think the font color and other system parameters must be called after changing the registry. Furthermore, I think this is more related to WDD scripts than WDD itself. This issue is more about the System Theme switch/Application Theme switch. Check my mouse script, How I called system parameters to update the new mouse value.

$CSharpSig = @’
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(
             uint uiAction,
             uint uiParam,
             uint pvParam,
             uint fWinIni);
‘@
$CursorRefresh = Add-Type -MemberDefinition $CSharpSig -Name WinAPICall -Namespace SystemParamInfo –PassThru
$CursorRefresh::SystemParametersInfo(0x0057,0,$null,0)

Pull request for the mouse script: https://github.com/t1m0thyj/WDD-scripts/pull/31 Mouse script where I called system parameters to update their mouse values: https://github.com/t1m0thyj/WDD-scripts/blob/a0994e51bab41a0baeb568fa77ef0c4664958909/ChangeMouseScheme.ps1

You just need to know which API needs to be called to update these values. Maybe use Process Monitor v3.92?

bigplayer-ai avatar Feb 19 '23 09:02 bigplayer-ai

I noticed such a thing, if you turn off and turn on the transparency effect in the settings, then the theme comes to the desired view.

Perhaps this can somehow be added to the auto-switching day / night theme script?

Untitled-1

shust avatar Feb 20 '23 08:02 shust

Looks like the AutoDarkMode team had the same issue and managed to get it working by updating the colorization: https://github.com/AutoDarkMode/Windows-Auto-Night-Mode/issues/567

adoginspace avatar Mar 03 '23 21:03 adoginspace

It seems like Microsoft has made theme switching more difficult in Windows 11, so there is no longer a simple way to do it from a PowerShell script. I would suggest using AutoDarkMode alongside WinDynamicDesktop if you want both features - dynamic wallpaper and automatic dark theme.

t1m0thyj avatar Mar 04 '23 04:03 t1m0thyj

It seems like Microsoft has made theme switching more difficult in Windows 11, so there is no longer a simple way to do it from a PowerShell script. I would suggest using AutoDarkMode alongside WinDynamicDesktop if you want both features - dynamic wallpaper and automatic dark theme.

This solution seems less elegant since one has to run one more app in the background for that. Maybe I can try to fix this when I have more spare time but that will be months later.

leostudiooo avatar Mar 04 '23 04:03 leostudiooo

If that’s the case I think WDD should have a built in options to change dark/light theme switch that uses the way mentioned. On 4 Mar 2023, at 6:13, Li Lingfeng @.***> wrote:

It seems like Microsoft has made theme switching more difficult in Windows 11, so there is no longer a simple way to do it from a PowerShell script. I would suggest using AutoDarkMode alongside WinDynamicDesktop if you want both features - dynamic wallpaper and automatic dark theme.

This solution seems less elegant since one has to run one more app in the background for that. Maybe I can try to fix this when I have more spare time but that will be months later.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

bigplayer-ai avatar Mar 04 '23 07:03 bigplayer-ai

Prior to WinDD v4, there were built-in options to change app/system theme. I removed them since the purpose of the core app is only to display dynamic wallpapers, and moved them into separate PowerShell scripts.

Contributions to the WDD-scripts repo are welcome to fix the behavior of the Change App Theme and Change System Theme scripts 🙂

t1m0thyj avatar Mar 09 '23 03:03 t1m0thyj

If that’s the case I think WDD should have a built in options to change dark/light theme switch that uses the way mentioned

@bigplayer-ai Honestly maintaining a functioning theme switch is nightmare territory. It almost never works reliably and you're chasing behavior that often breaks the entire windows UI for no apparent reason.

I would assume maintaining WDD by itself is already enough work as is (and so is ADM as a matter of fact)

This solution seems less elegant since one has to run one more app in the background for that. Maybe I can try to fix this when I have more spare time but that will be months late

@leostudiooo It's already possible to call ADM via CLI, perform the operations you desire and then shut it down again, so you get no background app. You can also hide the tray icon so you won't even know its running temporarily. Yes you have to configure ADM a bit, but it should work.

As far as elegance is concerned. Automatic theme switching is absolutely not approved by Microsoft and hacks to achieve said theme switching cannot be elegant by design. We're not even sure that ADM will work in the future.

Spiritreader avatar Mar 09 '23 12:03 Spiritreader

Can you explain more about ADM clis?On 9 Mar 2023, at 14:31, Sam @.***> wrote:

If that’s the case I think WDD should have a built in options to change dark/light theme switch that uses the way mentioned

@bigplayer-ai Honestly maintaining a functioning theme switch is nightmare territory. It almost never works reliably and you're chasing behavior that often breaks the entire windows UI for no apparent reason. I would assume maintaining WDD by itself is already enough work as is (and so is ADM as a matter of fact)

This solution seems less elegant since one has to run one more app in the background for that. Maybe I can try to fix this when I have more spare time but that will be months late

@leostudiooo It's already possible to call ADM via CLI, perform the operations you desire and then shut it down again, so you get no background app. You can also hide the tray icon so you won't even know its running temporarily. Yes you have to configure ADM a bit, but it should work. As far as elegance is concerned. Automatic theme switching is absolutely not approved by Microsoft and hacks to achieve said theme switching cannot be elegant by design. We're not even sure that ADM will work in the future.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

bigplayer-ai avatar Mar 09 '23 13:03 bigplayer-ai

Can you explain more about ADM clis?

We have documentation available here: https://github.com/AutoDarkMode/Windows-Auto-Night-Mode/wiki/Command-line-arguments-%7C-parameters

You would call something like this in WDD:

AutoDarkModeShell.exe --switch 10 --and-launch-service
AutoDarkModeShell.exe --exit

while having automatic switching and tray icon disabled in the AutoDarkMode settings, which can be configured using the app.

Spiritreader avatar Mar 09 '23 16:03 Spiritreader

Looks like the AutoDarkMode team had the same issue and managed to get it working by updating the colorization: AutoDarkMode/Windows-Auto-Night-Mode#567

Updating colorization works, but is done for a different reason, namely updating the titlebars/colors. It should not be used when performing actual theme switching because it introduces lag. The only reason ADM makes use of this is to ensure changing the titlebar color setting takes effect immediately when no other values in a theme file are changed. I strongly dissuade anyone from using this in order to fix light/dark theme switching.

Spiritreader avatar Mar 09 '23 17:03 Spiritreader

@Spiritreader Do you have any idea How can I change mouse scheme using ADM CLI while using WDD? I tried thinking of a solution. as they support this feature.

bigplayer-ai avatar Mar 09 '23 19:03 bigplayer-ai

@Spiritreader Do you have any idea How can I change mouse scheme using ADM CLI while using WDD? I tried thinking of a solution. as they support this feature.

Use windows theme mode, configure two themes with different mouse cursors, then set the "ignore background" flag.

If you have further questions feel free to use the discussions tab in the Auto dark Mode repository to keep the discussion in this issue on topic.

Spiritreader avatar Mar 09 '23 19:03 Spiritreader

Oh Thanks I just needed to update my ADM. Btw, I am not succeeding running this in powershell 7 script, What could be the reason? I think my problem is purely syntax.

AutoDarkModeShell.exe --force-light --and-launch-service
AutoDarkModeShell.exe --exit

I'm sadly not proficient in powershell, but yes, it's probably related to escaping arguments and using the correct call syntax I would assume. Also make sure you include the full path to the AutoDarkModeShell executable if you haven't put the ADM directory in your path variables.

I would also recommend specifying a custom timeout here:

AutoDarkModeShell.exe --force-light 10 --and-launch-service

There was a bug in older versions (including current stable, so ensure you're using the latest beta) that caused problems if it was omitted with the launch service argument present.

Spiritreader avatar Mar 09 '23 19:03 Spiritreader

I found the correct syntax for PowerShell 7:

$params = @("--light", "10", "--and-launch-service")
& "C:\Program Files (x86)\AutoDarkMode\AutoDarkModeShell.exe" @params
$params2 = @("--exit")
& "C:\Program Files (x86)\AutoDarkMode\AutoDarkModeShell.exe" @params2

What does the custom timeout do, and why do you recommend it (I thought the timeout value is a parameter that you can use with Auto Dark Mode to specify how long you want to switch your theme for.)? Why should I use it? And do you think should I use force-dark or regular dark CLI in ADM?

bigplayer-ai avatar Mar 09 '23 20:03 bigplayer-ai

I found the correct syntax for PowerShell 7:

$params = @("--light", "10", "--and-launch-service")
& "C:\Program Files (x86)\AutoDarkMode\AutoDarkModeShell.exe" @params
$params2 = @("--exit")
& "C:\Program Files (x86)\AutoDarkMode\AutoDarkModeShell.exe" @params2

What does the custom timeout do, and why do you recommend it (I thought the timeout value is a parameter that you can use with Auto Dark Mode to specify how long you want to switch your theme for.)? Why should I use it? And do you think should I use force-dark or regular dark CLI in ADM?

The custom timeout specifies how long the shell waits for the ADM service to respond. It's to ensure compatibility as mentioned before. Some older versions don't support the --and-launch-service parameter without also specifying the timeout. Mainly because of the order in which cli arguments were parsed.

In your case it doesn't really matter if you use --force-light or --light and --force-dark or --dark since you exit the ADM service afterwards. Setting the force flag will bypass ADM's internal postpone mechanism and theme state checks. It will also prevent ADM from switching again on its own. Clearing the force status only matters if you want to keep the service alive, so I would recommend making use of the force flags.

Spiritreader avatar Mar 09 '23 21:03 Spiritreader

In your case it doesn't really matter if you use --force-light or --light and --force-dark or --dark since you exit the ADM service afterwards. Setting the force flag will bypass ADM's internal postpone mechanism and theme state checks. It will also prevent ADM from switching again on its own. Clearing the force status only matters if you want to keep the service alive, so I would recommend making use of the force flags.

Actually it does differ. If you force night mode while using non forced dark mode. The theme won't switch if you set it for different time. Can you check my last version of ADM specific code snippet?

# Use a ternary operator to assign different values to $params based on $nightMode
$params = $nightMode ? @("--force-dark", "10", "--and-launch-service") : @("dark", "10", "--and-launch-service")

# Invoke AutoDarkModeShell.exe with $params
& "C:\Program Files (x86)\AutoDarkMode\AutoDarkModeShell.exe" @params

# Invoke AutoDarkModeShell.exe with --exit
& "C:\Program Files (x86)\AutoDarkMode\AutoDarkModeShell.exe" --exit

bigplayer-ai avatar Mar 09 '23 21:03 bigplayer-ai

In your case it doesn't really matter if you use --force-light or --light and --force-dark or --dark since you exit the ADM service afterwards. Setting the force flag will bypass ADM's internal postpone mechanism and theme state checks. It will also prevent ADM from switching again on its own. Clearing the force status only matters if you want to keep the service alive, so I would recommend making use of the force flags.

Actually it does differ. If you force night mode while using non forced dark mode. The theme won't switch if you set it for different time. Can you check my last version of ADM specific code snippet?

# Use a ternary operator to assign different values to $params based on $nightMode
$params = $nightMode ? @("--force-dark", "10", "--and-launch-service") : @("dark", "10", "--and-launch-service")

# Invoke AutoDarkModeShell.exe with $params
& "C:\Program Files (x86)\AutoDarkMode\AutoDarkModeShell.exe" @params

# Invoke AutoDarkModeShell.exe with --exit
& "C:\Program Files (x86)\AutoDarkMode\AutoDarkModeShell.exe" --exit

No. If you have set up everything correctly, it doesn't matter if you use the force method or not. Please ensure that automatic switching is disabled in ADM and that your theme is configured correctly.

Your snippet only generates --force-dark and --dark as parameters, that doesn't seem right.

I'm not involved with WDD. I merely reached out as courtesy for people that want to get theme switching to work alongside it without actually having to use the ADM background service. Which is technically not how the program is supposed to be used.

My main focus lies with maintaining ADM. What you're doing currently should eventually lead to success though, but might require a bit of tinkering.

Good luck!

Spiritreader avatar Mar 09 '23 21:03 Spiritreader

Ok thanks, It seems working pretty well atm. Also, It helped me with my mouse scheme (less clutter). I just noticed that you are part of auto dark mode program. Thank you for this amazing utility.

bigplayer-ai avatar Mar 09 '23 21:03 bigplayer-ai

Ok thanks, It seems working pretty well atm. Also, It helped me with my mouse scheme (less clutter). I just noticed that you are part of auto dark mode program. Thank you for this amazing utility.

Sure thing, glad you like it! Just wanted to clarify that I don't really know much about WDD and powershell, as such I can't really help out there.

Spiritreader avatar Mar 09 '23 21:03 Spiritreader

Honestly maintaining a functioning theme switch is nightmare territory. It almost never works reliably and you're chasing behavior that often breaks the entire windows UI for no apparent reason.

I would assume maintaining WDD by itself is already enough work as is (and so is ADM as a matter of fact)

@Spiritreader Thanks for developing ADM ❤️ You are right, it's kind of a nightmare to maintain some features that are not approved by Microsoft 🙂 Setting a wallpaper across all virtual desktops is similar because it keeps breaking with new versions of Win11.

It's already possible to call ADM via CLI, perform the operations you desire and then shut it down again, so you get no background app. You can also hide the tray icon so you won't even know its running temporarily. Yes you have to configure ADM a bit, but it should work.

This is awesome for folks who want to use WinDD and ADM together. Would you approve of having a PowerShell script in the WDD-scripts repo that would invoke the ADM CLI to change theme? If so I can add one along with some documentation for how to set it up.

t1m0thyj avatar Mar 12 '23 01:03 t1m0thyj