Creating and Using Objects

Posts 1–3 of 3 · Page 1 of 1
Creating and Using Objects
I have made a injector creating tool awhile back and thought i would release the BASIC code...

Basicly, you create an item and give it a handle... I made a handle so u can drag and drop items, then i made delete (activecontrol) <- only created buttons using getasynckeystate instead of keys_pressed because i like it better and its easier
Timer1.interval = 1, Timer1.enabled = true
Timer2.interval = 1, Timer2.enabled = true
Full Code :
Code:
Public Class Form1
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As IntPtr) As IntPtr
    Dim b As Button
    Dim i As Integer = 0

    Private Sub mousedownButton(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyClass.MouseDown
        Try
            b = sender
        Catch ex As Exception
            b = Nothing
        End Try
    End Sub

    Private Sub mouseupButton(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyClass.MouseUp
        b = Nothing
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        i += 1
        Dim b As New Button
        b.Location = New Point(15, 15)
        b.Text = "Button" & i
        Me.Controls.Add(b)
        AddHandler b.MouseDown, AddressOf Me.mousedownButton
        AddHandler b.MouseUp, AddressOf Me.mouseupButton
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Try
            Dim p As Point = Me.PointToClient(Me.MousePosition)
            b.Location = New Point(p.X, p.Y)
        Catch ex As Exception

        End Try
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Dim delete As Boolean = False

        delete = GetAsyncKeyState(Keys.Delete)
        If delete = True Then
            Me.Controls.Remove(b)
        Else

        End If
    End Sub
End Class
pretty self explanitory... kinda easy but yeah

PS : @abuckau907, if you comment don't tell me i can do this in 1/20 of the code, I'm not a genius like u lol
Also, i had a array for logging all selected items so u can move it but this way is 1/10 the code lol
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
Dim p As Point = Me.PointToClient(Me.MousePosition)
b.Location = New Point(p.X, p.Y)
Catch ex As Exception

End Try
End Sub

Empty catch block? : p

b.Location = Me.PointToClient(Me.MousePosition) // No temporary variable needed, tho it may add clarity.

I'd have used Form_MouseMove instead of timer1, but you specifically said you did it that way on purpose, so, agree to disagree.

edit:
Code:
Dim p As Point = Me.PointToClient(Me.MousePosition)
b.Location = New Point(p.X, p.Y)
Even if you decided to use the temp. variable, you could still just directly assign it to b.location, no need to create another point.
Code:
Dim p As Point = Me.PointToClient(Me.MousePosition)
b.Location = p
Un-needed optimizations as it apparently works as-is, but it doesn't hurt to keep in mind.
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?