Forum Discussion
Sharing part of the screen
- Apr 28, 2021Seem to be not possible at the moment, but heavily requested by user voices: https://microsoftteams.uservoice.com/forums/555103-public/suggestions/38834104-share-custom-area-of-screen
I have created a little work around for me, by letting VLC capture a part of my screen. This captured video is played back in a borderless VLC window which I use to share via Teams (or similar tools).
I put all things together as an powershell script which I installed into my powershell profile so I can easily start (partial) sharing from a powershell by typing
Share-PartialScreen
The script does the following:
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
}
Be warned that this leads to flickering sometimes, in the recorded area, as you constantly record the area again, but this disappears if you place a window over this area.
Of course VLC is necessary for this, but additionally I can recommend the tool http://www.brianapps.net/sizer/ that allows to set a windows to a specific size easily, so you don't need to fiddle a long time till a window matches the shared area.
I hope some of you enjoy this work around 😊
Fell free to follow the gist on https://gist.github.com/ahorn42/505cae6edcd9657ed6f02ee7508a0995 in case I extend this script.