5 Replies - 490 Views - Last Post: 28 September 2013 - 01:40 PM Rate Topic: -----

#1 JoshSoltys  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-September 13

Vb 2010 Mouse Click in webbrowsercontrol?

Posted 28 September 2013 - 12:31 PM

Hello my name is Josh and im new to the forum. First of all I just want to say that I didn't see a section for vb 2010 so this was the best place I could think to post.

So im basically developing a program that can record mouse movement and clicks then replay them on a WebBrowserControl.


So recording the movement is easy I just added the mouseposition.x to a listbox and mouseposition.y to a listbox with a timer looping every 10 intervals. To replay them I simply:

MousexList.selectedindex = 0
MouseyList.selectedindex = 0

mouseposition.x = mousexlist.selecteditem
mouseposition.y = mouseylist.selecteditem

mousexlist.selectedindex + 1
mouseylist.selectedindex + 1





Now I thought recording the clicks would be just as easy... So I added a MouseUp and MouseDown Sub.




Private Sub myBot_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        Select Case e.Button
            Case MouseButtons.Left
                LeftClick = True
            Case MouseButtons.Right
                RightClick = True
        End Select
    End Sub

    Private Sub myBot_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
        Select Case e.Button
            Case MouseButtons.Left
                LeftClick = False
            Case MouseButtons.Right
                RightClick = False
        End Select
    End Sub

    If rightclick = true or leftclick = true then
    








Now basiclly when recording if rightclick or leftclick = true then

Is This A Good Question/Topic? 0
  • +

Replies To: Vb 2010 Mouse Click in webbrowsercontrol?

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3354
  • View blog
  • Posts: 11,360
  • Joined: 12-December 12

Re: Vb 2010 Mouse Click in webbrowsercontrol?

Posted 28 September 2013 - 12:47 PM

Moved to VB.NET forum.

What is the purpose of your Bot?
Was This Post Helpful? 0
  • +
  • -

#3 JoshSoltys  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-September 13

Re: Vb 2010 Mouse Click in webbrowsercontrol?

Posted 28 September 2013 - 12:55 PM

Hello my name is Josh and im new to the forum. First of all I just want to say that I didn't see a section for vb 2010 so this was the best place I could think to post.

So im basically developing a program that can record mouse movement and clicks then replay them on a WebBrowserControl.


So this program has 3 loops
- Recordingloop (Records mouse movement and clicks)
- PlayBackloop (plays back recorded mouse movement and clicks)
- GeneralProgramLoop (Loop that always runs checking for changes and what not)

 'RecordingLoop
    Private Sub RecordingLoop_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RecordingLoop.Tick
        MousexList.Items.Add(MousePosition.X)
        MouseyList.Items.Add(MousePosition.Y)

        If LeftClick = True Then
            MousexList.Items.Add("Left Click")
            MouseyList.Items.Add("Left Click")
        End If
        If RightClick = True Then
            MousexList.Items.Add("Right Click")
            MouseyList.Items.Add("Right Click")
        Else
            MousexList.Items.Add(MousePosition.X)
            MouseyList.Items.Add(MousePosition.Y)
        End If

    End Sub

    'RunningLoop
    Private Sub RunningLoop_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunningLoop.Tick
        Dim TotalCount As Integer = MousexList.Items.Count - 1
        Dim SelectedIndex As String = MousexList.SelectedIndex

        If TotalCount = SelectedIndex Then
            RunningLoop.Stop()
        Else
            Cursor.Position = New Point _
          (MousexList.SelectedItem, MouseyList.SelectedItem)

            MousexList.SelectedIndex = MousexList.SelectedIndex + 1
            MouseyList.SelectedIndex = MouseyList.SelectedIndex + 1

            If MousexList.SelectedItem = "Left Click" Then
                PerformMouseClick("LClick")
                MousexList.SelectedIndex = MousexList.SelectedIndex + 1
                MouseyList.SelectedIndex = MouseyList.SelectedIndex + 1
            End If
            If MousexList.SelectedItem = "Right Click" Then
                PerformMouseClick("RClick")
                MousexList.SelectedIndex = MousexList.SelectedIndex + 1
                MouseyList.SelectedIndex = MouseyList.SelectedIndex + 1
            End If
        End If
    End Sub

'BotLoop / general loop
    Private Sub BotLoop_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BotLoop.Tick

        'Running
        If Running = True Then
            RunningLoop.Start()
        Else
            RunningLoop.Stop()
        End If

        'Recording
        If Recording = True Then
            RecordingLoop.Start()
        Else
            RecordingLoop.Stop()
        End If
    End Sub



So now im running into troubles getting the 'Preform "LClick"' or 'Preform "RClick"' to preform the clicks on the web browser?? However it works perfect anywhere on the form. Just not on the WebBrowserControl or anywhere outside of the program? My main goal is to get the 'Preform "LClick"' and 'Preform "RClick"' to work on my webbrowser control. Ive googled around and found little helpful information. Im not looking to be given the answer as i use vb as a learning tool. Any help would be muchly appreciated.

(I ran into a few errors while writing this post so i apologize in advance for double posting or anything. Thank you!)

I forgot to add the Sub im using for the 'Preform "LClick"' and 'Preform "RClick"' soooo here it is:

   'Mouse Events
    Private Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As IntPtr)

    Private Sub PerformMouseClick(ByVal LClick_RClick_DClick As String)
        Const MOUSEEVENTF_LEFTDOWN As Integer = 2
        Const MOUSEEVENTF_LEFTUP As Integer = 4
        Const MOUSEEVENTF_RIGHTDOWN As Integer = 6
        Const MOUSEEVENTF_RIGHTUP As Integer = 8
        If LClick_RClick_DClick = "RClick" Then
            mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, IntPtr.Zero)
            mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, IntPtr.Zero)
        ElseIf LClick_RClick_DClick = "LClick" Then
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
        ElseIf LClick_RClick_DClick = "DClick" Then
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
        End If
    End Sub


Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3354
  • View blog
  • Posts: 11,360
  • Joined: 12-December 12

Re: Vb 2010 Mouse Click in webbrowsercontrol?

Posted 28 September 2013 - 12:58 PM

Topics merged.

@OP I've merged your topics as they are on the same subject.

[I've noticed that the two sets of code are different though, so the topics may be split again. We'll see.]

But I still want to know the purpose of your Bot?

This post has been edited by andrewsw: 28 September 2013 - 01:01 PM

Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9081
  • View blog
  • Posts: 34,127
  • Joined: 12-June 08

Re: Vb 2010 Mouse Click in webbrowsercontrol?

Posted 28 September 2013 - 01:34 PM

Agreed- what are you trying to bot out?
Was This Post Helpful? 0
  • +
  • -

#6 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3717
  • View blog
  • Posts: 5,981
  • Joined: 08-June 10

Re: Vb 2010 Mouse Click in webbrowsercontrol?

Posted 28 September 2013 - 01:40 PM

DIC has a strict policy against aiding in the creation of programs that are malicious in nature. A web browser mouse-click bot would certainly qualify, seeing as the only use of such a program would be to mimic expected human interactions with sites. If sites wanted programs to be able to carry out the interaction you intend to replace with this bot, they would most likely provide an API you could use.

So no, we will not help you create this program. - PM me if you have any questions or comments. Also note that promises of non-malicious intentions for these type of programs fall on deaf ears around here. Even if we were to believe that, it wouldn't matter. The public answer would help others with less noble goals.

Closed
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1