Login Register






There was a very particular style of DDOS attack just now, it was mitigated.
Thread Rating:
  • 0 Vote(s) - 0 Average


How to take Screenshot ( Same as Printscreen, just faster) With Hotkey! filter_list
Author
Message
How to take Screenshot ( Same as Printscreen, just faster) With Hotkey! #1
I'm was working on an All-in-one application for my laptop since I'm starting school tomorrow and i wanted to share the code here just in case anyone was interested.

The hotkey works outside of the focused window, meaning it will work with whatever you're using.

[code=vb]
Public Class Form1
Public ImageData As Image
Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Integer) As Integer
Public TakeScreenshotViaHotkey As Boolean = True

Sub TakeScreenShot()
Dim Bounds As Rectangle
Dim CapturedImg As System.Drawing.Bitmap
Dim GFX As Graphics
Bounds = Screen.PrimaryScreen.Bounds
CapturedImg = New System.Drawing.Bitmap(Bounds.Width, Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
GFX = Graphics.FromImage(CapturedImg)
GFX.CopyFromScreen(Bounds.X, Bounds.Y, 0, 0, Bounds.Size, CopyPixelOperation.SourceCopy)
ImageData = CapturedImg
SaveScreenShot()
End Sub

Sub SaveScreenShot()
'Start of BMP format
SaveFileDialog1.DefaultExt = "*.bmp"
SaveFileDialog1.Filter = "Bitmap Images|*.bmp"
SaveFileDialog1.ShowDialog()
Try
ImageData.Save(SaveFileDialog1.FileName)
Catch ex As Exception
MessageBox.Show("An error has occured while saving" & vbNewLine & "And i don't know what's wrong.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Bouton1_Click(sender As Object, e As EventArgs) Handles Bouton1.Click
TakeScreenShot()
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Update_Stuff.Tick ' When the printscreen button is pressed it will run the "TakeScreenshot" sub.
If TakeScreenshotViaHotkey = False Then
If GetKeyPress(Keys.PrintScreen) Then
TakeScreenShot()
End If
End If

End Sub

Private Sub Hotkey_Checkbox_Click(sender As Object, e As EventArgs) Handles Hotkey_Checkbox.Click 'Enables and disable the ability to use the hotkey.
If Hotkey_Checkbox.Checked = True Then
TakeScreenshotViaHotkey = True
Else
TakeScreenshotViaHotkey = False
End If
End Sub
End Class
[/code]

Credits:
Not 100 % mine.
[Image: tumblr_m4vms28lYu1qj3ir1.gif]

Reply

RE: How to take Screenshot ( Same as Printscreen, just faster) With Hotkey! #2
That's pretty cool. I think that for people trying to learn more about this, a good project would be to add more file types and other features like: auto-upload, etc.
Thanks for sharing!

Reply

RE: How to take Screenshot ( Same as Printscreen, just faster) With Hotkey! #3
(08-19-2013, 08:39 PM)Xanii Wrote: That's pretty cool. I think that for people trying to learn more about this, a good project would be to add more file types and other features like: auto-upload, etc.
Thanks for sharing!

Doubt I'll do that since the Imgur API isn't much of a challenge, but maybe Smile
[Image: tumblr_m4vms28lYu1qj3ir1.gif]

Reply







Users browsing this thread:






This forum uses Lukasz Tkacz MyBB addons.