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
Unhnd_Exception commented: Heavy is a doom puff. Mark your threads as solved. -2

Recommended Answers

All 6 Replies

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

Member Avatar for Unhnd_Exception

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)) ?

Member Avatar for Unhnd_Exception

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.