在好例子网,分享、交流、成长!
您当前所在位置:首页ASP 开发实例VB编程 → 截图拍照源码,快照桌面源码

截图拍照源码,快照桌面源码

VB编程

下载此实例
  • 开发语言:ASP
  • 实例大小:0.21M
  • 下载次数:16
  • 浏览次数:295
  • 发布时间:2013-10-03
  • 实例类别:VB编程
  • 发 布 人:crazycode
  • 文件格式:.rar
  • 所需积分:2
 相关标签: 拍照 截图

实例介绍

【实例简介】

【实例截图】

【核心代码】

Imports WindowsHookLib
Imports ScreenCaptureLib
Imports system.Drawing.Imaging
Imports System.runtime.InteropServices

Public Class MenuForm

#Region " API DECLARATIONS "

    <DllImport("user32", EntryPoint:="ChangeClipboardChain")> _
    Private Shared Function ChangeClipboardChain(ByVal hwnd As IntPtr, _
    ByVal hWndNext As IntPtr) As Boolean
    End Function

    <DllImport("user32", EntryPoint:="SetClipboardViewer")> _
    Public Shared Function SetClipboardViewer(ByVal hwnd As IntPtr) As IntPtr
    End Function

#End Region

#Region " CONSTANTS "
    Private Const WM_DRAWCLIPBOARD As Integer = &H308
#End Region

#Region " Member Variables "

    Public WithEvents globalMouse As New LLMouseHook
    Dim WithEvents globalKeyboard As New LLKeyboardHook
    Dim nextHandle As IntPtr
    Dim _layerFrm As LayerForm
    Dim _caprure As Boolean
    Dim _control As IntPtr
    Dim _soundPlayer As New System.Media.SoundPlayer

#End Region

#Region " Public Properties "

    Public ReadOnly Property SuportUrl() As String
        Get
            Return "http://www.vbforums.com/showthread.php?p=2753948#post2753948"
        End Get
    End Property

    Public ReadOnly Property Sound() As System.Media.SoundPlayer
        Get
            Me._soundPlayer.Load()
            Return Me._soundPlayer
        End Get
    End Property

    Public WriteOnly Property InstantMenu() As Boolean
        Set(ByVal value As Boolean)
            If value Then
                Me.Location = New Point(CInt(( _
                My.Computer.Screen.Bounds.Right - Me.Width) / 2), _
                My.Computer.Screen.Bounds.Top - Me.Height   1)
            Else
                Me.Location = New Point(CInt(( _
                My.Computer.Screen.Bounds.Right - Me.Width) / 2), _
                My.Computer.Screen.Bounds.Top - Me.Height)
            End If
        End Set
    End Property

#End Region

    Private Sub MenuForm_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Deactivate
        Dim rect As New Rectangle
        rect = Me.Bounds
        If Not (Control.MousePosition.X > rect.Left AndAlso Control.MousePosition.X < rect.Right AndAlso Control.MousePosition.Y < rect.Bottom) Then
            Me.Timer1.Enabled = True
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        nextHandle = SetClipboardViewer(Me.Handle)
        Me.NotifyIcon1.Text = My.Application.Info.ProductName _
        & ControlChars.NewLine & String.Format("Version {0}", _
        My.Application.Info.Version.ToString)
        Dim cmdLine As String = Microsoft.VisualBasic.Command
        If cmdLine = "Icon" Then
            Me.Timer1.Enabled = False
            Me.Top = 0
            Me.Activate()
        End If
        Me.Region = Shape.RoundedRegion(Me.Size, 6)
        If Not Me.globalKeyboard.InstallHook(False) Then
            MessageBox.Show("The Screen Shot failed to install the PRINTSCREEN hotkey." _
            & Environment.NewLine & Environment.NewLine _
            & "The PRINTSCREEN hotkey will still capture images from" _
            & Environment.NewLine & "the screen and place them onto the clipboard." _
            & Environment.NewLine & "Restarting the application from the shortcut may fix the problem." _
            , "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
        Dim myHotkeys As New HotKeyUtil(My.Settings.ObjectModifier Or My.Settings.ObjectKey)
        If My.Settings.MouseCapture Then
            Me.MouseCaptureMenuItem.Checked = True
            Me.KeyboardCaptureMenuItem.Checked = False
            Me.ObjectTSB.ToolTipText = "Mouse Capture of Objects ( " & myHotkeys.Format & " )."
        Else
            Me.MouseCaptureMenuItem.Checked = False
            Me.KeyboardCaptureMenuItem.Checked = True
            Me.ObjectTSB.ToolTipText = "Keyboard Capture of Objects ( " & myHotkeys.Format & " )."
        End If
        Me._soundPlayer.Stream = My.Resources.camera_click
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        ChangeClipboardChain(Me.Handle, Me.nextHandle)
        Me.globalMouse.Dispose()
        Me.globalKeyboard.Dispose()
    End Sub

    Public Sub SaveImage(ByVal img As Image)
        Dim dirctory As String = My.Settings.DirectoryPath
        Dim myImageFormat As ImageFormat = My.Settings.FileFormat
        If My.Computer.FileSystem.DirectoryExists(dirctory) = False Then
            dirctory = My.Computer.FileSystem.SpecialDirectories.Desktop
            My.Settings.DirectoryPath = dirctory
        End If
        Dim file As String = dirctory & "\Image"
        Dim tempFile As String = file
        Dim extension As String = myImageFormat.ToString
        Dim count As Integer
reapit: If My.Computer.FileSystem.FileExists(tempFile & "." & extension) = False Then
            If myImageFormat Is ImageFormat.Emf Or myImageFormat Is ImageFormat.Wmf Then
                img.Save(tempFile & "." & extension, myImageFormat)
            Else
                img.Save(tempFile & "." & extension, GetEncoderInfo("image/" & extension.ToLower), GetEncoderParameters)
            End If
        Else
            count  = 1
            tempFile = file & count
            GoTo reapit
        End If
    End Sub

    Private Function GetEncoderParameters() As EncoderParameters
        'Dim myImageCodecInfo As ImageCodecInfo
        Dim myEncoder As Encoder
        Dim myEncoderParameter As EncoderParameter
        Dim myEncoderParameters As EncoderParameters

        ' Create an Encoder object based on the GUID
        ' for the Quality parameter category.
        myEncoder = Encoder.Quality

        ' Create an EncoderParameters object.
        ' An EncoderParameters object has an array of EncoderParameter
        ' objects. In this case, there is only one
        ' EncoderParameter object in the array.
        myEncoderParameters = New EncoderParameters(1)

        ' Sets the  quality parameter.
        myEncoderParameter = New EncoderParameter(myEncoder, My.Settings.Quality)
        myEncoderParameters.Param(0) = myEncoderParameter
        Return myEncoderParameters
    End Function

    Private Shared Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo
        Dim encoders() As ImageCodecInfo
        encoders = ImageCodecInfo.GetImageEncoders()
        For Each encoder As ImageCodecInfo In encoders
            If encoder.MimeType = mimeType Then
                Return encoder
            End If
        Next
        Return Nothing
    End Function

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If m.Msg = WM_DRAWCLIPBOARD Then
            If My.Computer.Clipboard.ContainsImage Then
                Me.ClipboardTSB.Enabled = True
            Else
                Me.ClipboardTSB.Enabled = False
            End If
        End If
        'Forward message to base WndProc.
        MyBase.WndProc(m)
    End Sub

    Public Sub GoToTheFolder()
        Dim dirctory As String = My.Settings.DirectoryPath
        If My.Computer.FileSystem.DirectoryExists(dirctory) = False Then
            dirctory = My.Computer.FileSystem.SpecialDirectories.Desktop
            My.Settings.DirectoryPath = dirctory
        End If
        Dim p As New System.Diagnostics.Process
        p.StartInfo.FileName = "explorer"
        p.StartInfo.Arguments = dirctory
        p.Start()
        p.Close()
        p.Dispose()
    End Sub

    Private Sub globalMouse_MouseClick1(ByVal sender As System.IntPtr, ByVal e As WindowsHookLib.LLMouseEventArgs) Handles globalMouse.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Dim img As Image
            If Not (e.X >= Me.Left AndAlso e.X <= Me.Bounds.Right AndAlso e.Y >= Me.Top AndAlso e.Y <= Me.Bounds.Bottom) Then
                If Me.Top > (My.Computer.Screen.Bounds.Top - Me.Height) Then
                    Me._control = sender
                    Me._caprure = True
                    Me.InstantMenu = False
                Else
                    Try
                        Me.NotifyIcon1.Icon = My.Resources.Capture
                        img = ICapture.Control(sender)
                        Me.SaveImage(img)
                        If My.Settings.PlaySound Then
                            Me.Sound.Play()
                        End If
                    Catch ex As Exception
                        Me.globalMouse.RemoveHook()
                        Me.TopMost = True
                        MessageBox.Show("The capture of the image failed!" & Environment.NewLine _
                        & "Restarting the application from the shortcut may fix the problem." _
                        & Environment.NewLine & Environment.NewLine & ex.Message, _
                        "Capture Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    Finally
                        Me.InstantMenu = My.Settings.InstantMenu
                        Me.NotifyIcon1.Icon = My.Resources.Screen
                    End Try
                End If
            End If
        End If
    End Sub

    Private Sub globalMouse_MouseDown(ByVal sender As IntPtr, ByVal e As WindowsHookLib.LLMouseEventArgs) Handles globalMouse.MouseDown
        e.Handled = sender <> Me.MenuToolStrip.Handle
    End Sub

    Private Sub globalMouse_MouseUp(ByVal sender As IntPtr, ByVal e As WindowsHookLib.LLMouseEventArgs) Handles globalMouse.MouseUp
        e.Handled = sender <> Me.MenuToolStrip.Handle
    End Sub

    Private Sub globalMouse_StateChanged(ByVal sender As Object, ByVal e As WindowsHookLib.StateChangedEventArgs) Handles globalMouse.StateChanged
        If e.State = HookState.Installed Then
            Me.ShowRedRectangle()
        Else
            Me.HideRedRectangle()
        End If
    End Sub

    Private Sub ShowRedRectangle()
        Me.CancelTSB.Enabled = True
        Me._layerFrm = New LayerForm
        Me._layerFrm.Size = My.Computer.Screen.Bounds.Size
        Me._layerFrm.Show()
        Me._layerFrm.Location = New Point(0, 0)
        Me.Focus()
    End Sub

    Private Sub HideRedRectangle()
        Me.CancelTSB.Enabled = False
        If Not Me._layerFrm.IsDisposed Then
            Me._layerFrm.Close()
        End If
    End Sub

    Private Sub AboutTSMI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutTSMI.Click
        If My.Forms.RectangleForm.Visible Then
            My.Forms.RectangleForm.Close()
        End If
        My.Forms.AboutApplication.ShowDialog()
    End Sub

    Private Sub ExitTSMI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitTSMI.Click
        Me.Close()
    End Sub

    Private Sub MenuForm_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
        If Not Me._caprure Then
            Me.Activate()
            Me.Timer1.Enabled = False
            Me.Top = 0
        End If
    End Sub

    Private Sub MenuForm_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
        Dim rect As New Rectangle
        rect = Me.Bounds
        If Not (Control.MousePosition.X > rect.Left AndAlso Control.MousePosition.X < rect.Right AndAlso Control.MousePosition.Y < rect.Bottom) Then
            Me.Timer1.Enabled = True
        End If
    End Sub

    Private Sub ToolStrip1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuToolStrip.MouseEnter
        If Not Me._caprure Then
            Me.Activate()
            Me.Focus()
            Me.Timer1.Enabled = False
            Me.Top = 0
        End If
    End Sub

    Private Sub ToolStrip1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuToolStrip.MouseLeave
        Dim rect As New Rectangle
        rect = Me.Bounds
        If Not (Control.MousePosition.X > rect.Left AndAlso Control.MousePosition.X < rect.Right AndAlso Control.MousePosition.Y < rect.Bottom) Then
            Me.Timer1.Enabled = True
        End If
    End Sub

    Private Sub NotifyIcon1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Me.Timer1.Enabled = False
            Me.Top = 0
            Me.Activate()
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Me.HelpTSDDB.HideDropDown()
        If My.Settings.InstantMenu Then
            If Me.Top > (My.Computer.Screen.Bounds.Top   1) - Me.Height Then
                Me.Top -= 1
            Else : Me.Timer1.Enabled = False
            End If
        Else
            If Me.Top > My.Computer.Screen.Bounds.Top - Me.Height Then
                Me.Top -= 1
            Else : Me.Timer1.Enabled = False
            End If
        End If
    End Sub

    Private Sub RectangleTSB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RectangleTSB.Click
        If Me.globalMouse.GetState = HookState.Installed Then
            Me.globalMouse.RemoveHook()
        End If
        Me.CancelTSB.Enabled = False
        If My.Forms.RectangleForm.Visible = False Then
            My.Forms.RectangleForm.Show()
        End If
    End Sub

    Private Sub ClipboardTSB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClipboardTSB.Click
        Try
            Me.NotifyIcon1.Icon = My.Resources.Capture
            Me.SaveImage(My.Computer.Clipboard.GetImage)
            If My.Settings.PlaySound Then
                Me.Sound.Play()
            End If
        Catch ex As Exception
            Me.globalMouse.RemoveHook()
            Me.CancelTSB.Enabled = False
            MessageBox.Show("The capture of the image failed!" & Environment.NewLine _
            & "Restarting the application from the shortcut may fix the problem." _
            & Environment.NewLine & Environment.NewLine & ex.Message, _
            "Capture Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            Me.NotifyIcon1.Icon = My.Resources.Screen
        End Try
    End Sub

    Private Sub CancelTSB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CancelTSB.Click
        If Me.globalMouse.GetState = HookState.Installed Then
            Me.globalMouse.RemoveHook()
        Else
            Me.CancelTSB.Enabled = False
        End If
    End Sub

    Private Sub FolderTSB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FolderTSB.Click
        If Me.globalMouse.GetState = HookState.Installed Then
            Me.globalMouse.RemoveHook()
        End If
        Me.CancelTSB.Enabled = False
        If My.Forms.RectangleForm.Visible Then
            My.Forms.RectangleForm.Close()
        End If
        Me.GoToTheFolder()
    End Sub

    Private Sub PropertiesTSB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PropertiesTSB.Click
        If Not Me.Timer1.Enabled Then
            Me.Timer1.Enabled = True
        End If
        If Me.globalMouse.GetState = HookState.Installed Then
            Me.globalMouse.RemoveHook()
        End If
        Me.CancelTSB.Enabled = False
        If My.Forms.RectangleForm.Visible Then
            My.Forms.RectangleForm.Close()
        End If
        If Not My.Forms.OptionsDialog.Visible Then
            My.Forms.OptionsDialog.ShowDialog()
        End If
    End Sub

    Private Sub ByMouseMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ByMouseMenuItem.Click, ByMouseIconMenuItem.Click
        Dim info As String
        Dim myHotkeys As New HotKeyUtil(My.Settings.ObjectModifier Or My.Settings.ObjectKey)
        info = "1. Set the object capture mode to 'Mouse'." & ControlChars.NewLine _
        & "2. Click on the 'Object Capture' menu button." & ControlChars.NewLine _
        & "3. Point the cursor to the object." & ControlChars.NewLine & _
        "4. Click inside the red rectangle or press " & myHotkeys.Format & " key-combination."
        Me.NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
        Me.NotifyIcon1.BalloonTipTitle = "Object Capture by Mouse"
        Me.NotifyIcon1.BalloonTipText = info
        Me.NotifyIcon1.ShowBalloonTip(500)
    End Sub

    Private Sub ByKeyboardMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ByKeyboardMenuItem.Click, ByKeyboardIconMenuItem.Click
        Dim info As String
        Dim myHotkeys As New HotKeyUtil(My.Settings.ObjectModifier Or My.Settings.ObjectKey)
        info = "1. Set the object capture mode to 'Keyboard'." & ControlChars.NewLine _
        & "2. Click on the 'Object Capture' menu button." & ControlChars.NewLine _
        & "3. Point the cursor to the object." & ControlChars.NewLine _
        & "4. Press " & myHotkeys.Format & " key-combination."
        Me.NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
        Me.NotifyIcon1.BalloonTipTitle = "Object Capture by Keyboard"
        Me.NotifyIcon1.BalloonTipText = info
        Me.NotifyIcon1.ShowBalloonTip(500)
    End Sub

    Private Sub HelpRectangleTSMI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpRectangleCTSMI.Click, HelpRectangleMTSMI.Click
        Dim info As String
        info = "1. Click on the 'Rectangle Capture' menu button." & ControlChars.NewLine _
        & "2. Make the necessary adjustments to the rectangle." & ControlChars.NewLine _
        & "3. Click on the 'Capture the Rectangle' menu button of the Toolbar."
        Me.NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
        Me.NotifyIcon1.BalloonTipTitle = "Rectangle Capture"
        Me.NotifyIcon1.BalloonTipText = info
        Me.NotifyIcon1.ShowBalloonTip(500)
    End Sub

    Private Sub HelpHotKeysTSMI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpHotKeysCTSMI.Click, HelpHotKeysMTSMI.Click
        Dim info As String = String.Empty
        Dim myHotkeys As New HotKeyUtil(My.Settings.FullScreenModifier Or My.Settings.FullScreenKey)
        info = myHotkeys.Format.ToUpper & ControlChars.NewLine
        info &= "( captures the entire screen )" & ControlChars.NewLine & ControlChars.NewLine
        myHotkeys.Reset(My.Settings.ActiveWindowModifier Or My.Settings.ActiveWindowKey)
        info &= myHotkeys.Format.ToUpper & ControlChars.NewLine
        info &= "( captures the active window )" & ControlChars.NewLine & ControlChars.NewLine
        myHotkeys.Reset(My.Settings.ObjectModifier Or My.Settings.ObjectKey)
        info &= myHotkeys.Format.ToUpper & ControlChars.NewLine
        info &= "( captures an object under the mouse if object-capture is ON )" & ControlChars.NewLine
        Me.NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
        Me.NotifyIcon1.BalloonTipTitle = "HotKeys"
        Me.NotifyIcon1.BalloonTipText = info
        Me.NotifyIcon1.ShowBalloonTip(500)
    End Sub

    Private Sub HelpTSDDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpTSDDB.Click
        If Me.globalMouse.GetState = HookState.Installed Then
            Me.globalMouse.RemoveHook()
        End If
        Me.CancelTSB.Enabled = False
    End Sub

    Private Sub MenuForm_LocationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LocationChanged
        If Me.Top = (My.Computer.Screen.Bounds.Top - Me.Height) AndAlso Me._caprure Then
            Try
                Me.NotifyIcon1.Icon = My.Resources.Capture
                Dim img As Image
                img = ICapture.Control(Me._control)
                Me.SaveImage(img)
                If My.Settings.PlaySound Then
                    Me.Sound.Play()
                End If
            Catch ex As Exception
                Me.globalMouse.RemoveHook()
                Me.TopMost = True
                MessageBox.Show("The capture of the image failed!" & Environment.NewLine _
                & "Restarting the application from the shortcut may fix the problem." _
                & Environment.NewLine & Environment.NewLine & ex.Message, _
                "Capture Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Finally
                Me.InstantMenu = My.Settings.InstantMenu
                Me.NotifyIcon1.Icon = My.Resources.Screen
                Me._caprure = False
            End Try
        End If
    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        If My.Forms.RectangleForm.Visible Then
            My.Forms.RectangleForm.Close()
        End If
        My.Forms.AboutApplication.ShowDialog()
    End Sub

    Private Sub globalKeyboard_KeyDown(ByVal sender As Object, ByVal e As WindowsHookLib.LLKeyEventArgs) Handles globalKeyboard.KeyDown
        Dim img As Image
        Try
            If e.Modifiers = My.Settings.ActiveWindowModifier AndAlso e.KeyCode = My.Settings.ActiveWindowKey Then
                e.Handled = True
                Me.NotifyIcon1.Icon = My.Resources.Capture
                img = ICapture.ActiveWindow
                Me.SaveImage(img)
                If My.Settings.PlaySound Then
                    My.Computer.Audio.Play( _
                    My.Resources.camera_click, AudioPlayMode.Background)
                End If
            End If
            If e.Modifiers = My.Settings.FullScreenModifier AndAlso e.KeyCode = My.Settings.FullScreenKey Then
                e.Handled = True
                Me.NotifyIcon1.Icon = My.Resources.Capture
                img = ICapture.FullScreen
                Me.SaveImage(img)
                If My.Settings.PlaySound Then
                    Me.Sound.Play()
                End If
            End If
            If Me.CancelTSB.Enabled Then
                If e.Modifiers = My.Settings.ObjectModifier AndAlso e.KeyCode = My.Settings.ObjectKey Then
                    e.Handled = True
                    img = ICapture.Control(Control.MousePosition)
                    Me.SaveImage(img)
                    If My.Settings.PlaySound Then
                        Me.Sound.Play()
                    End If
                End If
            End If
        Catch ex As Exception
            Me.TopMost = True
            MessageBox.Show("The capture of the image failed!" & Environment.NewLine _
            & "Restarting the application from the shortcut may fix the problem." _
            & Environment.NewLine & Environment.NewLine & ex.Message, _
            "Capture Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            Me.NotifyIcon1.Icon = My.Resources.Screen
        End Try
    End Sub

    Private Sub globalKeyboard_KeyUp(ByVal sender As Object, ByVal e As WindowsHookLib.LLKeyEventArgs) Handles globalKeyboard.KeyUp
        If (e.Modifiers = My.Settings.ActiveWindowModifier AndAlso e.KeyCode = My.Settings.ActiveWindowKey) _
        Or (e.Modifiers = My.Settings.FullScreenModifier AndAlso e.KeyCode = My.Settings.FullScreenKey) Then
            e.Handled = True
        End If
    End Sub

    Private Sub OptionsMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionsMenuItem.Click
        If Not Me.Timer1.Enabled Then
            Me.Timer1.Enabled = True
        End If
        If Me.globalMouse.GetState = HookState.Installed Then
            Me.globalMouse.RemoveHook()
        End If
        If My.Forms.RectangleForm.Visible Then
            My.Forms.RectangleForm.Close()
        End If
        If Not My.Forms.OptionsDialog.Visible Then
            My.Forms.OptionsDialog.ShowDialog()
        End If
    End Sub

    Private Sub ObjectTSB_ButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ObjectTSB.ButtonClick
        If Me.ObjectTSB.ButtonSelected Then
            If Me.MouseCaptureMenuItem.Checked Then
                Me.globalMouse.InstallHook()
            Else
                Me.CancelTSB.Enabled = True
            End If
        End If
    End Sub

    Private Sub ObjectTSB_DropDownOpening(ByVal sender As Object, ByVal e As System.EventArgs) Handles ObjectTSB.DropDownOpening
        Me.KeyboardCaptureMenuItem.Text = "Keyboard"
        Me.MouseCaptureMenuItem.Text = "Mouse"
        If Me.globalMouse.GetState = HookState.Installed Then
            Me.globalMouse.RemoveHook()
        End If
        Me.CancelTSB.Enabled = False
    End Sub

    Private Sub CancelTSB_EnabledChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CancelTSB.EnabledChanged
        If Me.CancelTSB.Enabled Then
            If Me.KeyboardCaptureMenuItem.Checked Then
                Me.CancelTSB.ToolTipText = "Cancel the Capture (Keyboard)."
            Else
                Me.CancelTSB.ToolTipText = "Cancel the Capture (Mouse)."
            End If
        Else
            Me.CancelTSB.ToolTipText = "Cancel."
        End If
    End Sub

    Private Sub MouseCaptureMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MouseCaptureMenuItem.Click
        If Not Me.MouseCaptureMenuItem.Checked Then
            Me.MouseCaptureMenuItem.Checked = True
            Me.KeyboardCaptureMenuItem.Checked = False
            My.Settings.MouseCapture = True
            My.Settings.Save()
        End If
    End Sub

    Private Sub KeyboardCaptureMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyboardCaptureMenuItem.Click
        If Not Me.KeyboardCaptureMenuItem.Checked Then
            Me.KeyboardCaptureMenuItem.Checked = True
            Me.MouseCaptureMenuItem.Checked = False
            My.Settings.MouseCapture = False
            My.Settings.Save()
        End If
    End Sub

    Private Sub ContextMenuStrip1_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
        If My.Forms.OptionsDialog.Visible Then
            Me.OptionsMenuItem.Enabled = False
        Else
            Me.OptionsMenuItem.Enabled = True
        End If
    End Sub
End Class

标签: 拍照 截图

实例下载地址

截图拍照源码,快照桌面源码

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警