fix(ci): stabilize Windows tray screenshots (#173)

This commit is contained in:
Dave Lane authored and GitHub committed 2026-07-29 20:30:27 -04:00
1 parent 40790a59f3
commit 46b469ff84
1 file changed
+23 -9
@@ -13,16 +13,28 @@ runs:
Invoke-WebRequest ` Invoke-WebRequest `
-Uri "https://raw.githubusercontent.com/paulmann/windows-show-all-tray-icons/main/Enable-AllTrayIcons.ps1" ` -Uri "https://raw.githubusercontent.com/paulmann/windows-show-all-tray-icons/main/Enable-AllTrayIcons.ps1" `
-OutFile $trayIconScript -OutFile $trayIconScript
& $trayIconScript -Action Enable -Force & $trayIconScript -Action Enable -RestartExplorer -Force
echo "::endgroup::"
echo "::group::Disable Do Not Disturb" Add-Type @"
Add-Type -AssemblyName System.Windows.Forms using System;
Start-Process "ms-settings:notifications" using System.Runtime.InteropServices;
Start-Sleep -Seconds 2
[System.Windows.Forms.SendKeys]::SendWait("{TAB}") public static class WindowsShell {
[System.Windows.Forms.SendKeys]::SendWait("{TAB}") [DllImport("user32.dll", CharSet = CharSet.Unicode)]
[System.Windows.Forms.SendKeys]::SendWait(" ") public static extern IntPtr FindWindow(string className, string windowName);
}
"@
$taskbarDeadline = (Get-Date).AddSeconds(15)
do {
$taskbarHandle = [WindowsShell]::FindWindow("Shell_TrayWnd", $null)
if ($taskbarHandle -ne [IntPtr]::Zero) {
break
}
Start-Sleep -Milliseconds 250
} while ((Get-Date) -lt $taskbarDeadline)
if ($taskbarHandle -eq [IntPtr]::Zero) {
throw "Windows taskbar did not become ready after restarting Explorer"
}
echo "::endgroup::" echo "::endgroup::"
echo "::group::Minimize all windows" echo "::group::Minimize all windows"
@@ -30,6 +42,8 @@ runs:
$shell.MinimizeAll() $shell.MinimizeAll()
echo "::endgroup::" echo "::endgroup::"
# Avoid opening ms-settings here. On Windows 11 ARM64 hosted runners,
# the first Settings URI can open the privacy OOBE over every screenshot.
echo "::group::Set Date - Hack for Quiet Time" echo "::group::Set Date - Hack for Quiet Time"
$newDate = (Get-Date).AddHours(2) $newDate = (Get-Date).AddHours(2)
Set-Date -Date $newDate Set-Date -Date $newDate