How to render a powershell WPF GUI to a video file

This topic contains 2 replies, has 2 voices, and was last updated by  Anonymous 4 years, 5 months ago.

  • Author
    Posts
  • #7835

    Anonymous

    I need help trying to output a WPF GUI window to a rendered video (mp4) via Powershell. i assume the last line is what will need to be modified to output to the video instead of the GUI. i assume the video parameters will need to be added somewhere but im not sure what is needed yet. i guestimate the video will be 15 or 30 seconds long. I am ok if this is done with ShowUI as well. Ive been searching for days and i cannot find anything related. Thank you for the help!

     

     

    Here is the code below:

    #JLo #Concept: turn rss and other realtime feeds info into animated videos Add-Type-AssemblyName presentationframework
    cls
    
    [xml]$XAML =@"
    http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow"Height="720"Width="1280"Background="White">< Grid>< Label x:Name="TopLabel"HorizontalAlignment="Left"VerticalAlignment="Top"Height="360"Width="1280">< Image x:Name="logo"Height="350"Width="1270"Source="http://www.johnjlopez.com/jlo.jpg"/>Label>< Label x:Name="BottomLeft"Content="Label"HorizontalAlignment="Left"Margin="0,365,0,0"VerticalAlignment="Top"Height="325"Width="635"Background="#FF84C5C9"Foreground="White"FontSize="18"/>< Label x:Name="BottomRight"Content="Label"HorizontalAlignment="Left"Margin="645,365,0,0"VerticalAlignment="Top"Height="325"Width="635"Background="white"Foreground="black"FontSize="18"/>Grid>Window>"@
    
    $reader=(New-Object System.Xml.XmlNodeReader $xaml)
    $Window=[Windows.Markup.XamlReader]::Load( $reader )
    
    # NEWSFEED
    $url = "http://feeds.chicagotribune.com/chicagotribune/news/" 
    $array =Invoke-RestMethod $url #| Select Title | Format-Table -AutoSize[string]$a  ="NEWS`n-------`n"
    $BottomLeft = $Window.findname("BottomLeft")
    $a         +=  $($array |%{$_.title})-join "`n"
    $BottomLeft.Content= $a
    
    #WEATHER FEED#Based from: #http://gallery.technet.microsoft.com/scriptcenter/PowerShell-Console-Weather-430a2eb7#http://jdhitsolutions.com/blog/2010/07/powershell-weather-module/FunctionGet-YahooWeather{[cmdletbinding()]Param([parameter(ValueFromPipeLine='True')][string[]]$ZipCode ="60625")Begin{
            $Webclient =New-ObjectNet.WebClient
            $Webclient.UseDefaultCredentials= $True
        }Process{ForEach($Zip in $ZipCode){Try{    
                    $weather =([xml]$webclient.DownloadString("http://weather.yahooapis.com/forecastrss?p=$Zip")).rss.Channel
                    $weatherhash =@{Sunrise= $weather.astronomy.SunriseSunset= $weather.astronomy.SunsetTemperature="{0}{1}F"-f $weather.Item.Condition.Temp,[char]176Conditions= $weather.Item.Condition.TextCity= $weather.Location.CityState= $weather.Location.RegionCountry= $weather.Location.CountryWindChill= $weather.Wind.ChillWindSpeed= $weather.Wind.SpeedLastUpdated=[datetime]"$(($weather.LastBuildDate | Select-String -pattern "\w+,\s\d{1,2}\s\w+\s\d{4}\s\d{1,2}:\d{1,2}\s\w{2}").matches[0].value)"HiTemp="{0}{1}F"-f $Weather.item.forecast[0].High,[char]176LowTemp="{0}{1}F"-f $Weather.item.forecast[0].Low,[char]176}
                    $weatherobject =New-ObjectPSObject-Property $weatherhash
                    $weatherobject.PSTypeNames.Insert(0,"Weather.Info")Write-Output $weatherobject
                    }Catch{Write-Warning"$($Error[0])"}}}}
    $weather =get-yahooweather 60601[string]$B              ="WEATHER`n-----------`n"
    $b             += $weather|selectCity,Temperature,HiTemp,LowTemp,WindChill,Sunset,Conditions|Out-string#-join "`n"
    $Bottomright            = $Window.findname("BottomRight")
    $Bottomright.Content= $b
    
    $Window.ShowDialog()|out-null
    
    This is also posted at:
    http://stackoverflow.com/questions/17283616/how-to-render-a-powershell-wpf-gui-to-a-video-file
    
    
    
  • #7839

    Don Jones
    Keymaster

    You might want to attach that instead of trying to paste it... but in general you're probably going to get more love on StackOverflow in terms of an answer. WPF is accessible from PowerShell, but it's not really PowerShell itself. You'll probably find less knowledge about WPF here, unfortunately.

  • #7840

    Anonymous

    I cant find any buttons to edit the original post.If you want, feel free to delete the entire code section. it will still be in the stack overflow post.

    Ive searched the net for awhile to find an answer and i haven't found it yet. I've also reached out to Doug Finke who recommended I post in both these forums. The hard part of all this is exactly what you said – its a combo of both powershell and WPF.

    Thanks again,

You must be logged in to reply to this topic.