Skip to content

OLED Display AutoHotkey Script for Automatically Dimming the Taskbar

If you have an OLED PC that you use for work, don't want burn-in but don't want to hide the taskbar either, here's a solution.

Goal

  1. Auto-dim the taskbar to prevent burn in.
  2. Keep the dimming when an app is opened in full-screen on a second monitor.
  3. Stop the dimming if an app is opened full-screen on the primary monitor.

Sources

Script

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

GetCurrentMonitor()
{
  SysGet, numberOfMonitors, MonitorCount
  WinGetPos, winX, winY, winWidth, winHeight, A
  winMidX := winX + winWidth / 2
  winMidY := winY + winHeight / 2
  Loop %numberOfMonitors%
  {
    SysGet, monArea, Monitor, %A_Index%
    if (winMidX > monAreaLeft && winMidX < monAreaRight && winMidY < monAreaBottom && winMidY > monAreaTop)
      return A_Index
  }
  SysGet, primaryMonitor, MonitorPrimary
  return "No Monitor Found"
}

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)
    isPrimaryMonitor := (GetCurrentMonitor() = 1)
    if (isfull and isPrimaryMonitor) {
        WinHide, ahk_id %ID%
    } else {
        WinShow, ahk_id %ID%
        Winset AlwaysOnTop,ON,ahk_id %ID%      ; Ensure it is still on the top
    }
    return

Comments