Sign in to follow this  
Followers 0
Solance

Um RS Auto Doer

1 post in this topic

#1 ·  Posted (edited)

Well i have just been messing with auto it for around a hour and this just just a heavy modification of the miner program ((great base for any gamebot really thanks for that)) basically i just added the capability for it to look for two pixels and then click the middle point between those two points that way you can just click one feature color monsters for instance on the head/face and one on the body.

This can pretty much do anything that can be color sensitive.

((I know this is probally a noob thing or something but its my frist work with autoit and it makes me happy))

Works like a charm for autofighting in RS.

EDIT: Working on the auto loot and auto bury bones features.

#NoTrayIcon
#include <GUIConstants.au3>
#include <Misc.au3>

HotKeySet("!^x", "Abort")

Global $CurrentColor = "946917"
Global $CurrentColorTwo = "1D522E"
Global $CurrentColorDead = "F9F8F8"
Global $StartX = IniRead("MineData.ini", "Pos", "X",0)
Global $StartY = IniRead("MineData.ini", "Pos", "Y",0)
Global $x = $StartX, $y = $StartY
Global $ScanWidth = 110, $ScanHeight = 120
Global $T1[5],$T2[5]
Global $SleepCheck = 500, $SleepMine = 40000
Global $Idle = 0
Global $MoveMode = True
Global $AppTitle = "RS Auto-Doer"

;beta below
Global $Sens = IniRead("MineData.ini", "Beta", "Sensitifity", 8)
Global $AverageX, $AverageY, $i

$GUI = GUICreate($AppTitle,220,40,$x,$y,$WS_POPUP)
$ColorLabel = GUICtrlCreateLabel("Color One",0,1,110,20,$SS_CENTER)
$ColorLabelTwo = GUICtrlCreateLabel("Color Two",1,1,220,40,$SS_CENTER)
$ColorLabelBones = GUICtrlCreateLabel("Color Two",1,1,220,40,$SS_CENTER)
SetColor()
$Sleep = GUICtrlCreateEdit("Stopped", 0, 20,110,20,$ES_AUTOVSCROLL+$ES_AUTOHSCROLL+$ES_READONLY+$ES_CENTER)
GUICtrlSetBkColor(-1,0xFFFFFF)
GUISetState()
WinSetOnTop($GUI,"",1)

$menu   = GUICtrlCreateContextMenu ($ColorLabel)
$Start = GUICtrlCreateMenuitem ("Start!", $menu,-1,1)
$Stop = GUICtrlCreateMenuitem ("Stop", $menu,-1,1)
GUICtrlSetState(-1,$GUI_CHECKED)
GUICtrlCreateMenuitem ("",$menu)
$Time1Menu = GUICtrlCreateMenu ("Check Interval", $menu)
    $T1[0] = GUICtrlCreateMenuitem ("200 ms", $Time1Menu,-1,1)
    $T1[1] = GUICtrlCreateMenuitem ("500 ms", $Time1Menu,-1,1)
    GUICtrlSetState(-1,$GUI_CHECKED)
    $T1[2] = GUICtrlCreateMenuitem ("1 sec", $Time1Menu,-1,1)
    $T1[3] = GUICtrlCreateMenuitem ("2 sec", $Time1Menu,-1,1)
    $T1[4] = GUICtrlCreateMenuitem ("Custom", $Time1Menu,-1,1)
$Time2Menu = GUICtrlCreateMenu ("Auto Interval", $menu)
    $T2[0] = GUICtrlCreateMenuitem ("1 sec", $Time2Menu,-1,1)
    $T2[1] = GUICtrlCreateMenuitem ("2 sec", $Time2Menu,-1,1)
    $T2[2] = GUICtrlCreateMenuitem ("4 sec", $Time2Menu,-1,1)
    GUICtrlSetState(-1,$GUI_CHECKED)
    $T2[3] = GUICtrlCreateMenuitem ("6 sec", $Time2Menu,-1,1)
    $T2[4] = GUICtrlCreateMenuitem ("Custom", $Time2Menu,-1,1)
