Results 1 to 7 of 7

Thread: [2008] Mouse Recorder

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    [2008] Mouse Recorder

    im working on a mouse recorder.. but it will not play the co-ordinates or clicks that i recorded. can somebody tell me what i done wrong or if there is other codes i can use and what they are?
    My current codes:
    Code:
    Public Class Form1
        Dim result As Integer
        Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    
        Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
        Private Const MOUSEEVENTF_ABSOLUTE = &H8000 ' absolute move
        Private Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
        Private Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
        Private Const MOUSEEVENTF_MOVE = &H1 ' mouse move
        Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
        Private Const MOUSEEVENTF_MIDDLEUP = &H40
        Private Const MOUSEEVENTF_RIGHTDOWN = &H8
        Private Const MOUSEEVENTF_RIGHTUP = &H10
    ::::Codes for recording::::
    Code:
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Dim Mouse As Point = Control.MousePosition
            If GetAsyncKeyState(MOUSEEVENTF_LEFTDOWN) Then
                ListBox1.Items.Add("Left")
            End If
            If GetAsyncKeyState(MOUSEEVENTF_RIGHTDOWN) Then
                ListBox1.Items.Add("Right")
            End If
            ListBox1.Items.Add(Mouse.X & "," & Mouse.Y)
        End Sub
    ::::Codes for playing::::
    Code:
        Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
            If ListBox1.Text = "Left" Then
                mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            ElseIf ListBox1.Text = "Right" Then
                mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
            ElseIf ListBox1.SelectedIndex = ListBox1.SelectedIndex + +1 Then
            Else
                MsgBox("A Problem Has Occured")
            End If
        End Sub
    Please Help me with this.. i really need to get this to work

  2. #2

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    Re: [2008] Mouse Recorder

    bump

  3. #3
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: [2008] Mouse Recorder

    Well for one, your GetAsyncKeyState is wrong: GetAsyncKeyState(1) returns the left mouse button and GetAsyncKeyState(2) returns the right button.

    Als, to make a click, you might need to send MOUSEEVENTF_(LEFT/RIGHT)UP right after you send down?

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    Re: [2008] Mouse Recorder

    GetAsyncKeyState(1) returns the left mouse button and GetAsyncKeyState(2) returns the right button
    ok im kind of new at this... could you show me a quick example. ill rep ++ u

  5. #5
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: [2008] Mouse Recorder

    Well, right now you have GetAsyncKeyState(MOUSEEVENTF_LEFTDOWN). Change that to GetAsyncKeyState(1). Then change GetAsyncKeyState(MOUSEEVENTF_RIGHTDOWN) To GetAsyncKeyState(2).

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    Re: [2008] Mouse Recorder

    its still not working with me... any other suggestions?

  7. #7
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: [2008] Mouse Recorder

    To simulate a proper mouse click, I think you'd want to add mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) right after mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0), and same thing with the right mouse button. If that doesn't work, you could try adding a 50 - 150 millisecond pause between the two calls.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width