Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

VS 2012 DirectX screenshot tool

$
0
0
Guys i need help with a working screenshot tool I put together, with the help of a vb member .paul. It takes a screen shot of normal windows in full screen and it uses a transparent form with 0% opacity. It also has its controls hidden, so the form is never visible with a keypress button. The problem is that i want to use it in games like call of duty and battlefield now. For that i need someone to help me get the first ever working directx screenshot tool. I searched all over the net and all i found was snippets of code and no answers. Here is the code and can you guys help me change it please?

Code:

Option Strict On
Imports System.Drawing.Bitmap
Imports System.Drawing.Rectangle
Imports System.Drawing.Image
Imports System.Runtime.InteropServices
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Imports System.IO

'http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx GetAsyncKeyState virtual key codes

Public Class takeScreenshot



    <DllImport("user32.dll")>
    Public Shared Function GetAsyncKeyState(ByVal vKey As Int32) As UShort
    End Function

    Dim Counter As Integer = 1

    Private Sub takeScreenshot_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        screenshotBox.BackgroundImageLayout = ImageLayout.Stretch
        Timer1.Interval = 100
        Timer1.Start()
    End Sub


    Private Sub escape_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Escape Then ScreenshotUpWindow.Show()

        Me.Hide()

    End Sub

    Public Shared Function Format( _
  ByVal Expression As Object, _
  Optional ByVal Style As String = "" _
) As String
    End Function

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        If CBool(GetAsyncKeyState(&H7B)) Then ' F12
            Dim ScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
            Dim bmpSize As Integer = (My.Computer.Screen.Bounds.Height)
            Dim BMP As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
            Dim g As System.Drawing.Graphics
            g = System.Drawing.Graphics.FromImage(BMP)
            g.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)

            Dim path1 As String = "C:" & IO.Path.DirectorySeparatorChar
            Dim path2 As String = "Pictures"
            Dim path3 As String = "Screenshots"
            Dim pathDate As String = DateTime.Now.ToString("yyyy-mm-dd")
            Dim savethePath As String = IO.Path.Combine(path1, path2, path3, pathDate)
            Dim thePath As String = IO.Path.Combine(path1, path2, path3)

            Try
                If Not (IO.Directory.Exists(thePath)) Then
                    IO.Directory.CreateDirectory(thePath)
                End If
            Catch ex As Exception
            End Try
            BMP.Save(savethePath & " _Capture-" & CStr(Counter) & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
            screenshotBox.BackgroundImage = BMP
            Counter = Counter + 1
        End If
    End Sub

    Private Sub screenshotBox_Click(sender As Object, e As EventArgs) Handles screenshotBox.Click

    End Sub
End Class


Viewing all articles
Browse latest Browse all 42220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>