I need a way to capture the screen within a web application in any way possible. Is there such a way without installing other tools like SnagIt? Can I use Win32 DllImports within an ActiveX component and do it that way?
Thanks in advance!
Here is some code that will take a screen shoot of your silverlight app. and then you can send it or what ever :-)
Just create a silverlight project (with normal mainpage etc. and replace with this.
works in both 3.0 and 4.0 (havent tried 2.0 and lower)
Hope i helps Regards ReLoad
.CS
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Windows.Data; using System.Windows.Media.Imaging;
namespace SilverlightApplication1 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); }
private void UIelementShoot(object sender,
RoutedEventArgs e) { theImageToSend.Source = new WriteableBitmap(elementToCapture, null); }
private void ScreenShoot(object sender,
RoutedEventArgs e) { theImageToSend.Source = new WriteableBitmap(LayoutRoot, null); }
private void Button_Click(object sender,
RoutedEventArgs e) {
} } }
XAML:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SilverlightApplication1" x:Class="SilverlightApplication1.MainPage"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White" Width="400" Height="300" >
<Image x:Name="theImageToSend" Margin="191,56,44,103" d:LayoutOverrides="HorizontalAlignment"/>
<TextBox x:Name="elementToCapture" Margin="37,56,0,130" TextWrapping="Wrap" Text="TextBox" Width="124" HorizontalAlignment="Left" d:LayoutOverrides="Width"/>
<Button Content="Make ScreenShoot" HorizontalAlignment="Right" Margin="0,0,44,26" VerticalAlignment="Bottom" Width="139" Click="ScreenShoot"/>
<Button Content="Make TextBox Shoot" HorizontalAlignment="Left" Margin="61,0,0,26" VerticalAlignment="Bottom" Width="139" Click="UIelementShoot"/>
</Grid>
</UserControl>