# Import the required Win32 DLLs Add-Type -TypeDefinition @" using System; using System.Runtime.InteropServices; public class WindowSwitcher { [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr hWnd); } "@ # Function to switch to the next window function SwitchToNextWindow { $currentWindow = [WindowSwitcher]::GetForegroundWindow() $nextWindow = (Get-Process | Where-Object { $_.MainWindowHandle -ne [IntPtr]::Zero -and $_.MainWindowHandle -ne $currentWindow }).MainWindowHandle if ($nextWindow) { [WindowSwitcher]::SetForegroundWindow($nextWindow) } } # Loop to continuously switch between windows every 2 minutes while ($true) { SwitchToNextWindow Start-Sleep -Minutes 2 # Wait for 2 minutes before switching to the next window }