I have two forms, a Region selection form and a Freeze screen form. For the freeze screen form I'm using a picture box to display the captured screen image then it loads the Region selection forum to select a picture from the previous captured screen.
Is there any other way to go about doing this, preferably not requiring a second form just so I can screen capture it.
Capture full screen, create a full screen form without borders, make forms BG image the captured image.
I hope u get the concept.
(Nov 28, 2014 09:45 AM)SubGenius Wrote: Capture full screen, create a full screen form without borders, make forms BG image the captured image.
I hope u get the concept.
Oh wow thank you I didn't already do that and that was why I made this thread, specifically asking for a different way to do this instead of using a Form and a Picturebox...
Region Select
Code Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
Imports System.Text
Imports System.Net
Imports System.Web
Imports System.Math
Public Class RS
Private MyRectangle As Rectangle
Private Drawing As Boolean = False
Private StartX, StartY, CursorX, CursorY As Single
Dim saveDialog As New SaveFileDialog
Dim bmp As Bitmap
Dim graphics As Graphics
Dim KeyCode As String = File.ReadAllText(Application.StartupPath & "\APIKey.txt")
Public Const CTRL As Integer = &H0
Public Const WM_HOTKEY As Integer = &H312
Public Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
Public Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
Private Sub HotKey_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call RegisterHotKey(Me.Handle, 1, CTRL, Keys.Escape)
End Sub
Private Sub HotKey_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Call UnregisterHotKey(Me.Handle, 100)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_HOTKEY Then
Dim id As IntPtr = m.WParam
Select Case (id.ToString)
Case "1" : Application.Exit()
End Select
End If
MyBase.WndProc(m)
End Sub
Private Sub Region_Drag_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If Drawing = True Then
Dim Oral_Pen As New Pen(Brushes.Red, 2)
Oral_Pen.DashStyle = Drawing2D.DashStyle.Solid
MyRectangle = New Rectangle(Min(StartX, CursorX), _
Min(StartY, CursorY), _
Abs(StartX - CursorX), _
Abs(StartY - CursorY))
e.Graphics.FillRectangle(New SolidBrush(Color.Transparent), MyRectangle)
e.Graphics.DrawRectangle(Oral_Pen, MyRectangle)
End If
End Sub
Private Sub Region_Drag_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
Me.Opacity = 100%
Me.BackColor = Color.Fuchsia
Drawing = True
StartX = e.X
StartY = e.Y
CursorX = e.X
CursorY = e.Y
End Sub
Private Sub Region_Drag_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If Not Drawing Then Exit Sub
Dim G As Graphics = Me.CreateGraphics
CursorX = e.X
CursorY = e.Y
Me.Invalidate()
End Sub
Private Sub Region_Drag_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
Drawing = False
Dim G As Graphics = Me.CreateGraphics
G.DrawRectangle(Pens.Black, MyRectangle.X, MyRectangle.Y, MyRectangle.Width, MyRectangle.Height)
Me.Visible = False
Try
bmp = New Bitmap(MyRectangle.Width, MyRectangle.Height, PixelFormat.Format32bppArgb)
graphics = graphics.FromImage(bmp)
graphics.CopyFromScreen(MyRectangle.X, MyRectangle.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy)
saveDialog.Filter = "png image|*.png"
saveDialog.Title = "Save image as"
saveDialog.ShowDialog()
If saveDialog.FileName <> "" Then
bmp.Save(saveDialog.FileName, ImageFormat.Png)
If KeyCode.ToString = String.Empty Then
Else
upload()
End If
End If
Catch ex As Exception : Application.Exit() : Finally
bmp = Nothing
graphics = Nothing
Me.WindowState = FormWindowState.Minimized
Me.Hide()
End Try
Me.Visible = True
Me.Invalidate()
Me.Dispose()
Application.Exit()
End Sub
Private Sub Region_Drag_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Focus()
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.TopMost = True
Me.Location = New Point(0, 0)
Me.Size = Screen.PrimaryScreen.Bounds.Size
Me.DoubleBuffered = True
End Sub
Sub upload()
Dim apiKey As String = KeyCode
Dim imageData() As Byte
Dim fileStream As FileStream = File.OpenRead(saveDialog.FileName)
imageData = New Byte((fileStream.Length) - 1) {}
fileStream.Read(imageData, 0, imageData.Length)
fileStream.Close()
Dim uploadRequestString As String = HttpUtility.UrlEncode("image", Encoding.UTF8) + "=" + HttpUtility.UrlEncode(System.Convert.ToBase64String(imageData)) + "&" + HttpUtility.UrlEncode("key", Encoding.UTF8) + "=" + HttpUtility.UrlEncode(apiKey, Encoding.UTF8)
Dim webRequest As HttpWebRequest = CType(Net.WebRequest.Create("http://api.imgur.com/2/upload"), HttpWebRequest)
webRequest.Method = "POST"
webRequest.ContentType = "application/x-www-form-urlencoded"
webRequest.ServicePoint.Expect100Continue = False
Dim streamWriter As IO.StreamWriter = New IO.StreamWriter(webRequest.GetRequestStream)
streamWriter.Write(uploadRequestString)
streamWriter.Close()
Dim response As WebResponse = webRequest.GetResponse
Dim responseStream As Stream = response.GetResponseStream
Dim responseReader As StreamReader = New StreamReader(responseStream)
Dim responseString As String = responseReader.ReadToEnd
Dim ImageURL As String = Split(responseString, "<original>")(1).Split("<")(0)
Dim X As String
X = ImageURL
System.Diagnostics.Process.Start(X)
End Sub
End Class
Freeze Screen
Code Imports System.Drawing
Imports System.Drawing.Imaging
Public Class FreezeScreen
Public bmp As Bitmap
Public gfx As Graphics
Private Sub FreezeScreen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
bmp = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb) : gfx = Graphics.FromImage(bmp) : gfx.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy) : PictureBox1.Image = bmp : Me.WindowState = FormWindowState.Maximized : RS.Show()
End Sub
End Class
As you see it works just fine, the only problem is the fact you have to see the form load up and it's just a bit nasty looking especially for a 'instant' screen capture. I Want everything to be execute and done as fast as possible in terms of Capturing the entire screen and displaying it for another capture to take picture of.
DO NOT DEAL WITH THIS MEMBER
Have the form preloaded in the background and have it set the background on a key press, so that way it doesnt have to load the form each time.
Well you can draw on the zero handle, you might have some trouble figuring it out, but that does not require you to use a form. Just create graohics from handle zero and copy the screen onto it. But here comes the problem. The zero handle is redrawn pretty quickly, so you will need to find a way to hook into the paint message , or you can just use a loop, wouls not reccomend
(Nov 29, 2014 07:35 AM)SIM-1456245 Wrote: Well you can draw on the zero handle, you might have some trouble figuring it out, but that does not require you to use a form. Just create graohics from handle zero and copy the screen onto it. But here comes the problem. The zero handle is redrawn pretty quickly, so you will need to find a way to hook into the paint message , or you can just use a loop, wouls not reccomend
If you could do it on a zero handle, could you use a NativeWindow to do it?
(Nov 29, 2014 07:40 AM)Nikey646 Wrote: If you could do it on a zero handle, could you use a NativeWindow to do it?
I don't see a reason for NativeWindow, except if you are going to use it to hook onto the paint event.
So you want to be able to capture an image of the screen, and have that image stay as the background ( not wallpaper ).
(Nov 29, 2014 04:36 PM)PapaBeans Wrote: So you want to be able to capture an image of the screen, and have that image stay as the background ( not wallpaper ).
Lol no, I already did that, you obviously can't read.
(Nov 29, 2014 02:14 PM)SIM-1456245 Wrote: I don't see a reason for NativeWindow, except if you are going to use it to hook onto the paint event.
But wouldn't using a NativeWindow solve the re-draw issue of using a zerohandle, without effecting performance as much as a Form?
(Nov 29, 2014 08:39 PM)Nikey646 Wrote: But wouldn't using a NativeWindow solve the re-draw issue of using a zerohandle, without effecting performance as much as a Form?
Can you give me an example of what you were talking about?
(Nov 29, 2014 08:40 PM)AEDEAD Wrote: Can you give me an example of what you were talking about?
No, because you clearly think leeching is fine and won't use it to better your knowledge, so it'll be wasted time and effort on my end, especially considering you will take credit for all the work i do for you.
I made something like this a long time ago I made a tutorial for it on my channel: jake000001111v2
|