Skip to content

Instantly share code, notes, and snippets.

@zydezu
Last active December 17, 2025 03:52
Show Gist options
  • Select an option

  • Save zydezu/0d2f10d57910eb286ce31d868731a3a1 to your computer and use it in GitHub Desktop.

Select an option

Save zydezu/0d2f10d57910eb286ce31d868731a3a1 to your computer and use it in GitHub Desktop.
Convert jxr (HDR) screenshots saved by GameBar to HDR pngs, copying them to the clipboard, ready for sharing. Uses https://github.com/ledoge/jxr_to_png. Use Windows + Alt + PrtScn to save a screenshot using GameBar.
# Uses jxr_to_png.exe from https://github.com/ledoge/jxr_to_png
Add-Type -AssemblyName PresentationCore
Add-Type -AssemblyName WindowsBase
Add-Type -AssemblyName System.Windows.Forms
function Copy-FileToClipboard {
param([string]$filePath)
$files = New-Object System.Collections.Specialized.StringCollection
$files.Add($filePath)
[System.Windows.Forms.Clipboard]::SetFileDropList($files)
}
$watchFolder = "C:\Users\User\Videos\Captures"
$outputFolder = Join-Path $watchFolder "hdr"
# Create output folder
if (-not (Test-Path $outputFolder)) {
New-Item -ItemType Directory -Path $outputFolder | Out-Null
}
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = $watchFolder
$watcher.Filter = "*.jxr"
$watcher.NotifyFilter = [System.IO.NotifyFilters]'FileName, LastWrite'
$watcher.EnableRaisingEvents = $true
$action = {
param($source, $eventArgs)
$jxrFile = $eventArgs.FullPath
if (-not (Test-Path $jxrFile)) { return }
# Wait until file is fully written
while ($true) {
try {
$s = [System.IO.File]::Open($jxrFile,'Open','Read','None')
$s.Close()
break
} catch {
Start-Sleep -Milliseconds 300
}
}
$outputFolder = Join-Path (Split-Path $jxrFile -Parent) "hdr"
if (-not (Test-Path $outputFolder)) {
New-Item -ItemType Directory -Path $outputFolder | Out-Null
}
$pngName = [System.IO.Path]::GetFileNameWithoutExtension($jxrFile) + ".png"
$pngFile = Join-Path $outputFolder $pngName
Write-Host "Converting:"
Write-Host " $jxrFile"
Write-Host " -> $pngFile"
$proc = Start-Process `
-FilePath "C:\Users\User\Videos\Captures\jxr_to_png.exe" `
-ArgumentList "`"$jxrFile`" `"$pngFile`"" `
-Wait `
-PassThru `
-NoNewWindow
if ($proc.ExitCode -eq 0 -and (Test-Path $pngFile)) {
# Delete original files
Remove-Item $jxrFile -Force
Remove-Item $pngName -Force
Write-Host "Conversion done."
# Copy PNG file path to clipboard
Copy-FileToClipboard $pngFile
Write-Host "PNG file copied to clipboard as a file reference."
} else {
Write-Host "Conversion failed!"
}
}
Register-ObjectEvent $watcher Created -Action $action
Register-ObjectEvent $watcher Renamed -Action $action
Write-Host "Watching $watchFolder for .jxr files..."
while ($true) { Start-Sleep 1 }
@zydezu
Copy link
Author

zydezu commented Dec 17, 2025

Set objShell = CreateObject("Wscript.Shell")
objShell.Run "powershell.exe -NoProfile -ExecutionPolicy Bypass -File ""C:\Users\User\Videos\Captures\watchjxr.ps1""", 0, False

You can make a vbs file like this above and place it in shell:startup to have this script run in the background on startup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment