How to control mouse and clicks with VB6?

Discussion in 'Programming General' started by CruZr, Oct 1, 2008.

How to control mouse and clicks with VB6?
  1. Unread #1 - Oct 1, 2008 at 3:05 PM
  2. CruZr
    Joined:
    Aug 9, 2008
    Posts:
    969
    Referrals:
    0
    Sythe Gold:
    0

    CruZr Apprentice
    Banned

    How to control mouse and clicks with VB6?

    I HAVE googled like 40 different combination's of search's, and no results were helpful.

    :(

    Any help?

    EDIT: I found these.
    Code:
    Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
    Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
        Public Const MOUSEEVENTF_LEFTDOWN = &H2
        Public Const MOUSEEVENTF_LEFTUP = &H4
        Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
        Public Const MOUSEEVENTF_MIDDLEUP = &H40
        Public Const MOUSEEVENTF_RIGHTDOWN = &H8
        Public Const MOUSEEVENTF_RIGHTUP = &H10
        Public Const MOUSEEVENTF_MOVE = &H1
    Public Type POINTAPI
        x As Long
        y As Long
        End Type
    
    Public Function LeftClick1(ByVal x As Long, ByVal y As Long)
        SetCursorPos x, y
        mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
        Sleep 50
        mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
    End Function
    Public Function GetX() As Long
        Dim n As POINTAPI
        GetCursorPos n
        GetX = n.x
    End Function
    
    ' Function to get mouse y-position
    Public Function GetY() As Long
        Dim n As POINTAPI
        GetCursorPos n
        GetY = n.y
    End Function
    
    ' Sub to emulate left button click (down + up)
    Public Sub LeftClick()
        LeftDown
        LeftUp
    End Sub
    
    ' Sub to emulate left button down
    Public Sub LeftDown()
        mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
    End Sub
    
    ' Sub to emulate left button up
    Public Sub LeftUp()
        mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
    End Sub
    
    ' Sub to emulate middle button click (down + up)
    Public Sub MiddleClick()
        MiddleDown
        MiddleUp
    End Sub
    
    ' Sub to emulate middle button down
    Public Sub MiddleDown()
        mouse_event MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0
    End Sub
    
    ' Sub to emulate middle button up
    Public Sub MiddleUp()
        mouse_event MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0
    End Sub
    
    ' Sub to emulate right button click (down + up)
    Public Sub RightClick()
        RightDown
        RightUp
    End Sub
    
    ' Sub to emulate right button down
    Public Sub RightDown()
        mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
    End Sub
    
    ' Sub to emulate right button up
    Public Sub RightUp()
        mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
    End Sub
    
    ' Sub to move mouse position with x,y
    Public Sub MoveMouse(xMove As Long, yMove As Long)
        mouse_event MOUSEEVENTF_MOVE, xMove, yMove, 0, 0
    End Sub
    
    ' Sub to set mouse position to x,y
    Public Sub SetMousePos(xPos As Long, yPos As Long)
        SetCursorPos xPos, yPos
    End Sub



    But I can't use any of the commands.
    Any help on that?
     
  3. Unread #2 - Oct 7, 2008 at 12:04 AM
  4. demonavenger
    Joined:
    Feb 25, 2007
    Posts:
    536
    Referrals:
    0
    Sythe Gold:
    0

    demonavenger Forum Addict
    $5 USD Donor

    How to control mouse and clicks with VB6?

  5. Unread #3 - Oct 7, 2008 at 3:32 AM
  6. rofloller
    Referrals:
    0

    rofloller Guest

    How to control mouse and clicks with VB6?

    Could you tell WHY you can't use them? I see that declaring is "Public" so you have to put them in a module i think.
     
< [code] RuneScape password check | Crack Me (Testing weird password thing) Please Help >

Users viewing this thread
1 guest


 
 
Adblock breaks this site