Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 853127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:42:32+00:00 2026-05-15T07:42:32+00:00

Edit I’ve added the following code, however I get an error @ SendInput: File

  • 0

Edit

I’ve added the following code, however I get an error @ SendInput:

File I/O of a structure with field ‘dwExtraInfo’ of type ‘IntPtr’ is not valid

Public Sub DoDoubleClick(ByVal wait As Integer, ByVal x As Integer, ByVal y As Integer)
    Dim inputEvents(0) As Input
    Dim p As MOUSEKEYBDHARDWAREINPUT

    p.mi.dx = x
    p.mi.dy = y
    p.mi.mouseData = 0
    p.mi.dwFlags = MOUSEEVENTF_MOVE + MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP

    inputEvents(0).dwType = 0
    inputEvents(0).mkhi = p

    SendInput(1, inputEvents(0), Len(inputEvents(0)))

    System.Threading.Thread.Sleep(wait)

    'SendInput(1, inputEvents(0), Len(inputEvents(0)))
End Sub

Original question:

I’m trying to programmatically invoke an onclick event however the click is not received/handled. Am I missing something, or is security preventing the click to be executed?

I have a forms application which is invisible. Basically I would like to say:

DoDoubleClick(wait, x, y)

This should raise two click (mousedown+mouseup) events on screen with the specified wait interval. However the click isn’t received in a Flash application in Firefox (which is running at that moment).

Here’s my code:

Form:

Public Class Form1
    Private WithEvents gmh As GlobalMouseHook

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        gmh = New GlobalMouseHook()
        Me.Visible = false
        gmh.DoDoubleClick(50, 800, 600)
    End Sub

    Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        gmh.Dispose()
    End Sub

    Private Sub gmh_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles gmh.MouseDown

    End Sub

    Private Sub gmh_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles gmh.MouseMove

    End Sub

    Private Sub gmh_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles gmh.MouseUp

    End Sub

End Class

GlobalMouseHook class:

