[Visual Basic .NET] 纯文本查看 复制代码 Public Class Form1
Private m_map As Bitmap
Private m_do As New DataObject()
Private Sub Form1_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp
If e.KeyCode = Keys.PrintScreen Then
m_do = Clipboard.GetDataObject()
Try
m_map = m_do.GetData(DataFormats.Bitmap)
Catch ee As Exception
MessageBox.Show(ee.Message)
Return
End Try
MsgBox("抓图完成")
Me.WindowState = FormWindowState.Normal
PictureBox1.Image = m_map
PictureBox1.Refresh()
End If
End Sub
Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp
'Dim m_Stream As Stream
If e.Button = MouseButtons.Right Then
SaveFileDialog1.Filter = "bmp files (*.bmp)|*.bmp"
SaveFileDialog1.RestoreDirectory = True
SaveFileDialog1.ShowDialog()
m_map.Save(SaveFileDialog1.FileName)
Me.WindowState = FormWindowState.Normal
PictureBox1.Image = Nothing
PictureBox1.Refresh()
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
MsgBox("请按PrintScreen键开始抓图")
Me.WindowState = FormWindowState.Minimized
End Sub
End Class
按照弹窗提示操作,支持全屏截图,右键截图选择保存位置。保存格式.bmp |