Skip to content

Instantly share code, notes, and snippets.

@Aetopia
Created December 28, 2022 03:50
Show Gist options
  • Save Aetopia/2267ffaa08f078983c1c0398d0786772 to your computer and use it in GitHub Desktop.
Save Aetopia/2267ffaa08f078983c1c0398d0786772 to your computer and use it in GitHub Desktop.
DWMCFG
import winim
import os
const
tsz = 4
fsz = 0
let cmdline = commandLineParams()
var
t = true
f = false
DWMWA_USE_IMMERSIVE_DARK_MODE = 20
osvi: OSVERSIONINFO
msg: MSG
GetVersionEx(&osvi)
if (osvi.dwBuildNumber >= 17763):
DWMWA_USE_IMMERSIVE_DARK_MODE = 19
proc dwmSetCfg(hwnd: HWND, cfg: string) =
case cfg:
of "disable":
for i in [DWMWA_NCRENDERING_POLICY, DWMWA_TRANSITIONS_FORCEDISABLED, DWMWA_FORCE_ICONIC_REPRESENTATION, DWMWA_DISALLOW_PEEK]:
DwmSetWindowAttribute(hwnd, i.DWORD, &t, tsz)
proc winEventProc(hWinEventHook: HWINEVENTHOOK, event: DWORD, hwnd: HWND, idObject: LONG, idChild: LONG, idEventThread: DWORD, dwmsEventTime: DWORD): VOID {.stdcall.} =
if (event != EVENT_OBJECT_CREATE): return
if (idObject != OBJID_WINDOW or idChild != CHILDID_SELF): return
dwmSetCfg(hwnd, "disable")
proc enumChildWindowsProc(hwnd: HWND, lParam: LPARAM): WINBOOL {.stdcall.} =
dwmSetCfg(hwnd, "disable")
return true
proc enumWindowsProc(hwnd: HWND, lParam: LPARAM): WINBOOL {.stdcall.}=
dwmSetCfg(hwnd, "disable")
EnumChildWindows(hwnd, enumChildWindowsProc, 0)
return true
if isMainModule:
EnumWindows(enumWindowsProc, 0)
SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE, 0, winEventProc, 0, 0, WINEVENT_OUTOFCONTEXT)
while GetMessage(&msg, 0, 0, 0):
TranslateMessage(&msg)
DispatchMessage(&msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment