Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[help] realtime mouseclicks
#1
i have a functioin in my rat that takes a screen shot, and i wanted to be able to click on the picturebox and convert the picturebox mouse coordinates to the screen coordinates and simulate a mouseclick. i dont think im doing my math right but ive been working on this for days now any help would be great!

Code:
Public Class Form1
    Dim widthX As Integer
    Dim heightY As Integer
    Dim picWid As Integer
    Dim picHgt As Integer
    Dim widResult As Integer
    Dim hgtResult As Integer
    Dim finalWid As Integer
    Dim finalHgt As Integer
    Dim X As Integer
    Dim Y As Integer

    Public Declare Auto Function SetCursorPos Lib "User32.dll" (ByVal X As Integer, ByVal Y As Integer) As Long
    Public Declare Auto Function GetCursorPos Lib "User32.dll" (ByRef lpPoint As Point) As Long
    Public Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo 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
    Dim tempPos As Point
    Dim R As Long = GetCursorPos(tempPos)
    Sub set_Pos()
        Dim mousePosX As String = PictureBox1.MousePosition.X.ToString
        Dim mousePosY As String = PictureBox1.MousePosition.Y.ToString
        finalWid = mousePosX + widResult
        finalHgt = mousePosY + hgtResult
        X = finalWid
        Y = finalHgt
        SetCursorPos(X, Y)
    End Sub
    Sub mid_Click()
        mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)
        mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)
    End Sub
    Sub drag_Drop()
        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        SetCursorPos(X, Y)
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
    End Sub
  
    Sub Do_LMouseClick()
        Call mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        Call mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
    End Sub
    Sub Do_RMouseClick()
        Call mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
        Call mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles Button1.Click
        Dim BackUpClipboard As String = My.Computer.Clipboard.GetText
        SendKeys.Send("{PRTSC}")
        PictureBox1.Image = My.Computer.Clipboard.GetImage
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles MyBase.Load
        widthX = My.Computer.Screen.Bounds.Width
        heightY = My.Computer.Screen.Bounds.Height
        picWid = PictureBox1.Width
        picHgt = PictureBox1.Height
        widResult = widthX - picWid
        hgtResult = heightY - picHgt
        
    End Sub

    Private Sub PictureBox1_MouseClick(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles PictureBox1.MouseClick
        set_Pos()
        Do_LMouseClick()
       End Sub


End Class
~ Digital-Punk
Reply
#2
Why don't you just make the picture the same size as the victim's desktop resolution? Then you don't have too worry about resizing.
Reply
#3
(12-20-2009, 03:23 PM)Revenger Wrote: Why don't you just make the picture the same size as the victim's desktop resolution? Then you don't have too worry about resizing.

solved thanks for the reply though.Thumbsup
~ Digital-Punk
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)