Skip to content

Instantly share code, notes, and snippets.

Created July 13, 2020 19:03
What would you like to do?
[Int32]$attempts = 3,
[Int32]$sleep = 10,
[bool]$keepAlive = $false
try {
$Win32ShowWindowAsync = Add-Type -MemberDefinition @"
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"@ -name "Win32ShowWindowAsync" -Namespace Win32Functions -PassThru
} catch {}
Write-Output "Hiding GoXLR Windows...";
while (($attempts -gt 0) -or ($keepAlive -eq $true)) {
# Get All GoXLR Desktop processes and find one with a window handle
(Get-Process -Name "GOXLR APP*").MainWindowHandle | ForEach-Object {
if($_ -eq 0) { return; } # We can ignore processes spun up that have no window
Write-Output "Found a GoXLR Window... Closing it now.";
# We'll Hide the window through its handle
$Win32ShowWindowAsync::ShowWindowAsync($_, 0) | Out-Null
Write-Output "Attempts remaining: $attempts, sleeping for $sleep, keep alive: $keepAlive"
if($keepAlive -eq $false) {
Start-Sleep -Seconds $sleep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment