Monday, October 4, 2010

Visual Basic Tutorial - getting image from print screen

This is my first tutorial in this blog. For those who want to have a look at my other tutorials, please check my another blog at: http://tutorialoflife.blogspot.com/ and my website http://programmingbeginner.zxq.net/.




This application might be useful when you want save your print screen picture. Although in the video I didn't include the save function, I will include here. There will be also auto save function to save every picture that being print screen.




This is the print screen of the save and auto save function that added to the form. Savefiledialog1 and folderbrowserdialog1 are added. 

The coding will be provided in the following:

Code:

Public Class Form1 Dim temp As Object Dim i As Integer Private Sub HideToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HideToolStripMenuItem.Click Me.Hide() My.Computer.Clipboard.Clear() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If My.Computer.Clipboard.ContainsImage = True Then PictureBox1.Image = My.Computer.Clipboard.GetImage My.Computer.Clipboard.Clear() Me.Show() If AutoSaveToolStripMenuItem.Checked = True Then Try PictureBox1.Image.Save(temp & "\" & i & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg) i = i + 1 Catch ex As Exception End Try End If End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Start() i = 1 End Sub Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click SaveFileDialog1.Filter = "Jpeg (*.jpg)|*.jpg" SaveFileDialog1.ShowDialog() If SaveFileDialog1.FileName <> "" Then PictureBox1.Image.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg) End If End Sub Private Sub AutoSaveToolStripMenuItem_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles AutoSaveToolStripMenuItem.CheckStateChanged If AutoSaveToolStripMenuItem.Checked = True Then FolderBrowserDialog1.ShowDialog() FolderBrowserDialog1.Description = "Selected path to save your picture." temp = FolderBrowserDialog1.SelectedPath End If End SubEnd Class

For those who want the application, please go to my website for download.

http://programmingbeginner.zxq.net/.

It will be uploaded soon. 



 

No comments:

Post a Comment