User:Pluke/clicker

From Wikibooks, open books for an open world
Jump to: navigation, search
Imports MouseKeyboardActivityMonitor
 
Public Class Form1
 
    Dim active As Boolean = True
 
 
    Public Declare Auto Function SetCursorPos Lib "User32.dll" (ByVal X As Integer, ByVal Y As Integer) As Integer
    Public Declare Auto Function GetCursorPos Lib "User32.dll" (ByRef lpPoint As Point) As Integer
    Public 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)
    Public Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
    Public Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
    Public Const MOUSEEVENTF_MIDDLEDOWN = &H20 ' middle button down
    Public Const MOUSEEVENTF_MIDDLEUP = &H40 ' middle button up
    Public Const MOUSEEVENTF_RIGHTDOWN = &H8 ' right button down
    Public Const MOUSEEVENTF_RIGHTUP = &H10 ' right button up
 
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        active = True
 
        Dim temp As Integer = 1000
        temp = txtTime.Text * 60 * 125
        For x = 1 To temp
 
            If active Then
                SetCursorPos(1150, 500) ' Where X and Y are in pixel
                mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
                mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
                System.Threading.Thread.Sleep(8)
                If x Mod 1500 = 0 Then
                    If chkBuy.Checked Then
                        sweepup()
                    End If
                    If chkUpgrade.Checked Then
                        sweepright()
                    End If
                End If
            End If
        Next
    End Sub
 
    Private Sub btnSweep_Click(sender As Object, e As EventArgs) Handles btnSweep.Click
        sweepright()
        sweepup()
    End Sub
 
    Private Sub sweepup()
        Dim ycore As Integer = 810
        Dim ytemp As Integer
 
        If chkAntimatter.Checked = True Then
            ytemp = ycore
            SetCursorPos(2000, ytemp)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            '  System.Threading.Thread.Sleep(1500)
        End If
 
        If chkTimeMachine.Checked = True Then
            ytemp = ycore - 60
            SetCursorPos(2000, ytemp)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            '  System.Threading.Thread.Sleep(1500)
        End If
 
        If chkPortal.Checked = True Then
            ytemp = ycore - 120
            SetCursorPos(2000, ytemp)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            '  System.Threading.Thread.Sleep(1500)
        End If
 
        If chkAlch.Checked = True Then
            ytemp = ycore - 180
            SetCursorPos(2000, ytemp)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            '  System.Threading.Thread.Sleep(1500)
        End If
 
        If chkShipment.Checked = True Then
            ytemp = ycore - 240
            SetCursorPos(2000, ytemp)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            ' System.Threading.Thread.Sleep(1500)
        End If
 
        If chkMine.Checked = True Then
            ytemp = ycore - 300
            SetCursorPos(2000, ytemp)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            '  System.Threading.Thread.Sleep(1500)
        End If
 
        If chkFactory.Checked = True Then
            ytemp = ycore - 360
            SetCursorPos(2000, ytemp)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            ' System.Threading.Thread.Sleep(1500)
        End If
 
        If chkFarm.Checked = True Then
            ytemp = ycore - 420
            SetCursorPos(2000, ytemp)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            '  System.Threading.Thread.Sleep(1500)
        End If
 
        If chkGran.Checked = True Then
            ytemp = ycore - 480
            SetCursorPos(2000, ytemp)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            ' System.Threading.Thread.Sleep(1500)
        End If
 
        If chkCursor.Checked = True Then
            ytemp = ycore - 540
            SetCursorPos(2000, ytemp)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            ' System.Threading.Thread.Sleep(1500)
        End If
 
        '///////////
 
        'For n = 1 To 10
        ' xtemp = xtemp - 60
        ' SetCursorPos(2000, xtemp)
        ' mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        ' mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
        ' System.Threading.Thread.Sleep(1500)
        'Next
 
    End Sub
 
    Private Sub sweepright()
        Dim ytemp As Integer = 1700
 
        For n = 1 To 5
            ytemp = ytemp + 60
            SetCursorPos(ytemp, 170)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            'System.Threading.Thread.Sleep(1500)
        Next
 
    End Sub
 
    Private Sub chkBuy_CheckedChanged(sender As Object, e As EventArgs) Handles chkBuy.CheckedChanged
        If chkBuy.Checked Then
            chkCursor.Checked = True
            chkGran.Checked = True
            chkFarm.Checked = True
            chkFactory.Checked = True
            chkMine.Checked = True
            chkShipment.Checked = True
            chkAlch.Checked = True
            chkPortal.Checked = True
            chkTimeMachine.Checked = True
            chkAntimatter.Checked = True
        Else
            chkCursor.Checked = False
            chkGran.Checked = False
            chkFarm.Checked = False
            chkFactory.Checked = False
            chkMine.Checked = False
            chkShipment.Checked = False
            chkAlch.Checked = False
            chkPortal.Checked = False
            chkTimeMachine.Checked = False
            chkAntimatter.Checked = False
        End If
    End Sub
 
 
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
 
    End Sub
 
    Private Sub MouseKeyEventProvider1_MouseWheel(sender As Object, e As MouseEventArgs) Handles MouseKeyEventProvider1.MouseWheel
        active = False
    End Sub
End Class