WildByDesign Posted May 29 Author Posted May 29 It turns out that WinGetTitle was also the source of the brief white flicker on the title bar. After switching to a class name based filtering, the flicker is gone and everything is even faster. argumentum 1
WildByDesign Posted May 30 Author Posted May 30 I just updated the first post with version 0.6. TL;DR - Check first post for changelog and source. I did not end up going with only class name for the initial event hook. I was up to 20-25 lines just to avoid class names for windows which had no title. That was fast but too problematic and the list would only grow. Nothing beat the "filter all blank titles" rule If $sActiveWindow = "" Then ContinueCase from @argumentum original script derived from WinGetTitle. The only problem is that WinGetTitle was identified as causing lag, much higher CPU usage and under rare situations it would freeze the entire script. I had tried _WinAPI_GetWindowText before but it always gave inconsistent results. So I modified it and fixed the problem: Func _WinAPI_GetWindowTextMod($hWnd) Local $sActiveWindow Local $aCall = DllCall("user32.dll", "int", "GetWindowTextW", "hwnd", $hWnd, "wstr", "", "int", 4096) If @error Or Not $aCall[0] Then $sActiveWindow = "" Return $sActiveWindow EndIf Return $aCall[2] EndFunc This fixed the lag issue, lowered CPU usage to almost nothing, made the whole event hook faster (little to no flicker) and fixed the rare issue of the entire script freezing under certain circumstances. That freeze was something that I could reproduce consistently before but it's gone now. I know I used the term "night and day" difference on a recent release, but that was nothing compared to this. I don't know why WinGetTitle is so slow because I can't see the code for it. But stay away from it in any situations where it gets called many times and performance matters. I also added wildcards for the inclusion/exclusion lists. The wildcards can be added at the beginning and/or end, not in the middle. For example, you could do *WndClass* which would then cover like 5 or 6 different classes at once. You could do C:\Windows\notepad.exe or even simply *notepad*. You get the idea.
WildByDesign Posted May 31 Author Posted May 31 The first post has been updated to version 0.7. The overall speed of the event hook is faster in this release which is nice. I cleaned up the event hook function to make it perform better. This release is mostly geared toward improving the File Explorer handling in the hook. I had to differentiate between classic File Explorer and modern File Explorer. Classic File Explorer has no issues with DwmExtendFrameIntoClientArea or Blur Behind and therefore can be applied immediately and stays applied. Modern File Explorer, on the other hand, is a "laggy" beast. It loses client area coloring from DwmExtendFrameIntoClientArea any time it loses and regains focus which I solved in a previous release. But it also doesn't always apply 100% of the time when you first start it due to a timing issue with how laggy it is. This can be different depending on the speed of any users' CPU. So I added ExplorerPaintDelay to the config file with a default value of 200ms which fixes it 100% of the time on my system. But I made it a config option because it might be different on other users' systems depending on hardware specs and how "laggy" modern File Explorer is. Modern File Explorer sometimes had an issue applying Blur Behind when starting File Explorer. I noticed that if you click on the taskbar and back on File Explorer, it fixes it. I will try to fix it properly when I have more time, but for now I have fixed it (100%) with a workaround in the blur behind function: If $sClassName = "CabinetWClass" Then WinActivate("[CLASS:Shell_TrayWnd]") WinActivate($hWnd) EndIf So that extra bit is only needed for File Explorer. All handling of both classic and modern File Explorer is super smooth in this release. File Explorer startup, losing and regaining focus, etc. It all works beautifully. And all of that extra work was only needed because modern File Explorer is such a "laggy" monstrosity. Classic File Explorer is and was always fast. Modern File Explorer has always been slow and "laggy" and Microsoft seems to have no desire to improve it. argumentum 1
WildByDesign Posted Monday at 11:42 PM Author Posted Monday at 11:42 PM Version 0.8 has been added to the first post. There were two goals for this release. The first was to complete the Blur Behind feature and the second was more performance improvements to the event hook. The Blur Behind had an issue where the titlebar would lose the blur after losing and regaining focus. I fixed that and it's working 100% now with the exception of modern File Explorer. Modern File Explorer required some special handling in the event hook. Blur Behind is complete now and fabulous. The event hook is basically instantaneous now. I created a testing script that runs through the functions used in my event hook 100,000 times to get a timediff. The results helped me tidy up, modify and organize the functions in my event hook to improve performance a bit. I was able to improve the initial startup performance as well. I am really thrilled with how much DwmColorBlurMica has evolved and improved. I have learned a lot from this. argumentum 1
WildByDesign Posted Tuesday at 01:28 PM Author Posted Tuesday at 01:28 PM In 0.9 (just updated first post), I added the ability to change the titlebar text color. Changing the titlebar text color is generally not needed. If you change the titlebar background color, the OS will generally (automatically) change the titlebar text color to something that is legible. However, if the option is available to change the titlebar text color in case someone wants to have fun with it. There may also be certain circumstances with Blur Behind that could benefit from changing the text color. I finally updated the documentation file (DwmColorBlurMica.txt) with some OS requirements for the different API calls and some general info. argumentum 1
WildByDesign Posted yesterday at 01:28 PM Author Posted yesterday at 01:28 PM (edited) I just updated the first post with version 0.9.1. I improved the custom hook handling for modern File Explorer to what seems like perfection on my system. But most importantly, I added custom hook handling for Windows Terminal. So if you love Windows Terminal and want to style it, you can now. Good news: You do NOT have to install any custom msstyles (like Rectify11 Black Mica theme) to enjoy this feature for Terminal. That is because Terminal already uses DwmExtendFrameIntoClientArea and therefore I only needed to change the backdrop type or enable blur behind. It involved a lot more than just that, but that is why you don't need a custom msstyles. You can use this just fine with default Windows Aero dark theme. Screenshots: Spoiler Note: While you don't need to install any custom msstyles, you do need to modify the theme details inside of the Windows Terminal settings. Location: C:\Users\~your-user-name~\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json You need to add the following theme details at the appropriate place in the file: Spoiler "theme": "myNewTheme", "themes": [ { "name": "myNewTheme", "tab": { "background": null, "iconStyle": "default", "showCloseButton": "always", "unfocusedBackground": "#00000000" }, "tabRow": { "background": "#00000000", "unfocusedBackground": "#00000000" }, "window": { "applicationTheme": "dark", "experimental.rainbowFrame": false, "frame": null, "unfocusedFrame": null, "useMica": true } } ], Edited yesterday at 01:30 PM by WildByDesign
WildByDesign Posted yesterday at 01:36 PM Author Posted yesterday at 01:36 PM (edited) Also regarding Windows Terminal custom handling, it is disabled by default in the config file. You would need to change WindowsTerminalHandling to True. If you want Blur Behind, under [ClassInclusion], you can add CASCADIA_HOSTING_WINDOW_CLASS to include it OR under [ProcessInclusion], you can add WindowsTerminal.exe (you don't need to include it in both sections, just one or the other) Edited yesterday at 01:38 PM by WildByDesign
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now