Friend Class GlobalMouseHook
    Implements IDisposable

    Private hhk As IntPtr = IntPtr.Zero
    Private disposedValue As Boolean = False 

    Public Event MouseDown As MouseEventHandler
    Public Event MouseUp As MouseEventHandler
    Public Event MouseMove As MouseEventHandler

    Public Sub New()
        Hook()
    End Sub

    Private Sub Hook()
        Dim hInstance As IntPtr = LoadLibrary("User32")
        hhk = SetWindowsHookEx(WH_MOUSE_LL, AddressOf Me.HookProc, hInstance, 0)
    End Sub

    Private Sub Unhook()
        UnhookWindowsHookEx(hhk)
    End Sub

    Public Sub DoDoubleClick(ByVal wait As Integer, ByVal x As Integer, ByVal y As Integer)
        RaiseEvent MouseDown(Me, New MouseEventArgs(MouseButtons.Left, 1, x, y, 0))
        RaiseEvent MouseUp(Me, Nothing)

        System.Threading.Thread.Sleep(wait)

        RaiseEvent MouseDown(Me, New MouseEventArgs(MouseButtons.Left, 1, x, y, 0))
        RaiseEvent MouseUp(Me, Nothing)
    End Sub

    Private Function HookProc(ByVal nCode As Integer, ByVal wParam As UInteger, ByRef lParam As MSLLHOOKSTRUCT) As Integer
        If nCode >= 0 Then
            Select Case wParam
                Case WM_LBUTTONDOWN
                    RaiseEvent MouseDown(Me, New MouseEventArgs(MouseButtons.Left, 0, lParam.pt.x, lParam.pt.y, 0))
                Case WM_RBUTTONDOWN
                    RaiseEvent MouseDown(Me, New MouseEventArgs(MouseButtons.Right, 0, lParam.pt.x, lParam.pt.y, 0))
                Case WM_MBUTTONDOWN
                    RaiseEvent MouseDown(Me, New MouseEventArgs(MouseButtons.Middle, 0, lParam.pt.x, lParam.pt.y, 0))
                Case WM_LBUTTONUP, WM_RBUTTONUP, WM_MBUTTONUP
                    RaiseEvent MouseUp(Nothing, Nothing)
                Case WM_MOUSEMOVE
                    RaiseEvent MouseMove(Nothing, Nothing)
                Case WM_MOUSEWHEEL, WM_MOUSEHWHEEL
                Case Else
                    Console.WriteLine(wParam)
            End Select
        End If
        Return CallNextHookEx(hhk, nCode, wParam, lParam)
    End Function

    Private Structure API_POINT
        Public x As Integer
        Public y As Integer
    End Structure

    Private Structure MSLLHOOKSTRUCT
        Public pt As API_POINT
        Public mouseData As UInteger
        Public flags As UInteger
        Public time As UInteger
        Public dwExtraInfo As IntPtr
    End Structure

    Private Const WM_MOUSEWHEEL As UInteger = &H20A
    Private Const WM_MOUSEHWHEEL As UInteger = &H20E
    Private Const WM_MOUSEMOVE As UInteger = &H200
    Private Const WM_LBUTTONDOWN As UInteger = &H201
    Private Const WM_LBUTTONUP As UInteger = &H202
    Private Const WM_MBUTTONDOWN As UInteger = &H207
    Private Const WM_MBUTTONUP As UInteger = &H208
    Private Const WM_RBUTTONDOWN As UInteger = &H204
    Private Const WM_RBUTTONUP As UInteger = &H205
    Private Const WH_MOUSE_LL As Integer = 14

    Private Delegate Function LowLevelMouseHookProc(ByVal nCode As Integer, ByVal wParam As UInteger, ByRef lParam As MSLLHOOKSTRUCT) As Integer

    Private Declare Auto Function LoadLibrary Lib "kernel32" (ByVal lpFileName As String) As IntPtr
    Private Declare Auto Function SetWindowsHookEx Lib "user32.dll" (ByVal idHook As Integer, ByVal lpfn As LowLevelMouseHookProc, ByVal hInstance As IntPtr, ByVal dwThreadId As UInteger) As IntPtr
    Private Declare Function CallNextHookEx Lib "user32" (ByVal hhk As IntPtr, ByVal nCode As Integer, ByVal wParam As UInteger, ByRef lParam As MSLLHOOKSTRUCT) As Integer
    Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hhk As IntPtr) As Boolean



    ' IDisposable
    Protected Overridable Sub Dispose(ByVal disposing As Boolean)
        If Not Me.disposedValue Then
            If disposing Then
                ' TODO: free other state (managed objects).
            End If

            Unhook()
        End If
        Me.disposedValue = True
    End Sub

    ' This code added by Visual Basic to correctly implement the disposablepattern.
    Public Sub Dispose() Implements IDisposable.Dispose
        ' Do not change this code.  Put cleanup code in Dispose(ByValdisposing As Boolean) above.
        Dispose(True)
        GC.SuppressFinalize(Me)
    End Sub

End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:42:33+00:00Added an answer on May 15, 2026 at 7:42 am

    Try this library, it is fairly straightforward and seems to work well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Here is the edited control file (control.ascx): <%@ Control Language=C# AutoEventWireup=true CodeFile=Sale.ascx.cs Inherits=Enmasse.Modules.Demo_Enmasse.Sale
EDIT: Added debugging output with memory locations as suggested by PlasmaHH. I don't understand
EDIT: Changed as I have a different issue with the same code 2nd Edit:
EDIT Leaving this for posterity, but nearly a year later, to get down voted,
Edit: I just moved my HTTPRequest code into the onCreate, and now all of
EDIT: More detail here. Basically if you 1. open a tab1 to url1 (GET
EDIT: void print(const int *v, const int size) { FILE *fpIn; fpIn = fopen(char-array.txt,
EDIT: I'd like to get a definitive answer on whether or not it's possible
Edit: Made an official bug report at developers.Facebook.com GETing either of the following: graph.facebook.com/me/photos
EDIT FOR CLARITY: I know what the 'head of empty list' error is and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.