Skip to content

Instantly share code, notes, and snippets.

@bp2008
Last active July 7, 2023 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bp2008/e2d89a5c6104c1e550492440c6c350bd to your computer and use it in GitHub Desktop.
Save bp2008/e2d89a5c6104c1e550492440c6c350bd to your computer and use it in GitHub Desktop.

Taskbar Dimmer Autohotkey Script

This Autohotkey script is intended to dim the taskbar when it is not needed in order to reduce the burn-in effect on OLED displays.

Source/Credit

This script originally came from: https://superuser.com/a/1691664

Original script from the link above:

SysGet, Monitor, Monitor                   ; Get monitor dimensions
SysGet, WorkArea, MonitorWorkArea          ; Get monitor work-area without taskbar
dimtop := % WorkAreaBottom + 1             ; taskbar is assumed to start below the work-area
Gui Color, 0,0                             ; Black color
Gui -Caption +ToolWindow +E0x20            ; No title bar, No taskbar button, Transparent for clicks
Gui Show, X0 Y%dimtop% W%MonitorRight% H63 ; Create a semi-transparent cover window
WinGet ID, ID, A                           ; Get its HWND/handle ID
Winset AlwaysOnTop,ON,ahk_id %ID%          ; Keep it always on the top
WinSet Transparent,99,ahk_id %ID%          ; Transparency 99/256
SetTimer, coverIt, 500                     ; Repeat setting it to be on top of the taskbar
return

coverIt:
    WinGet style, Style, A                 ; Get active window style and dimensions
    WinGetPos ,,,winW,winH, A
    ; 0x800000 is WS_BORDER.
    ; 0x20000000 is WS_MINIMIZE.
    ; check no border and not minimized
    isfull := ((style & 0x20800000) = 0 and winH >= A_ScreenHeight and winW >= A_ScreenWidth)
    if (isfull) {
        WinHide, ahk_id %ID%
    } else {
        WinShow, ahk_id %ID%
        Winset AlwaysOnTop,ON,ahk_id %ID%      ; Ensure it is still on the top
    }
    return

Usage

Save the script in a file called taskbardimmer.ahk and place it in C:\Users\USER-NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup so it will start automatically upon login.

My modifications

I have created a modified version of the script which:

  • Increases the darkening effect by changing the transparency from the default
  • Suppresses the darkening effect if "explorer.exe" owns the active window. Without this modification, there is a compatibility issue with Windows 11 and ExplorerPatcher where the taskbar is dimmed while you are actively using it.

Modified script

SysGet, Monitor, Monitor                   ; Get monitor dimensions
SysGet, WorkArea, MonitorWorkArea          ; Get monitor work-area without taskbar
dimtop := % WorkAreaBottom             ; taskbar is assumed to start below the work-area
Gui Color, 0,0                             ; Black color
Gui -Caption +ToolWindow +E0x20            ; No title bar, No taskbar button, Transparent for clicks
Gui Show, X0 Y%dimtop% W%MonitorRight% H63 ; Create a semi-transparent cover window
WinGet ID, ID, A                           ; Get its HWND/handle ID
Winset AlwaysOnTop,ON,ahk_id %ID%          ; Keep it always on the top
WinSet Transparent,179,ahk_id %ID%          ; Transparency 99/256
SetTimer, coverIt, 500                     ; Repeat setting it to be on top of the taskbar
return

coverIt:
    WinGet style, Style, A                 ; Get active window style and dimensions
    WinGet pName, ProcessName, A           ; Get active window process name
    WinGetPos ,,,winW,winH, A
    ; 0x800000 is WS_BORDER.
    ; 0x20000000 is WS_MINIMIZE.
    ; check no border and not minimized
    isfull := (((style & 0x20800000) = 0 and winH >= A_ScreenHeight and winW >= A_ScreenWidth) or pName == "explorer.exe")
    if (isfull) {
        WinHide, ahk_id %ID%
    } else {
        WinShow, ahk_id %ID%
        Winset AlwaysOnTop,ON,ahk_id %ID%      ; Ensure it is still on the top
    }
    return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment