How to stimulate a mouse left click when the x, y co-ordinates are provided

Hello All

I am trying to make an application in Visual Basic.NET which stimulates mouse left click.

I am using SendMessageA API with message WM_LBUTTONUP to achieve the same but the problem is that the click takes place at co-ordinates (0,0)

I found out that the reason for this is that i need to pass lparam as follows:-

lower order word specifying the x co-ordinate
and
high order word specifying the y co-ordinate

How do i achive the same using VB.NET


Answer this question

How to stimulate a mouse left click when the x, y co-ordinates are provided

  • WillHart

     

     

    Private shared function Curpos() as position

           return cursor.position

    end function

     

    This will give you screen coordinates.



  • MalG

    Telophase,

    Anytime...

    That user name looks familiar. Have you ever posted on feminist boad or lists

     



  • Reggaeton_King

    Yes that's what i wanted! I was confused on what to pass as arguments because i already had the cursor co-ordinates using GetCursorPos

    Silly me, i need to work more on bitwise operators

    Anyways, thanks a lot ReneeC !!

  • Cassie1

     

     

    Hi telophase,

    Yeah ....I was confused about what you were asking about. I thought may have been asking about SendMessage.

    But I still need more clarification from you. Are you asking where do you get that from to pass to via SendMessage or how do you pass the arguments

     I think you want to do this:

    Static a as integer  =  (x << 16) OR y

     SendMessageA(hwnd, WM_LBUTTONUP< XML:NAMESPACE PREFIX = PH />,0, a)

     



  • mahmut

    I think i didnt put up the question properly.

    What i meant was that how do i pass the screen co-ordinates to the SendMessageA function

    Here's what i mean.... :-

    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Integer) As Integer

    'My Function

    Public Sub Stimulate_Click(hwnd as integer,x as integer,y as integer)
      SendMessageA(hwnd,WM_LBUTTONUP,0,WHAT_DO_I_PUT_HERE)
    End Sub

  • How to stimulate a mouse left click when the x, y co-ordinates are provided