Page 1 of 1

Virtual mouse click inside a webbrowser at a specific x and

Posted: Sun Nov 25, 2012 1:53 am
by skyteam
Hi guys so my problem is that the mouse moves and I don't want it to move here the code I have
Code: Select all
    Declare Function mouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dX As Int32, ByVal dY As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean

    Public Const MOUSE_LEFTDOWN = &H2
    Public Const MOUSE_LEFTUP = &H4


    Private Sub RouletteXPro_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
        Timer2.Enabled = True
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim x As Int32, y As Int32

        'Change 'WebBrowser1.Width\2' and 'WebBrowser1.Height\2' to where ever you want the event to occur
        'but remember to keep it within the webBrowser's size range.
        x = WebBrowser1.Width - 100
        y = WebBrowser1.Height - 100
        'This will click dead center of the webBrowser.
        Call mouse_event(MOUSE_LEFTDOWN, x, y, 0, 0)
        Call mouse_event(MOUSE_LEFTUP, x, y, 0, 0)
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Label1.Text = Val(Label1.Text) - 1
        If Label1.Text = 0 Then
            Timer1.Enabled = False
        End If

    End Sub
but this does not work this is in visual basic 2010

Re: Virtual mouse click inside a webbrowser at a specific x and

Posted: Sun Nov 25, 2012 12:18 pm
by skyteam
= ( 30 views but no one can help I am about to give up on this code

Re: Virtual mouse click inside a webbrowser at a specific x and

Posted: Sun Nov 25, 2012 4:47 pm
by mandai
the mouse moves and I don't want it to move
It would probably be easier if you used this code:
Code: Select all
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Dim x As Integer = WebBrowser1.Width - 100
        Dim y As Integer = WebBrowser1.Height - 100

        Cursor.Position = New Point(x, y)
    End Sub
This will move the cursor to the point at x and y.

Re: Virtual mouse click inside a webbrowser at a specific x and

Posted: Sun Nov 25, 2012 5:48 pm
by CodenStuff
The mouse has to move in order for it to click in the spot you want to click. Maybe you could store the current mouse coordinates before doing the click and then return the mouse to that point afterwards.

If your trying to click a button or something on a web page then it would be easier and better to use the element invoke click method instead :?

Re: Virtual mouse click inside a webbrowser at a specific x and

Posted: Mon Nov 26, 2012 3:12 am
by skyteam
CodenStuff wrote:
The mouse has to move in order for it to click in the spot you want to click. Maybe you could store the current mouse coordinates before doing the click and then return the mouse to that point afterwards.

If your trying to click a button or something on a web page then it would be easier and better to use the element invoke click method instead :?
I have thought of that, thing is that I would like the form to minimize and still keep clicking the X and Y positions there is more then one