-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathImmersiveEngine.au3
More file actions
2044 lines (1757 loc) · 83.9 KB
/
ImmersiveEngine.au3
File metadata and controls
2044 lines (1757 loc) · 83.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=app.ico
#AutoIt3Wrapper_Outfile_x64=ImmersiveEngine.exe
#AutoIt3Wrapper_Compression=0
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Description=Immersive UX Engine
#AutoIt3Wrapper_Res_Fileversion=2.4.0
#AutoIt3Wrapper_Res_ProductName=Immersive UX Engine
#AutoIt3Wrapper_Res_ProductVersion=2.4.0
#AutoIt3Wrapper_Res_LegalCopyright=@ 2026 WildByDesign
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_HiDpi=N
#AutoIt3Wrapper_Run_Au3Stripper=y
#AutoIt3Wrapper_res_Compatibility=Win10
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <AutoItExitCodes.au3>
#include <Array.au3>
#include <Misc.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <WinAPIvkeysConstants.au3>
#include "include\WCD_IPC.au3"
#include "include\MediaPlayerUDF.au3"
#include "include\UIAEH_AutomationEventHandler.au3"
; HotKey only used temporarily when needing to look for window classes to include/exclude
;#include <Process.au3>
;HotKeySet("{SPACE}", "WinListtest")
; use RequireAdmin to color all apps, otherwise only user-mode apps will be colored
;#RequireAdmin
; DPI awareness
DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2)
Global $iPID, $sINFO, $oService, $fSpeed = 4
Global $IniFile = @ScriptDir & "\ImmersiveUX.ini"
Global $bDarkModeEnabled, $bClearChangesOnExit, $bRequireWindows11, $iBorderColorOptions
Global $g_iBlurTintColorInact, $g_iBlurOpacityInact
Global $aExcludeProcessNames, $aExcludeFromAllClass, $aExclusionsCombined
Global $bClassicExplorer, $bExplorerExtendClient
Global $g_bDarkTitleBar, $g_iBorderColor, $g_iTitleBarColor, $g_iTitleBarTextColor, $g_iTitleBarBackdrop, $g_iCornerPreference, $g_iExtendFrame, $g_iEnableBlurBehind
Global $g_iBlurTintColor, $g_iBlurTintColor, $g_iBlurOpacity
Global $dTerminalBorderColor, $dTerminalBackdrop, $bWindowsTerminalHandling, $dVSStudioBorderColor, $bWindowsTerminalBlur
Global $dVSCodiumBackdrop, $dVSCodeBackdrop
Global $bLiveEnabled, $bLoopEnabled
Global $iDuration, $iDurationMs, $oWinStart, $iDurationPause, $sStart
Global $iMediaRatio, $iMonitorRatio, $aGUI_Handles, $aGUI_Ratio
Global $hHookFunc, $hWinHook
Global $bMediaOpened = False
Global $bEnable = False
Global $bBoot = True
Global $bIsAnyBlurEnabled = False
Global $aCustomRules[0][16]
Global $bElevated = False
Global $sProdName = "ImmersiveUX"
Global $sEngName = "ImmersiveEngine"
Global $DWMWA_COLOR_NONE = "0xFFFFFFFE"
Global $DWMWA_COLOR_DEFAULT = "0xFFFFFFFF"
Global $WCA_ACCENT_POLICY = 19
Global $ACCENT_DISABLED = 0
Global $ACCENT_ENABLE_GRADIENT = 1
Global $ACCENT_ENABLE_TRANSPARENTGRADIENT = 2
Global $ACCENT_ENABLE_BLURBEHIND = 3
Global $ACCENT_ENABLE_ACRYLICBLURBEHIND = 4
Global $ACCENT_ENABLE_HOSTBACKDROP = 5
Global $ACCENT_INVALID_STATE = 6
Global $hDwmapi = DllOpen('dwmapi.dll')
Global $hUser32 = DllOpen('user32.dll')
Global $hKernel32 = DllOpen('kernel32.dll')
Global $hPsapi = DllOpen('psapi.dll')
Global $hGdi = DllOpen('gdi32.dll')
Global $hUxtheme = DllOpen('uxtheme.dll')
Opt("WinTitleMatchMode", 3)
; requires Windows 11 build 22621+
$OSBuild = @OSBuild
If $bRequireWindows11 = True Then
If $OSBuild < 22621 Then
MsgBox($MB_ICONERROR + $MB_SYSTEMMODAL, "Error", "This program only runs on Windows 11 build 22621 or higher." & @CRLF)
Exit
EndIf
Else
EndIf
; ensure that desktop composition is enabled
If Not _WinAPI_DwmIsCompositionEnabled_mod() Then
MsgBox($MB_ICONERROR + $MB_SYSTEMMODAL, 'Error', 'This program requires Desktop Composition to be enabled.')
Exit
EndIf
If StringInStr($CmdLineRaw, "bordereffects") Then
_BorderEffectsProcess()
Exit
EndIf
Global $aExcludeClassNames[17] = ["Progman", "Xaml_WindowedPopupClass", "Windows.UI.Core.CoreComponentInputSource", _
"Windows.UI.Core.CoreWindow", "Windows.UI.Composition.DesktopWindowContentBridge", "Chrome_RenderWidgetHostHWND", _
"ControlCenterWindow", "TopLevelWindowForOverflowXamlIsland", "SysDragImage", "IME", "OleMainThreadWndClass", "MSCTFIME UI", _
"CicMarshalWndClass", "XCPTimerClass", "msctls_statusbar32", "Microsoft.UI.Content.PopupWindowSiteBridge", "XamlExplorerHostIslandWindow"]
ReadIniFile()
If StringInStr($CmdLineRaw, "live") Then
_ImmersiveLiveProcess()
Exit
EndIf
If StringInStr($CmdLineRaw, "removeall") Then
SetBorderColor_removeall()
Exit
EndIf
; determine whether system just booted or not
$Uptime = _WinAPI_StrFromTimeInterval(_WinAPI_GetTickCount64_mod())
If StringInStr($Uptime, "min") Then
$bBoot = False
EndIf
If StringInStr($CmdLineRaw, "hookproc") Then
_HookProcess()
Exit
EndIf
Local $g_iIsTaskSchedInstalled = _TaskSched_AlreadyInstalled()
Local $g_iIsTaskSchedRun = False
If StringInStr($CmdLineRaw, 'runtask') Then $g_iIsTaskSchedRun = True
; if scheduled task is installed but not running, run the task instead
If @Compiled Then
If $g_iIsTaskSchedInstalled And Not $g_iIsTaskSchedRun Then
_TaskSched_Run()
Exit
EndIf
EndIf
If Not WinExists("Immersive UX Engine") Then
If @Compiled Then
ShellExecute(@ScriptDir & "\ImmersiveEngine.exe", "hookproc", @ScriptDir, $SHEX_OPEN)
ElseIf Not @Compiled Then
ShellExecute(@ScriptDir & "\ImmersiveEngine.au3", "hookproc")
EndIf
EndIf
If WinExists("Immersive UX Engine") Then
; start GUI/tray process
idGUI()
ElseIf Not WinExists("Immersive UX Engine") Then
WinWait("Immersive UX Engine", "", 5)
If WinExists("Immersive UX Engine") Then
; start GUI/tray process
idGUI()
EndIf
EndIf
_BrokerProcess()
Func _BrokerProcess()
Local $hWnd = _GetHwndFromPID(@AutoItPID)
_WinAPI_SetWindowText_mod($hWnd, "Immersive UX Broker")
Local $hServer = _WCD_CreateServer()
Local $aReq, $iData
While True
If _WCD_Server_IsRequestAvail() Then
$aReq = _WCD_Server_GetRequest()
$iData = @extended
Switch $iData
Case 1
Select
Case $aReq[1] = "start"
If @Compiled Then
ShellExecute(@ScriptDir & "\" & $sEngName & ".exe", "hookproc", @ScriptDir)
ElseIf Not @Compiled Then
ShellExecute(@ScriptDir & "\" & $sEngName & ".au3", "hookproc", @ScriptDir)
EndIf
Case $aReq[1] = "exit"
If WinExists("Immersive UX Engine") Then WinClose("Immersive UX Engine")
EndSelect
Case 2
Select
Case $aReq[1] = "start"
; start
Case $aReq[1] = "exit"
If WinExists("Immersive UX LED") Then WinClose("Immersive UX LED")
EndSelect
Case 3
Select
Case $aReq[1] = "start"
If @Compiled Then
RunLow("", @ScriptDir & "\ImmersiveEngine.exe" & " live", @ScriptDir)
ElseIf Not @Compiled Then
ShellExecute(@ScriptDir & "\ImmersiveEngine.au3", "live")
EndIf
Case $aReq[1] = "exit"
If WinExists("Immersive UX Live") Then WinClose("Immersive UX Live")
EndSelect
Case 4
Select
Case $aReq[1] = "start"
; start
Case $aReq[1] = "exit"
Exit
EndSelect
Case 5
Select
Case $aReq[1] = "start"
If @Compiled Then
ShellExecute(@ScriptDir & "\ImmersiveUX.exe", "", @ScriptDir)
ElseIf Not @Compiled Then
ShellExecute(@ScriptDir & "\ImmersiveUX.au3", "", @ScriptDir)
EndIf
Case $aReq[1] = "exit"
If WinExists("Immersive UX GUI") Then WinClose("Immersive UX GUI")
EndSelect
Case 6
Select
Case $aReq[1] = "uninstalltask"
; uninstall task here
Run('schtasks.exe /Delete /F /TN ImmersiveUX', '', @SW_HIDE)
EndSelect
EndSwitch
EndIf
Sleep(20)
WEnd
EndFunc
Func _HookProcess()
Local $g_iIsTaskSchedRun = False
If StringInStr($CmdLineRaw, 'runtask') Then $g_iIsTaskSchedRun = True
; ensure that only one instance is running
If _Singleton($sEngName, 1) = 0 Then
$sMsg = $sProdName & " is already running." & @CRLF
MsgBox($MB_ICONERROR + $MB_SYSTEMMODAL, "Error", $sMsg & @CRLF)
Exit
EndIf
If IsAdmin() Then $bElevated = True
Local $aSectionTS[4][2] = [[3, ""], ["StartedByTask", $g_iIsTaskSchedRun], ["PID", @AutoItPID], ["Elevated", $bElevated]]
IniWriteSection($IniFile, "StartupInfoOnly", $aSectionTS)
Opt("SetExitCode", 1)
OnAutoItExitRegister(DoCleanUp)
Local $hWnd = _GetHwndFromPID(@AutoItPID)
_WinAPI_SetWindowText_mod($hWnd, "Immersive UX Engine")
$hHookFunc = DllCallbackRegister('_WinEventProc', 'none', 'ptr;uint;hwnd;int;int;uint;uint')
$hWinHook = _WinAPI_SetWinEventHook_mod($EVENT_SYSTEM_FOREGROUND, $EVENT_OBJECT_NAMECHANGE, DllCallbackGetPtr($hHookFunc))
; don't apply to all during boot as there is no need
If $bBoot = False Then SetBorderColor_apply2all()
; set process priority
ProcessSetPriority(@AutoItPID, 4)
; start ImmersiveLED border effects if configured
If $iBorderColorOptions = "2" And Not WinExists("Immersive UX LED") Then
If @Compiled Then
ShellExecute(@ScriptDir & "\ImmersiveEngine.exe", "bordereffects", @ScriptDir, $SHEX_OPEN)
ElseIf Not @Compiled Then
ShellExecute(@ScriptDir & "\ImmersiveEngine.au3", "bordereffects")
EndIf
EndIf
; start Immersive UX Live if configured
If $bLiveEnabled And Not WinExists("Immersive UX Live") Then
If @Compiled Then
;ShellExecute(@ScriptDir & "\ImmersiveEngine.exe", "live", @ScriptDir, $SHEX_OPEN)
RunLow("", @ScriptDir & "\ImmersiveEngine.exe" & " live", @ScriptDir)
ElseIf Not @Compiled Then
ShellExecute(@ScriptDir & "\ImmersiveEngine.au3", "live")
EndIf
EndIf
While 1
Sleep(10000)
WEnd
EndFunc
Func _ToBoolean($sString)
Return (StringStripWS(StringUpper($sString), 8) = "TRUE" ? True : False)
EndFunc ;==>_ToBoolean
Func DoCleanUp()
SetBorderColor_removeall()
_Free()
IniDelete($IniFile, "StartupInfoOnly")
; show crash details if possible
If @exitCode <> 0 Then
$sMsg = "The Immersive UX engine process has crashed." & @CRLF & @CRLF
$sMsg &= "Error Code: " & "(0x" & Hex(@exitCode) & ')' & @CRLF & @CRLF
$sMsg &= '"' & _FormatAutoItExitCode() & '"'
MsgBox(0, "Immersive UX", $sMsg)
EndIf
EndFunc
Func _Free()
If $hWinHook Then _WinAPI_UnhookWinEvent_mod($hWinHook)
If $hHookFunc Then DllCallbackFree($hHookFunc)
EndFunc ;==>_Free
Func RefreshChanges()
; remove all based on current settings
SetBorderColor_removeall()
; read ini file for new changes
ReadIniFile()
; reapply all based on updated settings
SetBorderColor_apply2all()
EndFunc
Func SetBorderColor_removeall()
Local $hWnd, $sClassName, $sName
If $bClearChangesOnExit = True Then
$aArray = WinList()
For $n = 1 To $aArray[0][0]
; exclude windows with blank title
If $aArray[$n][0] = "" Then ContinueLoop
$sClassName = _WinAPI_GetClassName_mod($aArray[$n][1])
; exclude classnames from global exclusions
For $i = 0 To UBound($aExcludeClassNames) - 1
If $sClassName = $aExcludeClassNames[$i] Then ContinueLoop 2
Next
; exclude process names from global exclusions
$sName = _WinAPI_GetWindowFileName_mod($aArray[$n][1])
If $sName = "" Then ContinueLoop
For $i = 0 To UBound($aExcludeProcessNames) -1
If $sName = $aExcludeProcessNames[$i] Then ContinueLoop 2
Next
MainColoringRemoval($aArray[$n][1], $sClassName, $sName)
Next
EndIf
If $bClearChangesOnExit = True Then
; fix Windows Terminal from going fully transparent on exit
If WinExists("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]") Then
$hWnd = WinGetHandle("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]")
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(5000, 5000, 0, 0))
__DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, 2)
EndIf
; fix Task Manager from losing window control buttons on exit
If WinExists("[CLASS:TaskManagerWindow]") Then
$hWnd = WinGetHandle("[CLASS:TaskManagerWindow]")
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
__DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, 2)
EndIf
EndIf
EndFunc ;==>SetBorderColor_removeall
Func MainColoringRemoval($hWnd, $sClassName, $sName)
Local $i
Local $bMatchesFound = False
; determine if process rule or class rule matches for custom rules
For $i = 0 To UBound($aCustomRules) - 1
; run through all of the custom process/class rules for a match
If $sName = $aCustomRules[$i][1] Or $sClassName = $aCustomRules[$i][1] Then
; skip custom rules that are not Enabled
If Not $aCustomRules[$i][14] Then
;If $g_bDarkTitleBar Then __DwmSetWindowAttribute($hWnd, $DWMWA_USE_IMMERSIVE_DARK_MODE, True)
;If $iBorderColorOptions <> "0" Then
If $g_iBorderColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, 0xFFFFFFFF)
;EndIf
If $g_iTitleBarColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_CAPTION_COLOR, 0xFFFFFFFF)
If $g_iTitleBarTextColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_TEXT_COLOR, 0xFFFFFFFF)
If $g_iTitleBarBackdrop <> "" Then
If $sName = "VSCodium.exe" Or $sName = "Code.exe" Then
; prevent VSCodium and VSCode from being left completely transparent
__DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, 4)
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, 0x202020)
Else
__DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, 0)
EndIf
EndIf
If $g_iCornerPreference <> "" Then __DwmSetWindowAttribute($hWnd, $DWMWA_WINDOW_CORNER_PREFERENCE, 0)
If $g_iEnableBlurBehind Then _WinAPI_DwmEnableBlurBehindWindow11($hWnd, $ACCENT_DISABLED)
If $g_iExtendFrame And Not $g_iEnableBlurBehind Then
; fix for file explorer losing window control buttons occasionally
If $sClassName <> "CabinetWClass" Then _WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(0, 0, 0, 0))
EndIf
Return
EndIf
; border color reset to default
If $aCustomRules[$i][3] Or $g_iBorderColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, 0xFFFFFFFF)
; titlebar color reset to default
If $aCustomRules[$i][4] Or $g_iTitleBarColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_CAPTION_COLOR, 0xFFFFFFFF)
; titlebar text color reset to default
If $aCustomRules[$i][5] Or $g_iTitleBarTextColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_TEXT_COLOR, 0xFFFFFFFF)
; titlebar backdrop reset to default
If $aCustomRules[$i][6] <> "" Or $g_iTitleBarBackdrop <> "" Then
If $sName = "VSCodium.exe" Or $sName = "Code.exe" Then
; prevent VSCodium and VSCode from being left completely transparent
__DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, 4)
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, 0x202020)
Else
__DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, 0)
EndIf
EndIf
; corner preference reset to default
If $aCustomRules[$i][7] <> "" Or $g_iCornerPreference <> "" Then __DwmSetWindowAttribute($hWnd, $DWMWA_WINDOW_CORNER_PREFERENCE, 0)
; blur behind removal
If $aCustomRules[$i][9] = "True" Or $g_iEnableBlurBehind Then _WinAPI_DwmEnableBlurBehindWindow11($hWnd, $ACCENT_DISABLED)
; ExtendFrameIntoClientArea removal
If $aCustomRules[$i][8] = "True" Or $g_iExtendFrame Then
; only enable ExtendFrameIntoClientArea if blur behind is not enabled
If $aCustomRules[$i][9] <> "True" Or Not $g_iEnableBlurBehind Then
; fix for file explorer losing window control buttons occasionally
If $sClassName <> "CabinetWClass" Then _WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(0, 0, 0, 0))
EndIf
EndIf
$bMatchesFound = True
EndIf
Next
; fallback to global when no custom rules match
If Not $bMatchesFound Then
;If $g_bDarkTitleBar Then __DwmSetWindowAttribute($hWnd, $DWMWA_USE_IMMERSIVE_DARK_MODE, True)
If $g_iBorderColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, 0xFFFFFFFF)
If $g_iTitleBarColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_CAPTION_COLOR, 0xFFFFFFFF)
If $g_iTitleBarTextColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_TEXT_COLOR, 0xFFFFFFFF)
If $g_iTitleBarBackdrop <> "" Then
If $sName = "VSCodium.exe" Or $sName = "Code.exe" Then
; prevent VSCodium and VSCode from being left completely transparent
__DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, 4)
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, 0x202020)
Else
__DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, 0)
EndIf
EndIf
If $g_iCornerPreference <> "" Then __DwmSetWindowAttribute($hWnd, $DWMWA_WINDOW_CORNER_PREFERENCE, 0)
If $g_iEnableBlurBehind Then _WinAPI_DwmEnableBlurBehindWindow11($hWnd, $ACCENT_DISABLED)
If $g_iExtendFrame And Not $g_iEnableBlurBehind Then
; fix for file explorer losing window control buttons occasionally
If $sClassName <> "CabinetWClass" Then _WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(0, 0, 0, 0))
EndIf
EndIf
EndFunc
Func SetBorderColor_apply2all()
Local $sClassName
$aArray = WinList()
For $n = 1 To $aArray[0][0]
; exclude windows with blank title
If $aArray[$n][0] = "" Then ContinueLoop
$sClassName = _WinAPI_GetClassName_mod($aArray[$n][1])
; exclude classnames from global exclusions
For $i = 0 To UBound($aExcludeClassNames) - 1
If $sClassName = $aExcludeClassNames[$i] Then ContinueLoop 2
Next
MainColoringFunction($aArray[$n][1], $sClassName)
Next
; get active window and apply border only to active window
If $iBorderColorOptions = "0" Then
$hActiveWndLast = _WinAPI_GetForegroundWindow_mod()
$sClassNameActive = _WinAPI_GetClassName_mod($hActiveWndLast)
$sNameActive = _WinAPI_GetWindowFileName_mod($hActiveWndLast)
If $bIsAnyBlurEnabled Then _BlurOnlyActive($hActiveWndLast, $sClassNameActive, $sNameActive)
_ColorBorderOnly($hActiveWndLast, $sClassNameActive, $sNameActive)
EndIf
EndFunc ;==>SetBorderColor_apply2all
Func MainColoringFunction($hWnd, $sClassName)
Local $sName = _WinAPI_GetWindowFileName_mod($hWnd)
If Not @Compiled Then
Local $sWindow = _WinAPI_GetWindowText_mod($hWnd)
If $sWindow = "Immersive UX" Then $sName = "ImmersiveUX.exe"
EndIf
; exclude process names from global exclusions
If $sName = "" Then Return
For $i = 0 To UBound($aExcludeProcessNames) -1
If $sName = $aExcludeProcessNames[$i] Then Return
Next
MainColoringContinue($hWnd, $sClassName, $sName)
EndFunc
Func MainColoringContinue($hWnd, $sClassName, $sName)
Local $i
Local $bMatchesFound = False
Local $bIsDarkTitle = _WinAPI_ShouldAppsUseDarkMode()
; determine if process rule or class rule matches for custom rules
For $i = 0 To UBound($aCustomRules) - 1
; run through all of the custom process/class rules for a match
If $sName = $aCustomRules[$i][1] Or $sClassName = $aCustomRules[$i][1] Then
; skip custom rules that are not Enabled
If Not $aCustomRules[$i][14] Then
If $g_bDarkTitleBar And $bIsDarkTitle Then __DwmSetWindowAttribute($hWnd, $DWMWA_USE_IMMERSIVE_DARK_MODE, 1)
If $iBorderColorOptions = "1" Then
If $g_iBorderColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($g_iBorderColor))
EndIf
If $g_iTitleBarColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_CAPTION_COLOR, __SwitchColor($g_iTitleBarColor))
If $g_iTitleBarTextColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_TEXT_COLOR, __SwitchColor($g_iTitleBarTextColor))
If $g_iTitleBarBackdrop <> "" Then __DwmSetWindowAttribute($hWnd, 38, Int($g_iTitleBarBackdrop))
If $g_iCornerPreference <> "" Then __DwmSetWindowAttribute($hWnd, 33, Int($g_iCornerPreference))
If $g_iEnableBlurBehind Then _EnableBlur11($hWnd, $sName, $sClassName, $g_iBlurTintColorInact, $g_iBlurOpacityInact)
If Not $g_iEnableBlurBehind Then
; only enable ExtendFrameIntoClientArea if blur behind is not enabled
If $g_iExtendFrame Then _DwmExtendFrameIntoClientArea($hWnd, $sName, $sClassName, $i)
EndIf
Return
EndIf
; dark mode titlebar, fallback to global if not set
If $aCustomRules[$i][2] = "True" And $bIsDarkTitle Then
__DwmSetWindowAttribute($hWnd, $DWMWA_USE_IMMERSIVE_DARK_MODE, True)
EndIf
If $aCustomRules[$i][2] = "" Then
If $g_bDarkTitleBar And $bIsDarkTitle Then __DwmSetWindowAttribute($hWnd, $DWMWA_USE_IMMERSIVE_DARK_MODE, True)
EndIf
; border color, fallback to global if not set
If $iBorderColorOptions = "1" Then
If $aCustomRules[$i][3] Then
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($aCustomRules[$i][3]))
Else
If $g_iBorderColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($g_iBorderColor))
EndIf
EndIf
; titlebar color, fallback to global if not set
If $aCustomRules[$i][4] Then
__DwmSetWindowAttribute($hWnd, $DWMWA_CAPTION_COLOR, __SwitchColor($aCustomRules[$i][4]))
Else
If $g_iTitleBarColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_CAPTION_COLOR, __SwitchColor($g_iTitleBarColor))
EndIf
; titlebar text color, fallback to global if not set
If $aCustomRules[$i][5] Then
__DwmSetWindowAttribute($hWnd, $DWMWA_TEXT_COLOR, __SwitchColor($aCustomRules[$i][5]))
Else
If $g_iTitleBarTextColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_TEXT_COLOR, __SwitchColor($g_iTitleBarTextColor))
EndIf
; titlebar backdrop, fallback to global if not set
If $aCustomRules[$i][6] <> "" Then
__DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, Int($aCustomRules[$i][6]))
Else
If $g_iTitleBarBackdrop <> "" Then __DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, Int($g_iTitleBarBackdrop))
EndIf
; corner preference, fallback to global if not set
If $aCustomRules[$i][7] <> "" Then
__DwmSetWindowAttribute($hWnd, $DWMWA_WINDOW_CORNER_PREFERENCE, Int($aCustomRules[$i][7]))
Else
If $g_iCornerPreference <> "" Then __DwmSetWindowAttribute($hWnd, $DWMWA_WINDOW_CORNER_PREFERENCE, Int($g_iCornerPreference))
EndIf
; blur behind, fallback to global if not set
If $aCustomRules[$i][9] = "True" Then _EnableBlur11($hWnd, $sName, $sClassName, $aCustomRules[$i][12], $aCustomRules[$i][13])
If $aCustomRules[$i][9] = "" Then
; only enable blur if not custom set
If $g_iEnableBlurBehind Then _EnableBlur11($hWnd, $sName, $sClassName, $g_iBlurTintColorInact, $g_iBlurOpacityInact)
EndIf
; ExtendFrameIntoClientArea, fallback to global if not set
If $aCustomRules[$i][8] = "True" Then
; only enable ExtendFrameIntoClientArea if blur behind is not enabled
If $aCustomRules[$i][9] <> "True" Then _DwmExtendFrameIntoClientArea($hWnd, $sName, $sClassName, $i)
EndIf
If $aCustomRules[$i][8] = "" Then
; only enable ExtendFrameIntoClientArea if blur behind is not enabled
If $g_iExtendFrame And Not $g_iEnableBlurBehind Then
_DwmExtendFrameIntoClientArea($hWnd, $sName, $sClassName, $i)
EndIf
EndIf
$bMatchesFound = True
EndIf
Next
; fallback to global when no custom rules match
If Not $bMatchesFound Then
If $g_bDarkTitleBar And $bIsDarkTitle Then __DwmSetWindowAttribute($hWnd, $DWMWA_USE_IMMERSIVE_DARK_MODE, True)
If $g_iBorderColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($g_iBorderColor))
If $g_iTitleBarColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_CAPTION_COLOR, __SwitchColor($g_iTitleBarColor))
If $g_iTitleBarTextColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_TEXT_COLOR, __SwitchColor($g_iTitleBarTextColor))
If $g_iTitleBarBackdrop <> "" Then __DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, Int($g_iTitleBarBackdrop))
If $g_iCornerPreference <> "" Then __DwmSetWindowAttribute($hWnd, $DWMWA_WINDOW_CORNER_PREFERENCE, Int($g_iCornerPreference))
If $g_iEnableBlurBehind Then _EnableBlur11($hWnd, $sName, $sClassName, $g_iBlurTintColorInact, $g_iBlurOpacityInact)
If $g_iExtendFrame And Not $g_iEnableBlurBehind Then _DwmExtendFrameIntoClientArea($hWnd, $sName, $sClassName, $i)
EndIf
EndFunc
Func _BlurOnlyActive($hWnd, $sClassName, $sName)
Local $i
Local $bMatchesFound = False
Local $dBlurColor, $iBlurOpacity
; determine if process rule or class rule matches for custom rules
For $i = 0 To UBound($aCustomRules) - 1
; run through all of the custom process/class rules for a match
If $sName = $aCustomRules[$i][1] Or $sClassName = $aCustomRules[$i][1] Then
; determine if custom rule holds values else fallback to global value
If $aCustomRules[$i][10] Then $dBlurColor = $aCustomRules[$i][10]
If $aCustomRules[$i][11] Then $iBlurOpacity = $aCustomRules[$i][11]
If Not $aCustomRules[$i][10] Then $dBlurColor = $g_iBlurTintColor
If Not $aCustomRules[$i][11] Then $iBlurOpacity = $g_iBlurOpacity
; skip custom rules that are not Enabled
If Not $aCustomRules[$i][14] Then
If $g_iEnableBlurBehind Then _EnableBlur11($hWnd, $sName, $sClassName, $g_iBlurTintColor, $g_iBlurOpacity)
Return
EndIf
; blur behind, fallback to global if not set
If $aCustomRules[$i][9] = "True" Then _EnableBlur11($hWnd, $sName, $sClassName, $dBlurColor, $iBlurOpacity)
If $aCustomRules[$i][9] = "" Then
; only enable blur if not custom set
If $g_iEnableBlurBehind Then _EnableBlur11($hWnd, $sName, $sClassName, $g_iBlurTintColor, $g_iBlurOpacity)
EndIf
$bMatchesFound = True
EndIf
Next
; fallback to global when no custom rules match
If Not $bMatchesFound Then
If $g_iEnableBlurBehind Then _EnableBlur11($hWnd, $sName, $sClassName, $g_iBlurTintColor, $g_iBlurOpacity)
EndIf
EndFunc
Func _BlurOnlyInactive($hWnd, $sClassName, $sName)
Local $i
Local $bMatchesFound = False
Local $dBlurColor, $iBlurOpacity
; determine if process rule or class rule matches for custom rules
For $i = 0 To UBound($aCustomRules) - 1
; run through all of the custom process/class rules for a match
If $sName = $aCustomRules[$i][1] Or $sClassName = $aCustomRules[$i][1] Then
; determine if custom rule holds values else fallback to global value
If $aCustomRules[$i][12] Then $dBlurColor = $aCustomRules[$i][12]
If $aCustomRules[$i][13] Then $iBlurOpacity = $aCustomRules[$i][13]
If Not $aCustomRules[$i][12] Then $dBlurColor = $g_iBlurTintColorInact
If Not $aCustomRules[$i][13] Then $iBlurOpacity = $g_iBlurOpacityInact
; skip custom rules that are not Enabled
If Not $aCustomRules[$i][14] Then
If $g_iEnableBlurBehind Then _EnableBlur11($hWnd, $sName, $sClassName, $g_iBlurTintColorInact, $g_iBlurOpacityInact)
Return
EndIf
; blur behind, fallback to global if not set
If $aCustomRules[$i][9] = "True" Then _EnableBlur11($hWnd, $sName, $sClassName, $dBlurColor, $iBlurOpacity)
If $aCustomRules[$i][9] = "" Then
; only enable blur if not custom set
If $g_iEnableBlurBehind Then _EnableBlur11($hWnd, $sName, $sClassName, $g_iBlurTintColorInact, $g_iBlurOpacityInact)
EndIf
$bMatchesFound = True
EndIf
Next
; fallback to global when no custom rules match
If Not $bMatchesFound Then
If $g_iEnableBlurBehind Then _EnableBlur11($hWnd, $sName, $sClassName, $g_iBlurTintColorInact, $g_iBlurOpacityInact)
EndIf
EndFunc
Func _ColorBorderOnly($hWnd, $sClassName, $sName)
Local $bMatchesFound = False
For $i = 0 To UBound($aCustomRules) - 1
; run through all of the custom process/class rules for a match
If $sName = $aCustomRules[$i][1] Or $sClassName = $aCustomRules[$i][1] Then
$bMatchesFound = True
; skip custom rules that are not Enabled
If Not $aCustomRules[$i][14] Then
If $iBorderColorOptions = "1" Or $iBorderColorOptions = "0" Then
If $g_iBorderColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($g_iBorderColor))
EndIf
Return
EndIf
If $aCustomRules[$i][3] And $iBorderColorOptions = "0" Then
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($aCustomRules[$i][3]))
EndIf
If Not $aCustomRules[$i][3] And $g_iBorderColor And $iBorderColorOptions = "0" Then
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($g_iBorderColor))
EndIf
If Not $aCustomRules[$i][3] And Not $g_iBorderColor Then
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, $DWMWA_COLOR_DEFAULT)
EndIf
EndIf
Next
If Not $bMatchesFound Then
If $g_iBorderColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($g_iBorderColor))
If Not $g_iBorderColor Then __DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, $DWMWA_COLOR_DEFAULT)
EndIf
EndFunc
Func _DwmExtendFrameIntoClientArea($hWnd, $sName, $sClassName, $i)
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
; some slower programs need a 20ms delay to work consistently
; programs that have issues with double-overlapping window control buttons need margins of: 5000, 5000, 0, 0
If $sClassName = "CabinetWClass" Then
Sleep(20)
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
EndIf
; Visual Studio Handling
If $sName = 'devenv.exe' Then
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(5000, 5000, 0, 0))
;__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($dVSStudioBorderColor))
ElseIf $sName = 'VSCodium.exe' Then
Sleep(20)
;_WinAPI_DwmEnableBlurBehindWindow11($hWnd, 0) ; only needed for old vibrancy method
__DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, Int($dVSCodiumBackdrop))
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
ElseIf $sName = 'Code.exe' Then
Sleep(20)
;_WinAPI_DwmEnableBlurBehindWindow11($hWnd, 0) ; only needed for old vibrancy method
__DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, Int($dVSCodeBackdrop))
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
ElseIf $sClassName = "CASCADIA_HOSTING_WINDOW_CLASS" Then
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(5000, 5000, 0, 0))
If $aCustomRules[$i][3] Then __DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($aCustomRules[$i][3]))
Else
;_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
EndIf
EndFunc
Func _EnableBlur11($hWnd, $sName, $sClassName, $BlendColor = "", $ColorOpacity = "")
_WinAPI_DwmEnableBlurBehindWindow11($hWnd, $ACCENT_ENABLE_ACRYLICBLURBEHIND, True, $BlendColor, $ColorOpacity)
If $sClassName = 'CabinetWClass' Then
Sleep(20)
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
ElseIf $sName = 'devenv.exe' Then
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(5000, 5000, 0, 0))
ElseIf $sClassName = 'TaskManagerWindow' Then
Sleep(20)
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
ElseIf $sClassName = 'CASCADIA_HOSTING_WINDOW_CLASS' Then
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(5000, 5000, 0, 0))
Else
_WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
EndIf
EndFunc
Func _WinEventProc($hHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iEventThread, $imsEventTime)
Local Static $hWndLastReorder, $hWndLastNameChange, $hActiveWndLast
Local $sActiveWindow, $sName, $sClassName
Local $hTerminal, $hExplorer
Local $bMatchesFound = False
Switch $iEvent
Case $EVENT_OBJECT_SHOW
$sClassName = _WinAPI_GetClassName_mod($hWnd)
; exclude classnames from global exclusions
For $i = 0 To UBound($aExcludeClassNames) - 1
If $sClassName = $aExcludeClassNames[$i] Then Return
Next
; fix for Windows Terminal losing backdrop material when opening new tab tab
If $bWindowsTerminalHandling Then
If $sClassName = "PseudoConsoleWindow" Then
$hTerminal = WinGetHandle("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]")
If Not $bWindowsTerminalBlur Then __DwmSetWindowAttribute($hTerminal, $DWMWA_SYSTEMBACKDROP_TYPE, Int($dTerminalBackdrop))
__DwmSetWindowAttribute($hTerminal, $DWMWA_BORDER_COLOR, __SwitchColor($dTerminalBorderColor))
Sleep(20)
If Not $bWindowsTerminalBlur Then __DwmSetWindowAttribute($hTerminal, $DWMWA_SYSTEMBACKDROP_TYPE, Int($dTerminalBackdrop))
__DwmSetWindowAttribute($hTerminal, $DWMWA_BORDER_COLOR, __SwitchColor($dTerminalBorderColor))
Return
EndIf
EndIf
; exclude windows with blank title
$sActiveWindow = _WinAPI_GetWindowText_mod($hWnd)
If $sActiveWindow = "" Then Return
MainColoringFunction($hWnd, $sClassName)
Case $EVENT_SYSTEM_FOREGROUND
; this Case is mostly for handling border coloring and some special handling
; fix modern File Explorer losing client area backdrop material when losing focus
; fix modern File Explorer titlebar losing blur after gaining focus
If $bExplorerExtendClient And Not $bClassicExplorer Then
$hExplorer = WinGetHandle("[CLASS:CabinetWClass]")
If $hExplorer Then _WinAPI_DwmExtendFrameIntoClientArea_mod($hExplorer, _WinAPI_CreateMargins(-1, -1, -1, -1))
EndIf
$sActiveWindow = _WinAPI_GetWindowText_mod($hWnd)
; Visual Studio Handling
If $sActiveWindow = 'Microsoft Visual Studio' Then
Sleep(20)
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($dVSStudioBorderColor))
EndIf
; special handling for Windows Terminal backdrop
If $bWindowsTerminalHandling Then
$hTerminal = WinGetHandle("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]")
If $hTerminal Then
If Not $bWindowsTerminalBlur Then __DwmSetWindowAttribute($hTerminal, $DWMWA_SYSTEMBACKDROP_TYPE, Int($dTerminalBackdrop))
Sleep(20)
If Not $bWindowsTerminalBlur Then __DwmSetWindowAttribute($hTerminal, $DWMWA_SYSTEMBACKDROP_TYPE, Int($dTerminalBackdrop))
EndIf
EndIf
If $bIsAnyBlurEnabled Or $iBorderColorOptions = "0" Then
; border color, only color active window
$hActiveWnd = _WinAPI_GetForegroundWindow_mod()
If $hActiveWnd <> $hActiveWndLast Then
; exclude class names and process names from global exclusions
$sClassName = _WinAPI_GetClassName_mod($hActiveWndLast)
$sName = _WinAPI_GetWindowFileName_mod($hActiveWndLast)
For $i = 0 To UBound($aExclusionsCombined) -1
If $sName = $aExclusionsCombined[$i] Or $sClassName = $aExclusionsCombined[$i] Then $bMatchesFound = True
Next
; remove blend color
If Not $bMatchesFound Then
; need to switch to inactive blur func
;WinSetTrans($hActiveWndLast, "", 160)
;WinSetTrans($hActiveWndLast, "", 255)
If $bIsAnyBlurEnabled Then _BlurOnlyInactive($hActiveWndLast, $sClassName, $sName)
; remove border on inactive window
If $iBorderColorOptions = "0" Then __DwmSetWindowAttribute($hActiveWndLast, $DWMWA_BORDER_COLOR, $DWMWA_COLOR_NONE)
EndIf
$hActiveWndLast = $hActiveWnd
EndIf
EndIf
; exclude class names and process names from global exclusions
$sClassName = _WinAPI_GetClassName_mod($hWnd)
$sName = _WinAPI_GetWindowFileName_mod($hWnd)
If $sName = "" Then Return
For $i = 0 To UBound($aExclusionsCombined) -1
If $sName = $aExclusionsCombined[$i] Or $sClassName = $aExclusionsCombined[$i] Then Return
Next
; exclude windows with blank title
If $sActiveWindow = "" Then Return
If Not @Compiled And $sActiveWindow = "Immersive UX" Then $sName = "ImmersiveUX.exe"
If $bIsAnyBlurEnabled Then _BlurOnlyActive($hWnd, $sClassName, $sName)
_ColorBorderOnly($hWnd, $sClassName, $sName)
Case $EVENT_OBJECT_REORDER
; this Case is specifically for classic File Explorer when it loses Client Area coloring/backdrop when resizing
If Not $bExplorerExtendClient And Not $bClassicExplorer Then Return
; avoid applying coloring to duplicate hWnd in rapid succession
If $hWnd<>$hWndLastReorder Then
$sClassName = _WinAPI_GetClassName_mod($hWnd)
If $sClassName <> "CabinetWClass" Then $hWndLastReorder = $hWnd
ElseIf $hWnd=$hWndLastReorder Then
Return
EndIf
If $sClassName = "CabinetWClass" Then _WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
Case $EVENT_OBJECT_NAMECHANGE
; special handling for Windows Terminal backdrop (fixes Terminal losing backdrop when changing tabs)
If Not $bWindowsTerminalHandling Then Return
; avoid applying coloring to duplicate hWnd in rapid succession
If $hWnd<>$hWndLastNameChange Then
$sClassName = _WinAPI_GetClassName_mod($hWnd)
If $sClassName <> "CASCADIA_HOSTING_WINDOW_CLASS" Then $hWndLastNameChange = $hWnd
ElseIf $hWnd=$hWndLastNameChange Then
Return
EndIf
If $sClassName <> 'CASCADIA_HOSTING_WINDOW_CLASS' Then Return
If Not $bWindowsTerminalBlur Then __DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, Int($dTerminalBackdrop))
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($dTerminalBorderColor))
Sleep(20)
If Not $bWindowsTerminalBlur Then __DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, Int($dTerminalBackdrop))
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($dTerminalBorderColor))
Case $EVENT_SYSTEM_MINIMIZEEND
; special handling for Windows Terminal backdrop (fixes Terminal losing backdrop after minimize)
If Not $bWindowsTerminalHandling Then Return
$sClassName = _WinAPI_GetClassName_mod($hWnd)
If $sClassName <> 'CASCADIA_HOSTING_WINDOW_CLASS' Then Return
If Not $bWindowsTerminalBlur Then __DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, Int($dTerminalBackdrop))
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($dTerminalBorderColor))
Sleep(20)
If Not $bWindowsTerminalBlur Then __DwmSetWindowAttribute($hWnd, $DWMWA_SYSTEMBACKDROP_TYPE, Int($dTerminalBackdrop))
__DwmSetWindowAttribute($hWnd, $DWMWA_BORDER_COLOR, __SwitchColor($dTerminalBorderColor))
EndSwitch
EndFunc
Func _TaskSched_AlreadyInstalled()
If RunWait('schtasks.exe /Query /TN ' & $sProdName, '', @SW_HIDE) <> 0 Then Return 0
Return 1
EndFunc ;==>_TaskSched_AlreadyInstalled
Func _TaskSched_Run()
Local $sRun = 'schtasks.exe /Run /HRESULT /TN ' & $sProdName
RunWait($sRun, '', @SW_HIDE)
EndFunc ;==>_TaskSched_Run
; #FUNCTION# ====================================================================================================================
; Name ..........: _WinAPI_DwmEnableBlurBehindWindow11
; Description ...: Enables Aero-like blurred background in Windows 11.
; Syntax ........: _WinAPI_DwmEnableBlurBehindWindow11($hWnd[, $AccentState, $BlendColor, $ColorOpacity, $AccentFlags, $AnimationId])
; Parameters ....: $hWnd - Window handle
; $AccentState - [optional] Enable or disable the blur effect
; $IncludeCaption - [optional] Extend effects to the titlebar
; $BlendColor - [optional] Sets GradientColor
; $ColorOpacity - [optional] Sets blending color opacity value
; $AccentFlags - [optional] Sets AccentFlags value
; $AnimationId - [optional] Sets AnimationId value
; Return values .: 1 on success, 0 otherwise. Call _WinAPI_GetLastError on failure for more information.
; Author ........: scintilla4evr
; Modified ......: WildByDesign - added $AccentState, $BlendColor, $ColorOpacity, $AccentFlags and $AnimationId
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ACCENT_DISABLED = 0
; ACCENT_ENABLE_GRADIENT = 1
; ACCENT_ENABLE_TRANSPARENTGRADIENT = 2
; ACCENT_ENABLE_BLURBEHIND = 3
; ACCENT_ENABLE_ACRYLICBLURBEHIND = 4
; ACCENT_ENABLE_HOSTBACKDROP = 5
; ACCENT_INVALID_STATE = 6
; ===============================================================================================================================
Func _WinAPI_DwmEnableBlurBehindWindow11($hWnd, $AccentState = $ACCENT_ENABLE_ACRYLICBLURBEHIND, $IncludeCaption = True, $BlendColor = "", $ColorOpacity = "", $AccentFlags = 0, $AnimationId = 0)
If $AccentState And $IncludeCaption Then
Local $hRgn = _WinAPI_CreateEllipticRgn_mod(_WinAPI_CreateRectEx(0, 0, 0, 0))
_WinAPI_DwmEnableBlurBehindWindow_mod($hWnd, 1, 0, $hRgn)
If $hRgn Then _WinAPI_DeleteObject($hRgn)
EndIf
If Not $AccentState Then _WinAPI_DwmEnableBlurBehindWindow_mod($hWnd, 0)
Local $tAccentPolicy = DllStructCreate("int AccentState; int AccentFlags; int GradientColor; int AnimationId")
Local $tAttrData = DllStructCreate("dword Attribute; ptr DataBuffer; ulong Size")
$tAccentPolicy.AccentState = $AccentState
If $AccentState = $ACCENT_ENABLE_TRANSPARENTGRADIENT And $AccentFlags = 0 Then $AccentFlags = 2
$tAccentPolicy.AccentFlags = $AccentFlags
If $BlendColor Then
Local $iVal = Int($ColorOpacity > 99 ? 100 : ($ColorOpacity < 1 ? 0 : $ColorOpacity)) ; no more than 100% or less than 0%
Local $sTransparencyHex = Hex(Ceiling(($iVal * 100) * (2.55 * 100) / (100 * 100)), 2)
$tAccentPolicy.GradientColor = '0x' & $sTransparencyHex & Hex(__SwitchColor($BlendColor), 6)
EndIf
$tAccentPolicy.AnimationId = $AnimationId
$tAttrData.Attribute = $WCA_ACCENT_POLICY
$tAttrData.DataBuffer = DllStructGetPtr($tAccentPolicy)
$tAttrData.Size = DllStructGetSize($tAccentPolicy)
Local $aResult = DllCall($hUser32, "bool", "SetWindowCompositionAttribute", "hwnd", $hWnd, "ptr", DllStructGetPtr($tAttrData))
If @error Then Return SetError(@error, @extended, 0)
If $AccentState And $IncludeCaption Then _WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
If Not $AccentState And $IncludeCaption Then
Local $sClassName = _WinAPI_GetClassName_mod($hWnd)
If $sClassName <> "CabinetWClass" Then _WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(0, 0, 0, 0))
If $sClassName = "CabinetWClass" Then _WinAPI_DwmExtendFrameIntoClientArea_mod($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1))
EndIf
Return $aResult[0]
EndFunc ;==>_WinAPI_DwmEnableBlurBehindWindow11
Func _WinAPI_GetWindowText_mod($hWnd)
Local $aCall = DllCall($hUser32, "int", "GetWindowTextW", "hwnd", $hWnd, "wstr", "", "int", 4096)
If @error Or Not $aCall[0] Then Return ""
Return $aCall[2]
EndFunc ;==>_WinAPI_GetWindowText_mod
Func _WinAPI_SetWindowText_mod($hWnd, $sText)
Local $aCall = DllCall($hUser32, "bool", "SetWindowTextW", "hwnd", $hWnd, "wstr", $sText)
If @error Then Return SetError(@error, @extended, False)
Return $aCall[0]
EndFunc ;==>_WinAPI_SetWindowText_mod
Func idGUI()
Local $hActiveWin = _WinAPI_GetForegroundWindow_mod()
; only start GUI if not already running
If @Compiled Then
If $bBoot Then
;ShellExecute(@ScriptDir & "\" & $sProdName & ".exe", "hidegui", @ScriptDir, $SHEX_OPEN, @SW_HIDE)
RunLow("", @ScriptDir & "\" & $sProdName & ".exe" & " hidegui", @ScriptDir)
Return