Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion guest_server/install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set INSTALL_DIR=C:\Program Files\WinBoat
set EXE_PATH=%INSTALL_DIR%\winboat_guest_server.exe
set TIME_SYNC_SCRIPT_PATH=%INSTALL_DIR%\scripts\time-sync.bat
set NOTIFICATIONS_SCRIPT_PATH=%INSTALL_DIR%\scripts\notifications_cleanup.ps1
set NSSM_PATH=%INSTALL_DIR%\nssm.exe
set OEM_DIR=C:\OEM

Expand All @@ -28,4 +29,5 @@ netsh advfirewall firewall add rule name="Allow WinBoat API 7148" dir=in action=
"%NSSM_PATH%" start WinBoatGuestServer

:: Startup Tasks
schtasks /create /tn "TimeSyncTask" /sc ONSTART /RL HIGHEST /tr "\"%TIME_SYNC_SCRIPT_PATH%\"" /RU SYSTEM
schtasks /create /tn "TimeSyncTask" /sc ONSTART /RL HIGHEST /tr "\"%TIME_SYNC_SCRIPT_PATH%\"" /RU SYSTEM
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "NotificationCleanup" /t REG_SZ /d "conhost --headless powershell.exe -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File \"%NOTIFICATIONS_SCRIPT_PATH%\"" /f
64 changes: 64 additions & 0 deletions guest_server/scripts/notifications_cleanup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
if (-not (Get-WmiObject Win32_OperatingSystem).Caption -Match "Windows 11") {
exit
}

Add-Type @"
using System;
using System.Runtime.InteropServices;

public class Win32 {
[StructLayout(LayoutKind.Sequential)]
public struct RECT {
public int Left;
public int Top;
public int Right;
public int Bottom;
}

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
}
"@

$hwnd_progman = [Win32]::FindWindow("Progman", "Program Manager")
$hwnd_shell = [Win32]::FindWindowEx($hwnd_progman, [IntPtr]::Zero, "SHELLDLL_DefView", $null)

if ($hwnd_shell -ne [IntPtr]::Zero) {
exit
}

$className = "Windows.UI.Core.CoreWindow"
$caption = "New notification"

$prev = 0;

while ($true) {
$hwnd = [Win32]::FindWindow($className, $caption)

if ($hwnd -eq [IntPtr]::Zero) {
Start-Sleep -Milliseconds 100
continue
}

$rect = New-Object Win32+RECT

if ([Win32]::GetWindowRect($hwnd, [ref]$rect)) {
$width = $rect.Right - $rect.Left
$height = $rect.Bottom - $rect.Top

if ($height -eq 0 -and $prev -ne 0) {
Stop-Process -Name "ShellExperienceHost" -Force
}

$prev = $height;
}

Start-Sleep -Milliseconds 100
}