Skip to content

SECLogics

Cybersecurity | Tech News | Engineering Solutions

Primary Menu
  • Home
  • Technology
  • Cybersecurity
  • Systems
  • DevOps
  • AWS
  • Azure
  • Virtualization
  • Networking
  • Home
  • 2026
  • April
  • 5
  • Auto HDR Switcher Script for Steam Games (PowerShell)
  • Systems

Auto HDR Switcher Script for Steam Games (PowerShell)

Editorial Team April 5, 2026 (Last updated: May 9, 2026) 3 minutes read

If you play some games with HDR and others without it, this PowerShell launcher helps automate the switch so you don’t have to toggle HDR manually every time.

What this script does

  • Toggles HDR ON before launching a Steam game
  • Waits until the game process exits
  • Toggles HDR back OFF after the game closes

PowerShell script (auto-detect Steam game, no GameID needed)

# Auto HDR Switcher for Steam (no GameID required)
# Watches for any Steam-launched game process and toggles HDR automatically.

param(
    [int]$PollSeconds = 2,
    [int]$PostLaunchGraceSeconds = 8
)

Add-Type @"
using System;
using System.Runtime.InteropServices;
public class KeySender {
    [DllImport("user32.dll", SetLastError=true)]
    public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
}
"@

$VK_LWIN = 0x5B
$VK_MENU = 0x12
$VK_B    = 0x42
$KEYEVENTF_KEYUP = 0x0002

function Invoke-HdrToggle {
    [KeySender]::keybd_event($VK_LWIN,0,0,[UIntPtr]::Zero)
    [KeySender]::keybd_event($VK_MENU,0,0,[UIntPtr]::Zero)
    [KeySender]::keybd_event($VK_B,0,0,[UIntPtr]::Zero)
    Start-Sleep -Milliseconds 120
    [KeySender]::keybd_event($VK_B,0,$KEYEVENTF_KEYUP,[UIntPtr]::Zero)
    [KeySender]::keybd_event($VK_MENU,0,$KEYEVENTF_KEYUP,[UIntPtr]::Zero)
    [KeySender]::keybd_event($VK_LWIN,0,$KEYEVENTF_KEYUP,[UIntPtr]::Zero)
}

function Get-SteamGameProcesses {
    # Steam.exe + gameoverlayui.exe are not game executables, so exclude them.
    # We use parent-child relation where parent is Steam or steamwebhelper.
    $all = Get-CimInstance Win32_Process
    $steamParents = $all | Where-Object { $_.Name -in @('steam.exe','steamwebhelper.exe') } | Select-Object -ExpandProperty ProcessId
    if (-not $steamParents) { return @() }

    $children = $all | Where-Object {
        $_.ParentProcessId -in $steamParents -and
        $_.Name -notin @('steam.exe','steamwebhelper.exe','gameoverlayui.exe')
    }

    return $children
}

Write-Host "Watching for Steam game process..."
$hdrOn = $false

while ($true) {
    $games = Get-SteamGameProcesses

    if ($games.Count -gt 0 -and -not $hdrOn) {
        Write-Host "Steam game detected: $($games[0].Name). Toggling HDR ON..."
        Invoke-HdrToggle
        $hdrOn = $true
        Start-Sleep -Seconds $PostLaunchGraceSeconds
    }

    if ($games.Count -eq 0 -and $hdrOn) {
        Write-Host "No Steam game running. Toggling HDR OFF..."
        Invoke-HdrToggle
        $hdrOn = $false
    }

    Start-Sleep -Seconds $PollSeconds
}

How to run in background

powershell -WindowStyle Hidden -ExecutionPolicy Bypass -File .\AutoHDR-Steam.ps1

This mode keeps running in the background and automatically handles HDR based on Steam game activity.

Tips

  • Use the real executable name from Task Manager for -GameProcessName.
  • If your game takes longer to start, increase -LaunchDelaySeconds.
  • Create one shortcut per game with its own Steam Game ID and process name.

Run it automatically in background (recommended)

To keep this truly automatic, run it through Task Scheduler or a startup shortcut so it launches silently when needed.

Task Scheduler example

# Program/script:
powershell.exe

# Add arguments:
-WindowStyle Hidden -ExecutionPolicy Bypass -File "C:\Scripts\AutoHDR-Steam.ps1"  1091500 -GameProcessName "Cyberpunk2077.exe"

This keeps the script in the background and preserves the original goal: HDR turns on before the game, then off automatically after exit.

Notes

  • This script relies on the Windows HDR keyboard shortcut (Win + Alt + B).
  • is most effective on single-monitor HDR setups; multi-monitor setups may need custom tuning.

Post navigation

Previous: Windows Security Triage Playbook with PowerShell (Step-by-Step)
Next: Most Useful Cybersecurity Commands in 2026 (Linux + Windows Incident Pack)

Recent Posts

  • Most Useful Cybersecurity Commands in 2026 (Linux + Windows Incident Pack)
  • Auto HDR Switcher Script for Steam Games (PowerShell)
  • Windows Security Triage Playbook with PowerShell (Step-by-Step)
  • 15 Windows Event IDs Every Security Admin Should Track
  • Hyper-V: Building a Small S2D Cluster (Practical Guide)

You May Have Missed

Most Useful Cybersecurity Commands in 2026 (Linux + Windows Incident Pack)
  • Cybersecurity
  • Systems

Most Useful Cybersecurity Commands in 2026 (Linux + Windows Incident Pack)

Editorial Team April 21, 2026
Auto HDR Switcher Script for Steam Games (PowerShell)
  • Systems

Auto HDR Switcher Script for Steam Games (PowerShell)

Editorial Team April 5, 2026
Windows Security Triage Playbook with PowerShell (Step-by-Step)
  • Cybersecurity
  • Systems

Windows Security Triage Playbook with PowerShell (Step-by-Step)

Editorial Team March 31, 2026
15 Windows Event IDs Every Security Admin Should Track
  • Cybersecurity
  • Systems

15 Windows Event IDs Every Security Admin Should Track

Editorial Team March 31, 2026
Copyright © 2026 All rights reserved. | ReviewNews by AF themes.
Share

Facebook

X

LinkedIn

WhatsApp

Copy Link
×