468,769 Members | 2,180 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,769 developers. It's quick & easy.

Catch mouse clicks system wide with API call

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,

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

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'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
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

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

'NOTE: The following procedure is required by the Windows Form
Designer
'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
InitializeComponent()
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.SuspendLayout()
'
'btnOK
'
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"
'
'StatusBar1
'
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.Controls.Add(Me.StatusBar1)
Me.Controls.Add(Me.btnOK)
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.Fixed3D
Me.Icon = CType(resources.GetObject("$this.Icon"),
System.Drawing.Icon)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmcatchclickMouse"
Me.Text = "frmcatchclickMouse"
Me.TopMost = True
Me.ResumeLayout(False)

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
StatusBar1.Text = "NOCLIENTMOUSEMOVE"
Case vbalWinHook6.EHTMousewParamValues.WM_NCRBUTTONDOWN
StatusBar1.Text = "NOCLIENT RIGHT DOWN"
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
MyHook.InstallHook(Me,
vbalWinHook6.EHTHookTypeConstants.WH_MOUSE)
End Sub
End Class

May 26 '06 #1
0 1396

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Benoit Martin | last post: by
1 post views Thread by Brent | last post: by
16 posts views Thread by dfaber | last post: by
18 posts views Thread by eliss.carmine | last post: by
reply views Thread by Sin Jeong-hun | last post: by
22 posts views Thread by schneider | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.