Skip to content

Instantly share code, notes, and snippets.

@ahorn42
Last active August 31, 2023 07:14
Show Gist options
  • Save ahorn42/505cae6edcd9657ed6f02ee7508a0995 to your computer and use it in GitHub Desktop.
Save ahorn42/505cae6edcd9657ed6f02ee7508a0995 to your computer and use it in GitHub Desktop.
A small powershell script to allow to record and play back a part of your screen with VLC to allow partial screen sharing in communication tools like Teams.
function Share-PartialScreen {
[CmdletBinding(DefaultParameterSetName='Preset')]
Param(
[Parameter(Mandatory = $false)]
[string] $preset,
[Parameter(Mandatory = $false)]
[int] $Width = 1920,
[Parameter(Mandatory = $false)]
[int] $Height = 1080
)
switch ($preset) {
"720p" {
$Width = 1280
$Height = 720
}
"1080p" {
$Width = 1920
$Height = 1080
}
}
$id = Start-Process -FilePath "C:\Program Files\VideoLAN\VLC\vlc.exe" -ArgumentList "screen:// --screen-fps=30 --live-caching=300 --screen-width=$Width --screen-height=$Height --no-embedded-video --no-video-deco --qt-start-minimized" -PassThru
[reflection.assembly]::LoadWithPartialName( "System.Windows.Forms")
[reflection.assembly]::LoadWithPartialName( "System.Drawing")
$pen = New-Object Drawing.Pen red
$brushRed = New-Object Drawing.SolidBrush red
$brushWhite = New-Object Drawing.SolidBrush white
$font = New-Object Drawing.Font "Arial", 14
$form = New-Object Windows.Forms.Form
$form.TransparencyKey = $form.BackColor
$form.WindowState = 'Maximized'
$form.FormBorderStyle = 'None'
$form.TopMost = $true
$formGraphics = $form.createGraphics()
$form.add_paint(
{
$formGraphics.DrawRectangle($pen, 0, 0, $Width + 1, $Height + 1)
$formGraphics.FillRectangle($brushRed, $Width + 1, 0, 60, 30)
$formGraphics.DrawString("close", $font, $brushWhite, $Width + 5, 3)
}
)
$form.Add_Click({$form.Close()})
$form.ShowDialog() # display the dialog
Stop-Process $id
}
@FonzTech
Copy link

You can add --screen-left and --screen-top to VLC start command to record your screen with an offset. But you have also translate "Paint" operations to that offset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment