Hello! My first post here. I have a problem. I want to make a Windows form that it's exist a button, and if you click that button, then the mouse cursor will move to a choosen X and Y coordinates and after that the cursor will click left or right. But how do I make that?

A question more!
On my window form (the program). Their is a progressbar and a webbrowser. How can i make so the click-function waint untill the progressbar is 100% loaded, then click? The progressbar is follow the webbrwoser, you know :)


Here is my code.

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click  
        Windows.Forms.Cursor.Position = New System.Drawing.Point(320, 138) 
        ' here i want to have the "wait-to-the-progressbar-is-100%-loaded"
        ' here i want to click-function left or right. 
    End Sub

Edited 5 Years Ago by heavy.is.happy: n/a

Comments
Heavy is a doom puff. Mark your threads as solved.

I don't understand your code. It's to mutch for one click.
Isn't no easier way to do just one click? Or a dubbleclick? and Rightclick?

I think it was first Windows.Forms.MouseClick.Left() but it wasin't

Edited 5 Years Ago by heavy.is.happy: n/a

Actually, The above link is not needed.

Just move the mouse over the button and call the buttons mouse click event.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Button1_MouseClick(Button1, New MouseEventArgs(Windows.Forms.MouseButtons.Left, 2, 50, 20, 0))

    End Sub

    Private Sub Button1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Left AndAlso e.Clicks = 2 Then
             'Left double click
        End If
    End Sub

okej, i will test that. Comming soon. :)

It's not working.

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Button6_MouseClick(Button6, New MouseEventArgs(Windows.Forms.MouseButtons.Left, 2, 235, 140, 0))
    End Sub


    Private Sub Button6_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button6.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Left AndAlso e.Clicks = 2 Then
            'left doubble click.
        End If
    End Sub

Is the 235, 140 = X, Y?

How do I make a right click and just one left click? Do i just change e.Clicks = 2 to e.Clicks = 1?

can you explain this? , 2, 235, 140, 0)) ?

Edited 5 Years Ago by heavy.is.happy: n/a

Yes just change e.clicks to 1. and yes on the x and y. x and y are not needed if your mouse click event sub is not even using them. just make them 0,0.

In your mouse click event check the e.button variable and do what you want if its left or right.

And the button is not actually going to be pressed. Only the code in your mouse click event sub is going to be run.

It's not working. It does not click or move :P

(Windows.Forms.MouseButtons.Left, 2, 200, 140, 0))
2 = 2 clicks.
200 = x
140 = y
0 = i don't know what this is for use.

its working now with this. But not click.

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Windows.Forms.Cursor.Position = New System.Drawing.Point(200, 140) ' move mouse cursor to X200, Y140.
        Button6_MouseClick(Button6, New MouseEventArgs(Windows.Forms.MouseButtons.Left, 2, 0, 0, 0)) ' I don't know but e.Click has the value 2.
    End Sub

    
    Private Sub Button6_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button6.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Left AndAlso e.Clicks = 2 Then ' if the e.Click has the value 2 -> click twice.
            'I don't know if it click or not???
        End If
    End Sub

Edited 5 Years Ago by heavy.is.happy: n/a

This article has been dead for over six months. Start a new discussion instead.