Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create a Screen Recorder.
#1
This Basic tutorial will show you how to make a simple screen recorder.


Step 1.

-Create a new Windows ApplicationPublic Class ScreenRecorder


Step 2.

-Add a reference to System.Drawing.dll, and System.Windows.Forms.dll

Use this code;

Code:
Public Class ScreenRecorder

    Private Shared tempDir As String = My.Computer.FileSystem.SpecialDirectories.Temp & "\snapshot\"
    Private Shared snap As New System.Threading.Thread(AddressOf Snapshot)
    Private Shared _Bounds As System.Drawing.Rectangle = System.Windows.Forms.Screen.PrimaryScreen.Bounds
    Public Shared Property Bounds() As System.Drawing.Rectangle
        Get
            Return _Bounds
        End Get
        Set(ByVal value As System.Drawing.Rectangle)
            _Bounds = value
        End Set
    End Property
    Private Shared Sub Snapshot()
        If Not My.Computer.FileSystem.DirectoryExists(tempDir) Then _
            My.Computer.FileSystem.CreateDirectory(tempDir)
        Dim Co As Integer = 0
        Do
            Co += 1
            System.Threading.Thread.Sleep(50)
            Dim X As New System.Drawing.Bitmap(_Bounds.Width, _Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
            Using G = System.Drawing.Graphics.FromImage(X)
                G.CopyFromScreen(_Bounds.Location, New System.Drawing.Point(), _Bounds.Size)
                Dim CurBounds As New System.Drawing.Rectangle(System.Windows.Forms.Cursor.Position - Bounds.Location, System.Windows.Forms.Cursor.Current.Size)
                Forms.Cursors.Default.Draw(G, CurBounds)
            End Using
            Dim FS As New IO.FileStream(tempDir & FormatString(Co.ToString, 5, "0"c) & ".png", IO.FileMode.OpenOrCreate)
            X.Save(FS, System.Drawing.Imaging.ImageFormat.Png)
            X.Dispose()
            FS.Close()
        Loop
    End Sub
    Public Shared Sub ClearRecording()
        If My.Computer.FileSystem.DirectoryExists(tempDir) Then _
        My.Computer.FileSystem.DeleteDirectory(tempDir, FileIO.DeleteDirectoryOption.DeleteAllContents)
        My.Computer.FileSystem.CreateDirectory(tempDir)
    End Sub
    Public Shared Sub Save(ByVal Output As String)
        Dim G As New Windows.Media.Imaging.GifBitmapEncoder

        Dim X As New List(Of IO.FileStream)
        For Each Fi As String In My.Computer.FileSystem.GetFiles(tempDir, FileIO.SearchOption.SearchTopLevelOnly, "*.png")
            Dim TempStream As New IO.FileStream(Fi, IO.FileMode.Open)
            Dim Frame = Imaging.BitmapFrame.Create(TempStream)
            X.Add(TempStream)
            G.Frames.Add(Frame)
        Next
        Dim FS As New IO.FileStream(Output, IO.FileMode.OpenOrCreate)
        G.Save(FS)
        FS.Close()

        For Each St As IO.FileStream In X
            St.Close()

        Next

    End Sub
    Public Shared Sub Start()
        snap = New System.Threading.Thread(AddressOf Snapshot)
        snap.Start()
    End Sub
    Public Shared Sub [Stop]()
        snap.Abort()
    End Sub
    Private Shared Function FormatString(ByVal S As String, ByVal places As Integer, ByVal character As Char) As String
        If S.Length >= places Then Return S
        For X As Integer = S.Length To places
            S = character & S
        Next
        Return S
    End Function

End Class

To use the Codes

Start:
Code:
ScreenRecorder.Start

Stop
Code:
ScreenRecorder.Stop

Save
Code:
ScreenRecorder.Save("")

Select Window to Record
Code:
ScreenRecorder.Bounds = New System.Drawing.Rectangle(300, 300, 500, 300)

Delete the "Movie"
Code:
ScreenRecorder.ClearRecording()


This is a very simple tutorial to follow. Feel free to modify/ add your own functions!

Hope you found this helpfullBlackhat
Pm me if you need assistance with anything.
Reply
#2
Ahh sweet!! I'm going to try this right now!
Reply
#3
(04-12-2010, 07:38 AM)Sam Wrote: Ahh sweet!! I'm going to try this right now!

Smile. It works pretty well for something that takes ten minutes to code.
Pm me if you need assistance with anything.
Reply
#4
I'm going to expand on it and make loads of functions.
Reply
#5
(04-12-2010, 07:54 AM)Sam Wrote: I'm going to expand on it and make loads of functions.

Post any codes here and I'll add a, "if you would like to go more in depth" party
Pm me if you need assistance with anything.
Reply
#6
Thanks for this, the people that are just learning can use this. Its a great Tut. 10/10
Reply
#7
(04-12-2010, 09:14 AM)ImPrune Wrote: Thanks for this, the people that are just learning can use this. Its a great Tut. 10/10

Thanks man.
Pm me if you need assistance with anything.
Reply
#8
Very nice work. Should help new people when starting out in coding. Maybe make a common error section in order to deal with the same replies over and over again. But great work mate.
-Poppins
WhiteHat Hacker, Infection Control and HJT Team Trainee
Poppins™
Originally from: Hackforums.net
Reply
#9
Nice tut,thanks....
[Image: 20r9vh4.jpg]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Release] Advanced Screen Recorder 2011 CodingWorm 5 1,580 12-03-2011, 10:53 PM
Last Post: HostGap

Forum Jump:


Users browsing this thread: 1 Guest(s)