Created
February 7, 2021 04:10
-
-
Save calvinbui/a4f325da40caaffaa2fcb465b4a8458d to your computer and use it in GitHub Desktop.
This file contains 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
param([switch]$Elevated) | |
function Test-Admin { | |
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent()) | |
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | |
} | |
$obsFolder = "C:\Program Files\obs-studio" | |
$windowedBorderlessFolder = "D:\Windowed Borderless" | |
$windowedBorderlessProcess = Get-Process -Name WindowedBorderlessGaming -ErrorAction SilentlyContinue | |
$obsProcess = Get-Process -Name obs64 -ErrorAction SilentlyContinue | |
# stop OBS and WBP if running | |
if ( $windowedBorderlessProcess -or $obsProcess ) { | |
if ((Test-Admin) -eq $false) { | |
if ($elevated) { | |
# tried to elevate, did not work, aborting | |
} else { | |
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition)) | |
} | |
} | |
$windowedBorderlessProcess | Stop-Process | |
$obsProcess | Stop-Process | |
exit | |
} | |
Start-Process -FilePath WindowedBorderlessGaming.exe -WorkingDirectory $windowedBorderlessFolder | |
Start-Process -FilePath "obs64.exe" -WorkingDirectory "$obsFolder\bin\64bit" | |
# open OBS Windowed Projector mode | |
Add-Type -path "$obsFolder\websocket\obs-websocket-dotnet.dll" | |
$obs = new-object OBSWebsocketDotNet.OBSWebsocket | |
$obs.Connect("ws://127.0.0.1:4444", "") | |
$obs.SendRequest("OpenProjector") | |
$obs.Disconnect() | |
# bring Windowed Projector into focus | |
$wshell = New-Object -ComObject wscript.shell | |
$wshell.AppActivate('Windowed Projector (Preview)') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment