基本信息
源码名称:截图拍照源码,快照桌面源码
源码大小:0.21M
文件格式:.rar
开发语言:ASP
更新时间:2013-10-03
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在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