Last active
December 17, 2025 03:52
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can make a
vbsfile like this above and place it inshell:startupto have this script run in the background on startup.