GUICtrlCreateMenuitem ("",$menu)
$move = GUICtrlCreateMenuitem ("Move Screen", $menu)
$Resize = GUICtrlCreateMenuitem ("Set Scansize", $menu)
$Colormenu = GUICtrlCreateMenu ("Select Color", $menu)
    $Pick = GUICtrlCreateMenuitem ("Set Color 1", $Colormenu)
    $Pick2 = GUICtrlCreateMenuitem ("Set Color 2", $Colormenu)
    $Pickdead = GUICtrlCreateMenuitem ("Pick Death Indicator", $Colormenu)
    
GUICtrlCreateMenuitem ("",$menu)
$Preferences = GUICtrlCreateMenuitem ("Preferences", $menu)
$Help = GUICtrlCreateMenuitem ("Help", $menu)
GUICtrlCreateMenuitem ("",$menu)
$Exit = GUICtrlCreateMenuitem ("Exit", $menu)


    $Top = GUICreate("Top Line", $ScanWidth, 2,$x,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Left = GUICreate("Left Line", 2, $ScanHeight,$x,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Right = GUICreate("Right Line", 2, $ScanHeight,$x + $ScanWidth - 2,$y + 40,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Bottom = GUICreate("Bottom Line", $ScanWidth, 2,$x,$y + 40 + $ScanHeight,$WS_POPUP,-1,$GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()


HotKeySet("^f","DisplayColor")
HotKeySet("^z","Start")
HotKeySet("^x","Stop")
HotKeySet("^x","Stop")
HotKeySet("^a","Move")

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Start
            Check()
        Case $msg = $Stop
            AdlibDisable()
            GUICtrlSetData($Sleep,"Stopped")
        Case $msg = $ColorLabel
            $NewColor = _ChooseColor(2,$CurrentColor,2)
            If Not @error Then
                $CurrentColor = $NewColor
                SetColor()
            EndIf
        Case $msg = -3
            Exit
        Case $msg = $move
            Stop()
            $MoveMode = True
            While 1
                $MousePos = MouseGetPos()
                WinMove($GUI,"", $MousePos[0],$MousePos[1])
                
                WinMove($Top,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Left,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Right,"", $MousePos[0]+ $ScanWidth - 2,$MousePos[1]+40)
                WinMove($Bottom,"", $MousePos[0],$MousePos[1]+ 40 + $ScanHeight)
                
                $x = $MousePos[0]
                $y = $MousePos[1]
                
                If _IsPressed(01) Then
                    ExitLoop
                EndIf
            WEnd
        Case $msg = $Pick
            While 1
                $MousePos = MouseGetPos()
                If Not @error Then
                    $NewColor = PixelGetColor($MousePos[0],$MousePos[1])
                    GUICtrlSetBkColor($ColorLabel,$NewColor)
                    GUISetBkColor($NewColor,$GUI)
                EndIf
                Sleep(200)
                If _IsPressed(01) Then
                    ExitLoop
                EndIf
            WEnd
            If $NewColor <> -1 Then
                $CurrentColor = $NewColor
            EndIf
            SetColor()
        Case $msg = $Pick2
            While 1
                $MousePos = MouseGetPos()
                If Not @error Then
                    $NewColor = PixelGetColor($MousePos[0],$MousePos[1])
                    GUICtrlSetBkColor($ColorLabelTwo,$NewColor)
                    GUISetBkColor($NewColor,$GUI)
                EndIf
                Sleep(200)
                If _IsPressed(01) Then
                    ExitLoop
                EndIf
            WEnd
            If $NewColor <> -1 Then
                $CurrentColorTwo = $NewColor
            EndIf
            SetColor()  
        Case $msg = $Pickdead
            While 1
                $MousePos = MouseGetPos()
                If Not @error Then
                    $NewColor = PixelGetColor($MousePos[0],$MousePos[1])
                    GUICtrlSetBkColor($ColorLabelTwo,$NewColor)
                    GUISetBkColor($NewColor,$GUI)
                EndIf
                Sleep(200)
                If _IsPressed(01) Then
                    ExitLoop
                EndIf
            WEnd
            If $NewColor <> -1 Then
                $CurrentColorDead = $NewColor
            EndIf
            SetColor()  
        Case $msg = $Resize
            Resize()
        Case $msg = $Preferences
            Preferences()
        Case $msg = $Exit
            Exit
        Case $msg = $T1[0]
            $SleepCheck = 200
        Case $msg = $T1[1]
            $SleepCheck = 500
        Case $msg = $T1[2]
            $SleepCheck = 1000
        Case $msg = $T1[3]
            $SleepCheck = 2000
        Case $msg = $T1[4]
            $Input = Number(InputBox("Custom Checking Time", "How many ms do you want to wait?", $SleepCheck,"", 200,162,$x+111,$y))
            If (Not @error) AND (IsNumber($Input)) AND ($Input <> 0) Then
                $SleepCheck = Round($Input)
            Else
                $SleepCheck = 500
                GUICtrlSetState($T1[1],$GUI_CHECKED)
                GUICtrlSetState($T1[4],$GUI_UNCHECKED)
            EndIf
        Case $msg = $T2[0]
            $SleepMine = 1000
        Case $msg = $T2[1]
            $SleepMine = 2000
        Case $msg = $T2[2]
            $SleepMine = 4000
        Case $msg = $T2[3]
            $SleepMine = 6000
        Case $msg = $T2[4]
            $Input = Number(InputBox("Custom Mining Time", "How many ms do you want to wait?", $SleepMine,"", 200,162,$x+111,$y))
            If (Not @error) AND (IsNumber($Input)) AND ($Input <> 0) Then
                $SleepMine = Round($Input)
            Else
                $SleepMine = 4000
                GUICtrlSetState($T2[3],$GUI_CHECKED)
                GUICtrlSetState($T2[4],$GUI_UNCHECKED)
            EndIf
        
    EndSelect
WEnd

Func Check()
    Sleep(Random(0,500,1))
    $Pixel = PixelSearch($x+2,$y+42,$x+2+$ScanWidth,$y+42+$ScanHeight,$CurrentColor,$Sens)
    $PixelTwo = PixelSearch($x+2,$y+42,$x+2+$ScanWidth,$y+42+$ScanHeight,$CurrentColorTwo,$Sens)
    $fighting = False
    If Not @error Then
        MouseClick("Left", (($Pixel[0]+$PixelTwo[0])/2),(($Pixel[1]+$PixelTwo[1])/2),1,2)
        GUICtrlSetData($Sleep,"Mining | " & $SleepMine & " ms")
        $Idle = 0
        
        AdlibEnable("Check", $SleepMine)
        
        
    Else
        GUICtrlSetData($Sleep,"Checking | " & $SleepCheck & " ms")
        $Idle += $SleepCheck
        If $Idle >= 60000 Then
            MouseClick("Left")
            $Idle = 0
        EndIf
        AdlibEnable("Check", $SleepCheck)
    EndIf
EndFunc

Func DisplayColor()
    InputBox("Copy & Paste Box", "This is the variable $CurrentColor:", $CurrentColor)
EndFunc

Func Resize()
    HotKeySet("^a")
    Stop()
    $MoveMode = True
    While 1
        $MousePos = MouseGetPos()
        
        WinMove($Top,"", $x,$y+40,$ScanWidth,2)
        WinMove($Left,"", $x,$y+40,2,$ScanHeight)
        WinMove($Right,"", $x+ $ScanWidth - 2,$y+40,2,$ScanHeight)
        WinMove($Bottom,"", $x,$y+ 40 + $ScanHeight,$ScanWidth,2)
        
        If Not (($MousePos[0] - $x + 1) <= 40) Then
            $ScanWidth = $MousePos[0] - $x + 1
        EndIf
        If Not (($MousePos[1] - $y - 39) <= 40) Then
            $ScanHeight = $MousePos[1] - $y - 39
        EndIf
        
        If _IsPressed(01) Then
            ExitLoop
        EndIf
    WEnd
    HotKeySet("^a","Move")
EndFunc

Func SetColor()
    GUICtrlSetBkColor($ColorLabel,$CurrentColor)
    GUISetBkColor($CurrentColor,$GUI)
EndFunc

Func Abort()
    AdlibDisable()
    HotKeySet("!^x")
    SplashTextOn("Alert", "Emergency Exit", 200,30)
    Sleep(800)
    Exit
EndFunc

Func Start()
    Check()
    GUICtrlSetState($Stop,$GUI_UNCHECKED)
    GUICtrlSetState($Start,$GUI_CHECKED)
EndFunc

Func Stop()
    AdlibDisable()
    GUICtrlSetData($Sleep,"Stopped")
    AdlibDisable()
    GUICtrlSetData($Sleep,"Stopped")
    GUICtrlSetState($Stop,$GUI_CHECKED)
    GUICtrlSetState($Start,$GUI_UNCHECKED)
EndFunc

Func Move()
    If $MoveMode Then
        Stop()
        SetProgramPos($StartX,$StartY)
    Else
        SetProgramPos($x,$y)
    EndIf
    $MoveMode = Not $MoveMode
EndFunc

Func SetProgramPos($x,$y)
    WinMove($GUI,"", $x,$y)
        
    WinMove($Top,"", $x,$y+40)
    WinMove($Left,"", $x,$y+40)
    WinMove($Right,"", $x+ $ScanWidth - 2,$y+40)
    WinMove($Bottom,"", $x,$y+ 40 + $ScanHeight)
EndFunc

Func Preferences()
    Stop()
    $Pref = GUICreate("Preferences", 453, 462)
    
; Left side
    GUICtrlCreateLabel("The colors " & $AppTitle & " looks for are below." & @CRLF & "The color can be a hex or a decimal. To get a color use the ""Select Color > By Screen Color"" mode and press ""Ctrl + F""", 5, 5, 233, 52)
    
    GUICtrlCreateGroup("Colors", 0, 55, 240, 285)
    $InputClay = GUICtrlCreateInput($ColorClay, 105, 75, 121, 21)
    GUICtrlCreateLabel("Clay", 10, 80, 43, 17)
    $InputCopper = GUICtrlCreateInput($ColorCopper, 105, 100, 121, 21)
    GUICtrlCreateLabel("Copper", 10, 105, 53, 17)
    $InputTin = GUICtrlCreateInput($ColorTin, 105, 125, 121, 21)
    GUICtrlCreateLabel("Tin", 10, 130, 53, 17)
    $InputIron = GUICtrlCreateInput($ColorIron, 105, 150, 121, 21)
    GUICtrlCreateLabel("Iron", 10, 155, 53, 17)
    $InputSilver = GUICtrlCreateInput($ColorSilver, 105, 175, 121, 21)
    GUICtrlCreateLabel("Silver", 10, 180, 53, 17)
    $InputCoal = GUICtrlCreateInput($ColorCoal, 105, 200, 121, 21)
    GUICtrlCreateLabel("Coal", 10, 205, 53, 17)
    $InputGold = GUICtrlCreateInput($ColorGold, 105, 225, 121, 21)
    GUICtrlCreateLabel("Gold", 10, 230, 53, 17)
    $InputMithril = GUICtrlCreateInput($ColorMithril, 105, 250, 121, 21)
    GUICtrlCreateLabel("Mithril", 10, 255, 53, 17)
    $InputAddy = GUICtrlCreateInput($ColorAddy, 105, 275, 121, 21)
    GUICtrlCreateLabel("Adamantite", 10, 280, 53, 17)
    $InputRunite = GUICtrlCreateInput($ColorRunite, 105, 300, 121, 21)
    GUICtrlCreateLabel("Runite", 10, 305, 53, 17)
    
    GUICtrlCreateLabel("These represent the starting point for the program. They are also the coordinates used with Ctrl + A.", 0, 345, 239, 47)
    
    GUICtrlCreateGroup("X and Y", 0, 380, 240, 50)
    
    $InputX = GUICtrlCreateInput($StartX, 30, 400, 86, 21)
    $InputY = GUICtrlCreateInput($StartY, 120, 400, 86, 21)
    
;Right side
    
    GUICtrlCreateLabel("The right side contains Beta functions only. These are more advanced and may cause unexplainable errors.", 245, 5, 204, 42)
    
    GUICtrlCreateGroup("Beta Options", 245, 55, 205, 285)
        $CenterCheckbox = GUICtrlCreateCheckbox("", 255, 75, 187, 17)
        $ColorCheckbox = GUICtrlCreateCheckbox("", 255, 100, 187, 17)
        GUICtrlCreateLabel("Color match sensitivity. Move the slider to the left for a harder match.", 255, 125, 179, 27)
        $SensSlider = GUICtrlCreateSlider(255, 155, 180, 30)
        GUICtrlSetLimit(-1,20,1)
        GUICtrlSetData(-1,$Sens)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    GUICtrlCreateGroup("Drop Options", 250, 245, 195, 85)
        $DropNormal = GUICtrlCreateRadio("", 260, 265, 113, 17)
        $DropMagic = GUICtrlCreateRadio("", 260, 285, 113, 17)
        $DropNone = GUICtrlCreateRadio("No Drop (Default)", 260, 305, 113, 17)
        GUICtrlSetState(-1,$GUI_CHECKED)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    
;Bottom Buttons
    $DefaultButton = GUICtrlCreateButton("Default Values", 5, 435, 135, 25)
    $OkButton = GUICtrlCreateButton("OK", 145, 435, 90, 25)
    GUICtrlSetState(-1,$GUI_FOCUS)
    
    GUISetState(@SW_SHOW)
    WinSetOnTop($Pref, "", 1)
    
    While 1
        $msg = GuiGetMsg()
        Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $OkButton
            IniWrite("MineData.ini", "Colors", "Clay", GUICtrlRead($InputClay))
            IniWrite("MineData.ini", "Colors", "Copper", GUICtrlRead($InputCopper))
            IniWrite("MineData.ini", "Colors", "Tin", GUICtrlRead($InputTin))
            IniWrite("MineData.ini", "Colors", "Iron", GUICtrlRead($InputIron))
            IniWrite("MineData.ini", "Colors", "Silver", GUICtrlRead($InputSilver))
            IniWrite("MineData.ini", "Colors", "Coal", GUICtrlRead($InputCoal))
            IniWrite("MineData.ini", "Colors", "Gold", GUICtrlRead($InputGold))
            IniWrite("MineData.ini", "Colors", "Mithril", GUICtrlRead($InputMithril))
            IniWrite("MineData.ini", "Colors", "Addy", GUICtrlRead($InputAddy))
            IniWrite("MineData.ini", "Colors", "Runite", GUICtrlRead($InputRunite))
            
            IniWrite("MineData.ini", "Pos", "X", GUICtrlRead($InputX))
            IniWrite("MineData.ini", "Pos", "Y", GUICtrlRead($InputY))
            
            $ColorClay = GUICtrlRead($InputClay)
            $ColorCopper = GUICtrlRead($InputCopper)
            $ColorTin = GUICtrlRead($InputTin)
            $ColorIron = GUICtrlRead($InputIron)
            $ColorSilver = GUICtrlRead($InputSilver)
            $ColorCoal = GUICtrlRead($InputCoal)
            $ColorGold = GUICtrlRead($InputGold)
            $ColorMithril = GUICtrlRead($InputMithril)
            $ColorAddy = GUICtrlRead($InputAddy)
            $ColorRunite = GUICtrlRead($InputRunite)
            
    ;beta below
            
            If GUICtrlRead($CenterCheckbox) = $GUI_CHECKED Then
                IniWrite("MineData.ini", "Beta", "CenterOnOre", 1)
            ElseIf GUICtrlRead($CenterCheckbox) = $GUI_UNCHECKED Then
                IniWrite("MineData.ini", "Beta", "CenterOnOre", 0)
            EndIf
            
            If GUICtrlRead($ColorCheckbox) = $GUI_CHECKED Then
                IniWrite("MineData.ini", "Beta", "ColorAverage", 1)
            ElseIf GUICtrlRead($ColorCheckbox) = $GUI_UNCHECKED Then
                IniWrite("MineData.ini", "Beta", "ColorAverage", 0)
            EndIf
            
            $Sens = GUICtrlRead($SensSlider)
            IniWrite("MineData.ini", "Beta", "Sensitifity", $Sens)
            
            ExitLoop
        Case $msg = $DefaultButton
            FileDelete("MineData.ini")
            MsgBox(0, $AppTitle, "Default values set, please restart " & $AppTitle)
            Exit
        EndSelect
    WEnd
    GUIDelete()
EndFunc
Edited by Solance

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0