By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,289 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,289 IT Pros & Developers. It's quick & easy.

Catch mouse clicks system wide with API call

P: n/a
I' m trying to disable all right mouse clicks by using the
vbAccelerator Windows Hooks Library
The small (systray / console) app. must catch all (right) mouseclicks
before they are received by the users application (for instance IE).
I' m not getting passed the stage where I write to the console catching
clicks on my applications form..

I really doubt if this one's possible at all (especially for an API
noob like me)..

Thanks in advance,

Public Class frmCatchClick
Inherits System.Windows.Forms.Form
Implements vbalWinHook6.IWindowsHook
#Region " Windows Form Designer generated code "

Public Sub New()

'This call is required by the Windows Form Designer.

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
If disposing Then
If Not (components Is Nothing) Then
End If
End If
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents btnOK As System.Windows.Forms.Button
Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
<System.Diagnostics.DebuggerStepThrough()> Private Sub
Dim resources As System.Resources.ResourceManager = New
System.Resources.ResourceManager(GetType(frmcatchc lick))
Me.btnOK = New System.Windows.Forms.Button
Me.StatusBar1 = New System.Windows.Forms.StatusBar
Me.btnOK.BackColor = System.Drawing.SystemColors.Control
Me.btnOK.Location = New System.Drawing.Point(96, 16)
Me.btnOK.Name = "btnOK"
Me.btnOK.Size = New System.Drawing.Size(80, 24)
Me.btnOK.TabIndex = 0
Me.btnOK.Text = "Start Mouse"
Me.StatusBar1.Location = New System.Drawing.Point(0, 59)
Me.StatusBar1.Name = "StatusBar1"
Me.StatusBar1.Size = New System.Drawing.Size(294, 16)
Me.StatusBar1.TabIndex = 1
Me.StatusBar1.Text = "StatusBar1"
'frmcatchclick '
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.LightSteelBlue
Me.ClientSize = New System.Drawing.Size(294, 75)
Me.FormBorderStyle =
Me.Icon = CType(resources.GetObject("$this.Icon"),
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmcatchclickMouse"
Me.Text = "frmcatchclickMouse"
Me.TopMost = True

End Sub

#End Region
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click
Me.DialogResult = DialogResult.OK
End Sub
Private Function IWindowsHook_HookProc(ByVal eType As
vbalWinHook6.EHTHookTypeConstants, ByVal nCode As Integer, ByVal wParam
As Integer, ByVal lParam As Integer, ByRef bConsume As Boolean) As
Integer Implements vbalWinHook6.IWindowsHook.HookProc
Dim ctlOver As System.Windows.Forms.Control
Dim bS As Boolean
Dim lC As Integer
Dim lhWNd As Integer
Dim bSkip As Boolean

With MyHook.MouselParam(lParam)
Select Case wParam
Case vbalWinHook6.EHTMousewParamValues.WM_MOUSEMOVE
StatusBar1.Text = "MOUSEMOVE"
Case vbalWinHook6.EHTMousewParamValues.WM_RBUTTONDOWN
', vbalWinHook6.EHTMousewParamValues.WM_LBUTTONDOWN
StatusBar1.Text = "MOUSE DOWN!!!"
Case vbalWinHook6.EHTMousewParamValues.WM_NCMOUSEMOVE
Case vbalWinHook6.EHTMousewParamValues.WM_NCRBUTTONDOWN
Case vbalWinHook6.EHTMousewParamValues.WM_RBUTTONUP
StatusBar1.Text = " RIGHT UP"
Case vbalWinHook6.EHTMousewParamValues.WM_NCRBUTTONUP
StatusBar1.Text = "NOCLIENT RIGHT UP!"
End Select

End With
End Function
Private Sub frmcatchclick_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
End Class

May 26 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.