Windows Desktop Screenshot Monitoring

From Steak Wiki
Revision as of 04:19, 4 February 2020 by Adminguy (talk | contribs) (Created page with "Here are notes on setting up a screen capture / recording / desktop streaming for Windows 10 (02/2020). ==Easy Solution (non Win10)== In Windows 7 (I think) you can simply us...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Here are notes on setting up a screen capture / recording / desktop streaming for Windows 10 (02/2020).

Easy Solution (non Win10)

In Windows 7 (I think) you can simply use VLC from the command line.

"C:\Program Files\VideoLAN\VLC\vlc.exe" -I --dummy-quiet screen://  --screen-fps=3   :sout=#transcode{vcodec=MJPG,venc=ffmpeg{qmin=0,qmax=10},vb=800,width=320, height=240,acodec=none}:http{mux=mpjpeg,dst=:8088} :sout-keep

This was tested to work in 2008 server. (NOTE: Doesn't work in win10, without opening a video screen. see below.)

NOTE: make sure to open port in firewall.

test first in localhost on server.

then test remotely.

firewall needs port opened for remote access.


testing VLC 3.0.8 (64 bit windows) now... by default, 3.0.8 opens up a GUI. obnoxious.

from stckexchange

You can use this:

vlc -I dummy --dummy-quiet {path_to_file}

As per @MC10's answer, the -intf dummy or -I dummy (they do the same thing) hides the GUI but still opens a second command line window. Use the additional --dummy-quiet option to hide this window too. 

but that doesn't fucking work

Looks like it's a windows 10 problem.

It worked on 2008

Let's look at other options.

https://github.com/aviloria/ScreenCaptureServer/releases
https://github.com/rdp/screen-capture-recorder-to-video-windows-free

this just looks like a mess. popular, though. doesn't mean anything.

Manual JPEG screen capture and server over HTTP

After all that, I decided the best solution is to do this manually. Almost future proof.

Some apache server, with a program that just takes screenshots and puts them in the local dir.

Then Zoneminder, Blueiris, etc... server reads the jpg file. that would work... forever.

trying xampp EDIT: i only need apache, so nix xampp, go with just apache on win. you have to use 3rd party builds, as they don't make binaries. and autoscreen (sourceforge) av gives warnings on autoscreen.

but its bs

it doesn't really work because, it saves to a new file all the time. I could manually fix it but nope.

Powershell Get Screenshot

let's try this:

[Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 
function screenshot($path) 
{
    $width = 0;
    $height = 0;
    $workingAreaX = 0;
    $workingAreaY = 0;

    $screen = [System.Windows.Forms.Screen]::AllScreens;

    foreach ($item in $screen)
    {
        if($workingAreaX -gt $item.WorkingArea.X)
        {
            $workingAreaX = $item.WorkingArea.X;
        }

        if($workingAreaY -gt $item.WorkingArea.Y)
        {
            $workingAreaY = $item.WorkingArea.Y;
        }

        $width = $width + $item.Bounds.Width;

        if($item.Bounds.Height -gt $height)
        {
            $height = $item.Bounds.Height;
        }
    }

    $bounds = [Drawing.Rectangle]::FromLTRB($workingAreaX, $workingAreaY, $width, $height); 
    $bmp = New-Object Drawing.Bitmap $width, $height;
    $graphics = [Drawing.Graphics]::FromImage($bmp);

    $graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size);

    $bmp.Save($path);

    $graphics.Dispose();
    $bmp.Dispose();
}

Can be called with: screenshot "D:\screenshot.png"

you need to allow scripts, so:

explains it well

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force

this is a few more steps than 7 used to have. scope and force is new. fun.

can't figure out that one.

trying this:

[Reflection.Assembly]::LoadWithPartialName("System.Drawing")
function screenshot([Drawing.Rectangle]$bounds, $path) {
   $bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
   $graphics = [Drawing.Graphics]::FromImage($bmp)

   $graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)

   $bmp.Save($path)

   $graphics.Dispose()
   $bmp.Dispose()
}

$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, 1000, 900)
screenshot $bounds "C:\screenshot.png"

may have to write somewhere other than c: which often doesn't have write permissions anymore.

that didn't work trying a different one...

[cmdletbinding()]            
param(            
  [string]$Width,            
  [string]$Height,            
  [String]$FileName = "Screenshot"  ,
  [string]$path2 = "c:\ProgramData\Apache\"          

)            
#requires making the apache folder. This is just my personal preference.

#Function to take screenshot. This function takes the width and height of the screen that # #has            
#to be captured            

function Take-Screenshot{            
[cmdletbinding()]            
param(            
 [Drawing.Rectangle]$bounds,             
 [string]$path            
)             
   $bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height            
   $graphics = [Drawing.Graphics]::FromImage($bmp)            
   $graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)            
   $bmp.Save($path)            
   $graphics.Dispose()            
   $bmp.Dispose()            
}            

#Function to get the primary monitor resolution.            
#This code is sourced from             
# https://techibee.com/powershell/powershell-script-to-get-desktop-screen-resolution/1615            


function Get-ScreenResolution {            
 $Screens = [system.windows.forms.screen]::AllScreens                        
 foreach ($Screen in $Screens) {            
  $DeviceName = $Screen.DeviceName            
  $Width  = $Screen.Bounds.Width            
  $Height  = $Screen.Bounds.Height            
  $IsPrimary = $Screen.Primary                        
  $OutputObj = New-Object -TypeName PSobject            
  $OutputObj | Add-Member -MemberType NoteProperty -Name DeviceName -Value $DeviceName            
  $OutputObj | Add-Member -MemberType NoteProperty -Name Width -Value $Width            
  $OutputObj | Add-Member -MemberType NoteProperty -Name Height -Value $Height            
  $OutputObj | Add-Member -MemberType NoteProperty -Name IsPrimaryMonitor -Value $IsPrimary            
  $OutputObj                        
 }            
}            

#Main script begins            

#By default captured screenshot will be saved in %temp% folder            
#You can override it here if you want  
#orig          
#$Filepath = join-path $env:temp $FileName 
#edit
$Filepath = join-path $path2 $FileName           

[void] [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")            
[void] [Reflection.Assembly]::LoadWithPartialName("System.Drawing")            

if(!($width -and $height)) {            

 $screen = Get-ScreenResolution | ? {$_.IsPrimaryMonitor -eq $true}            
 $Width = $screen.Width            
 $Height = $screen.height            
}            

$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, $Screen.Width, $Screen.Height)            

Take-Screenshot -Bounds $bounds -Path "$Filepath.png"            
#Now you have the screenshot

from: https://techibee.com/powershell/powershell-script-to-take-a-screenshot-of-your-desktop/1626

that works. OK

now to schedule it.


A Windows Task Scheduler trigger cannot repeat more often than every 1 minute, but you can set up multiple triggers. To run a task every 10 seconds, add six Triggers. Each one should run the task Daily, and Repeat task every 1 minute. Their start times should be 12:00:00 AM, 12:00:10 AM, 12:00:20 AM, 12:00:30 AM, 12:00:40 AM, and 12:00:50 AM.

from: https://superuser.com/questions/293445/windows-task-scheduler-schedule-task-to-run-once-every-10-seconds not so bad

then just to serve the file on the web

need to decipher apache on win

https://serverfault.com/questions/320288/how-can-i-easily-password-protect-a-site-in-apache-windows looks like i have to generate an htaccess file

i'll do this on a unix machine. i don't trust the websites that you can enter passwords in that's bad practice

do it on linux then copy over the htaccess file.

todo: finish apache setup