Jump to content

Another outdated code. :/


Recommended Posts

I have been able to fix 6 or 7 things myself witih Monoceres script, but I dont think this one is just GUI.

#include <StaticConstants.au3>
#include <ProgressConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
;Build on Generator's bot in AutoIt Forums @ http://www.autoitscript.com/forum/index.php?showtopic=70399&st=0&gopid=601549&#entry601549
;UDF by Developers of AutoIt
;heavily modifyed by Sprille
#NoTrayIcon
#include<GUIConstants.au3>
#include <WindowsConstants.au3>
#include<IE.au3>
#include<Misc.au3>

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC", 0)
AutoItSetOption("MouseCoordMode", 2); sets mouse to use client cordinates
AutoItSetOption("PixelCoordMode", 2); set pixel functions to use client cordinates

;----------------------------------------------------------------------------------------
;                         Declare some variables
;----------------------------------------------------------------------------------------

;Standard detail free world 1 column = 30 px spacing = 12
Dim $drop_x_min[4] = [586,628,670,712]
Dim $drop_x_max[4] = [616,658,700,742]

;standard detail free world - 7 rows - 1 row = 30px spacing = 6
Dim $drop_y_min[7] = [355,391,427,463,499,535,571]
Dim $drop_y_max[7] = [385,421,457,493,529,565,601]

Dim $mode = 0, $version = "", $start = 0
Dim $Color[2], $timer[6], $Cords[2] = [0,0], $pos[2] = [0,0]
Dim $menu_cords[2] = [0,0], $dropped
Dim $get_tired = Random(50, 100, 1), $sleeptime
Dim $drop_from_slot

Dim $fail_at, $fail_counter = 0, $failed_slot =""


;-----------------------------------------------------------------------------------------
;                        Setup all inventory slots
;-----------------------------------------------------------------------------------------

Dim $slot[29][4]
dim $i
Dim $row = 0
Dim $column = 0

For $i = 1 to 28
    $slot[$i][0] = $drop_x_min[$column]
    $slot[$i][1] = $drop_x_max[$column]
    $slot[$i][2] = $drop_y_min[$row]
    $slot[$i][3] = $drop_y_max[$row]
    $column+=1
    if $column > 3 Then
        $column = 0
        $row+=1
    EndIf   
Next

HotKeySet("{ESC}", "_StopBot")

_Singleton("Power Training")
_IEErrorHandlerRegister()
#region Welcome GUI
$form0 = GUICreate("Power Training", 400, 70, -1, -1, $WS_CAPTION, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
$label0 = GUICtrlCreateLabel("Welcome to Power Training...Please wait for vertification....", 10, 5, 390, 20, -1)
$progress0 = GUICtrlCreateProgress(10, 25, 240, 20, $PBS_SMOOTH)
$label1 = GUICtrlCreateLabel("Looking for Java plug-in....", 10, 50, 240, 20, -1)
GUISetState(@SW_SHOW, $form0)
For $i = 1 To 100
    GUICtrlSetData($progress0, $i)
    Sleep(5)
Next
If Not _CheckJava() Then
    $label3 = GUICtrlCreateLabel("Get the latest Java", 260, 25, 140, 20, -1)
    GUICtrlSetData($label1, "Please install Java before continuing...")
    _HyperLink($label3)
Else
    GUICtrlCreateLabel("Version: " & $version, 260, 25, 140, 20, -1)
    $label4 = GUICtrlCreateLabel("Start", 370, 50, 30, 20, -1)
    _HyperLink($label4)
EndIf

While Not $mode
    $Info0 = GUIGetCursorInfo($form0)
    If $version == "" Then
        If $Info0[2] And $Info0[4] = $label3 Then
            While _IsPressed("01")
                Sleep(1)
            WEnd
            _GetJava()
            Exit
        EndIf
    ElseIf $Info0[2] And $Info0[4] = $label4 Then
        While _IsPressed("01")
            Sleep(1)
        WEnd
        $mode = 1
        GUIDelete($form0)
    EndIf
    Sleep(1)
WEnd
#endregion Welcome GUI
#region Main GUI

;----------------------------------------------------------------------------------
;                           Setup the GUI
;----------------------------------------------------------------------------------

$form1 = GUICreate("RSClient", 810, 700, -1, -1, -1)

;Create tab page
$tab=GUICtrlCreateTab (20,10,770,125)
GUICtrlSetFont($tab, 9, 400, 0, "Tahoma")

;Create first tab
$tab0=GUICtrlCreateTabitem ("Main")
$button2 = GUICtrlCreateButton("Start Training", 600, 48, 170, 65, -1)
GUICtrlSetFont(-1, 16, 400,0,"Century Gothic")

$status_label = GUICtrlCreateLabel("", 35, 70, 530,20, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400,0,"Century Gothic")

;Create thierd tab
$tab3=GUICtrlCreateTabitem ("Inventory")
;Create the label for the scan slots / drop spot
$scan_slots_label = GUICtrlCreateLabel("Start dropping at slot :", 35, 45, 125,20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$drop_spot = GUICtrlCreateInput (IniRead("power trainer.ini", "inventory", "drop_slot", 2),165,43, 40, 20,$ES_READONLY)
$updown_1 = GUICtrlCreateUpdown($drop_spot)
GUICtrlSetLimit ( $updown_1, 28, 1 )

;Timers for before right click
$label_12 = GUICtrlCreateLabel("Time before right click between:", 255, 45, 190,20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_1 = GUICtrlCreateInput (IniRead("power trainer.ini", "timers", "timer_1", 2),460,43, 40, 20,$ES_READONLY)
$updown_2 = GUICtrlCreateUpdown($timer_1)
GUICtrlSetLimit ( $updown_2, 50, 1 )
$label_13 = GUICtrlCreateLabel("and", 510, 45, 30,20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_2 = GUICtrlCreateInput (IniRead("power trainer.ini", "timers", "timer_2", 5),540,43, 40, 20,$ES_READONLY)
$updown_3 = GUICtrlCreateUpdown($timer_2)
GUICtrlSetLimit ( $updown_3, 50, 1 )

;Timers for before mouse move
$label_13 = GUICtrlCreateLabel("Time before mouse move between:", 255, 75, 210,20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_3 = GUICtrlCreateInput (IniRead("power trainer.ini", "timers", "timer_3", 5),460,73, 40, 20,$ES_READONLY)
$updown_4 = GUICtrlCreateUpdown($timer_3)
GUICtrlSetLimit ( $updown_4, 50, 1 )
$label_14 = GUICtrlCreateLabel("and", 510, 75, 30,20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_4 = GUICtrlCreateInput (IniRead("power trainer.ini", "timers", "timer_4", 10),540,73, 40, 20,$ES_READONLY)
$updown_5 = GUICtrlCreateUpdown($timer_4)
GUICtrlSetLimit ( $updown_5, 50, 1 )

;Timers for before menu click
$label_15 = GUICtrlCreateLabel("Time before menu click between:", 255, 105, 210,20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_5 = GUICtrlCreateInput (IniRead("power trainer.ini", "timers", "timer_5", 2),460,103, 40, 20,$ES_READONLY)
$updown_6 = GUICtrlCreateUpdown($timer_5)
GUICtrlSetLimit ( $updown_5, 50, 1 )
$label_16 = GUICtrlCreateLabel("and", 510, 105, 30,20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_6 = GUICtrlCreateInput (IniRead("power trainer.ini", "timers", "timer_6", 6),540,103, 40, 20,$ES_READONLY)
$updown_7 = GUICtrlCreateUpdown($timer_6)
GUICtrlSetLimit ( $updown_6, 50, 1 )

;create the button for color picking
$label_10 = GUICtrlCreateLabel("When finding this color :", 35, 70, 140,20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")

;this is label for the color display of the picked color
$label_11 = GUICtrlCreateLabel("", 35, 85, 130,35)
GUICtrlSetBkColor ( $label_11,  IniRead("power trainer.ini", "inventory", "color", 4006425))
;Colorpicker button
$button1 = GUICtrlCreateButton("+", 650, 70, 100, 40, -1)
GUICtrlSetCursor(-1, 3)
GUICtrlSetFont(-1, 30, 400)
;create label for colorpicker
$label8 = GUICtrlCreateLabel("Log/Ore Color", 650, 45, 100, 20, $SS_CENTER)
GUICtrlSetFont(-1, 9.5, 400,0,"Tahoma") 

;Create fourth tab
$tab4=GUICtrlCreateTabitem ("Fail-Drop")
;Create the label for the drop
$fail_drop_label = GUICtrlCreateLabel("Hit examine ore random between :", 35, 45, 195,20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$fail_at_1 = GUICtrlCreateInput (IniRead("power trainer.ini", "inventory", "fail_at_1", 6),235,43, 40, 20,$ES_READONLY)
$updown_8 = GUICtrlCreateUpdown($fail_at_1)
GUICtrlSetLimit ( $updown_1, 99, 1 )
$label_17 = GUICtrlCreateLabel("and", 285, 45, 30,20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$fail_at_2 = GUICtrlCreateInput (IniRead("power trainer.ini", "inventory", "fail_at_2", 28),315,43, 40, 20,$ES_READONLY)
$updown_9 = GUICtrlCreateUpdown($fail_at_2)
GUICtrlSetLimit ( $updown_1, 99, 1 )
$label_18 = GUICtrlCreateLabel("drops", 365, 45, 30,20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
;end tab definition
GUICtrlCreateTabitem ("")

;----------------------------------------------------------------------------------
;              Create the explorer object and navigate to free world
;----------------------------------------------------------------------------------

$oIE = _IECreateEmbedded()
$guiactivex = GUICtrlCreateObj($oIE, 20, 10, 770, 680, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))

_IENavigate($oIE, "http://www.runescape.com/game.ws?m=0&j=1", 0)

;----------------------------------------------------------------------------------
;                            set the events for GUI
;----------------------------------------------------------------------------------
;

GUICtrlSetOnEvent ( $updown_1, "drop_spot_selector_changed" )
GUICtrlSetOnEvent ( $updown_2, "timer_1_click" )
GUICtrlSetOnEvent ( $updown_3, "timer_2_click" )
GUICtrlSetOnEvent ( $updown_4, "timer_3_click" )
GUICtrlSetOnEvent ( $updown_5, "timer_4_click" )
GUICtrlSetOnEvent ( $updown_6, "timer_5_click" )
GUICtrlSetOnEvent ( $updown_7, "timer_6_click" )
GUICtrlSetOnEvent ( $updown_8, "fail_at_changed" )
GUICtrlSetOnEvent ( $updown_9, "fail_at_changed" )
GUICtrlSetOnEvent($button2, "_Start")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "_StopBot")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

;----------------------------------------------------------------------------------
;                            Show the GUI
;----------------------------------------------------------------------------------

GUISetState(@SW_SHOW, $form1)

;----------------------------------------------------------------------------------
;                            Init start values
;----------------------------------------------------------------------------------

;init the dropspot in inventory to get cordinates to scan
drop_spot_selector_changed()

;init timer values. All times in GUI are stated in 1/100 of a second
timer_1_click()
timer_2_click()
timer_3_click()
timer_4_click()
timer_5_click()
timer_6_click()

;Init the inventory search color
$Color[1] = IniRead("power trainer.ini", "inventory", "color", 4006425)

;set the fail point where we deliberatly hit examine ore
fail_at_changed()

;----------------------------------------------------------------------------------
;                               Main program
;----------------------------------------------------------------------------------

While 1
    $Info1 = GUIGetCursorInfo($form1)
;If $Info1[2] And $Info1[4] = $button0 Then
;   While _IsPressed("01")
;       Sleep(1)
;   WEnd
;   _GetColor(0)
    If $Info1[2] And $Info1[4] = $button1 Then
        While _IsPressed("01")
            Sleep(1)
        WEnd
        _GetColor(1)
    EndIf
    While $start
        GUICtrlSetData ( $status_label, "Searching inventory slot " & $drop_from_slot & " for color match" )
        $Cords = PixelSearch($slot[$drop_from_slot][0], $slot[$drop_from_slot][2], $slot[$drop_from_slot][1], $slot[$drop_from_slot][3], $Color[1], 8)
        If Not @error Then
            
   ;When done we return mouse back to aproximate where we took it from
            $pos = MouseGetPos()
            $pos[0] = Random($pos[0]-20, $pos[0]+20,1)
            $pos[1] = Random($pos[1]-20, $pos[1]+20,1)
        
   ;we are full start dropping
            For $i = 1 To $drop_from_slot
                GUICtrlSetData ( $status_label, "Dropping from inventory slot " & $i )
                If $start = 0 Then ExitLoop
       ;get the random drop position
                $Cords[0] = Random($slot[$i][0], $slot[$i][1])
                $Cords[1] = Random($slot[$i][2], $slot[$i][3])
            
       ;move mouse to get a text displayed if this is an ore
                MouseMove( $Cords[0], $Cords[1],2)
                Sleep(Random($timer[0],$timer[1],1))
                
       ;-------------------------------------------------------
       ; check if the text in upper left corner matches an ore
       ;-------------------------------------------------------
                
                $dummy = PixelSearch(61, 147, 95, 161, 15106873, 40)
                If Not @error Then
           ;confirmed ore in inventory we need the menu cords
                    $menu_cords[0] = Random($Cords[0]-30, $Cords[0]+30, 1)
                    $fail_counter+=1
                    if $fail_at = $fail_counter Then
                        if $i < 25 Then
                            $menu_cords[1] = Random($Cords[1]+49, $Cords[1]+63, 1)
                        Else
                            $menu_cords[1] = Random(613, 627, 1)
                        EndIf
                        if IsArray ( $failed_slot ) Then
                            ReDim $failed_slot[UBound($failed_slot) + 1]
                            $failed_slot[UBound($failed_slot) - 1] = $i
                        Else
                            Dim $failed_slot[1] = [$i]
                        EndIf   
                        $fail_counter = 0
                        
               ;-----------------------------------------------
               ;         Set a new random failpoint
               ;-----------------------------------------------
                        
                        fail_at_changed()
                        
                    Else    
                        if $i < 25 Then
                            $menu_cords[1] = Random($Cords[1]+34, $Cords[1]+48, 1)
                        Else
                            $menu_cords[1] = Random(598, 612, 1)
                        EndIf
                    EndIf   
                    MouseClick("Right")
                    Sleep(Random($timer[2],$timer[3],1))
                    MouseMove($menu_cords[0],$menu_cords[1],2)
                    MouseClick("Left")
                    Sleep(Random($timer[4],$timer[5],1))
                    $dropped+=1
                    if $dropped = $get_tired Then
                        $sleeptime = Random(7000,20000,1)
                        GUICtrlSetData ( $status_label, "Pausing script for " & Round($sleeptime/1000, 1) & " seconds." )
                        $get_tired = Random(50, 100, 1)
                        $dropped = 0
                        Sleep($sleeptime)
                    EndIf
                Else
           ;We might just have been taken by a random event, or something is deffently wrong - so we stop
                    Dim $failed_slot = ""
                    _StopBot()
                    GUICtrlSetData ( $status_label, "Stopped as i could not confirm ore in inventory" )
                    ExitLoop
                EndIf   
                Sleep(1)
            Next
            
   ;--------------------------------------------------------------------------------------------------------------
   ;                     if we deliberatly missed to drop something we will clean it up here
   ;--------------------------------------------------------------------------------------------------------------
            
            if IsArray ( $failed_slot ) Then
                For $i = UBound($failed_slot)-1 to 0 Step -1
                    GUICtrlSetData ( $status_label, "Dropping from inventory slot " & $failed_slot[$i] )
                    If $start = 0 Then ExitLoop
           ;get the random drop position
                    $Cords[0] = Random($slot[$failed_slot[$i]][0], $slot[$failed_slot[$i]][1])
                    $Cords[1] = Random($slot[$failed_slot[$i]][2], $slot[$failed_slot[$i]][3])
            
           ;move mouse to get a text displayed if this is an ore
                    MouseMove( $Cords[0], $Cords[1],2)
                    Sleep(Random($timer[0],$timer[1],1))
                
           ;-------------------------------------------------------
           ; check if the text in upper left corner matches an ore
           ;-------------------------------------------------------
                
                    $dummy = PixelSearch(61, 147, 95, 161, 15106873, 40)
                    If Not @error Then
               ;confirmed ore in inventory we need the menu cords
                        $menu_cords[0] = Random($Cords[0]-30, $Cords[0]+30, 1)
                        if $failed_slot[$i] < 25 Then
                            $menu_cords[1] = Random($Cords[1]+34, $Cords[1]+48, 1)
                        Else
                            $menu_cords[1] = Random(598, 612, 1)
                        EndIf
                        MouseClick("Right")
                        Sleep(Random($timer[2],$timer[3],1))
                        MouseMove($menu_cords[0],$menu_cords[1],2)
                        MouseClick("Left")
                        Sleep(Random($timer[4],$timer[5],1))
                        $dropped+=1
                        if $dropped = $get_tired Then
                            $sleeptime = Random(7000,20000,1)
                            GUICtrlSetData ( $status_label, "Pausing script for " & Round($sleeptime/1000, 1) & " seconds." )
                            $get_tired = Random(50, 100, 1)
                            $dropped = 0
                            Sleep($sleeptime)
                        EndIf
                    Else
               ;We might just have been taken by a random event, or something is deffently wrong - so we stop
                        Dim $failed_slot = ""
                        _StopBot()
                        GUICtrlSetData ( $status_label, "Stopped as i could not confirm ore in inventory" )
                        ExitLoop
                    EndIf   
                    Sleep(1)
                Next
                Dim $failed_slot = ""
            EndIf
   ;return mouse to about where it came from
            MouseMove($pos[0],$pos[1],2)
        EndIf
        Sleep(1000) 
    WEnd
    Sleep(1)
WEnd
#endregion Main GUI
Func _HyperLink($label)
    GUICtrlSetColor($label, 0x1B2392)
    GUICtrlSetFont($label, 8.5, 400, 4, "Arial")
    GUICtrlSetCursor($label, 0)
EndFunc;==>_HyperLink
Func _CheckJava()
    $regread = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Web Start", "CurrentVersion")
    $version = String($regread)
    If Not @error Then
        Return $version And 1
    Else
        Return 0
    EndIf
EndFunc;==>_CheckJava
Func _GetJava()
    _IECreate("www.java.com/getjava/", 0, 1, 0, 0)
EndFunc;==>_GetJava
Func _Exit()
    IniWrite("power trainer.ini", "inventory", "color", $Color[1])
    IniWrite("power trainer.ini", "inventory", "drop_slot", GUICtrlRead ($drop_spot))
    IniWrite("power trainer.ini", "timers", "timer_1", GUICtrlRead ($timer_1))
    IniWrite("power trainer.ini", "timers", "timer_2", GUICtrlRead ($timer_2))
    IniWrite("power trainer.ini", "timers", "timer_3", GUICtrlRead ($timer_3))
    IniWrite("power trainer.ini", "timers", "timer_4", GUICtrlRead ($timer_4))
    IniWrite("power trainer.ini", "timers", "timer_5", GUICtrlRead ($timer_5))
    IniWrite("power trainer.ini", "timers", "timer_6", GUICtrlRead ($timer_6))
    IniWrite("power trainer.ini", "inventory", "fail_at_1", GUICtrlRead ($fail_at_1))
    IniWrite("power trainer.ini", "inventory", "fail_at_2", GUICtrlRead ($fail_at_2))
    Exit
EndFunc;==>_Exit

;timer functions
Func timer_1_click()
    $timer[0] = GUICtrlRead ($timer_1) * 100
EndFunc   ;==>_timer_1_click
Func timer_2_click()
    $timer[1] = GUICtrlRead ($timer_2) * 100
EndFunc   ;==>_timer_2_click
Func timer_3_click()
    $timer[2] = GUICtrlRead ($timer_3) * 100
EndFunc   ;==>_timer_3_click
Func timer_4_click()
    $timer[3] = GUICtrlRead ($timer_4) * 100
EndFunc   ;==>_timer_4_click
Func timer_5_click()
    $timer[4] = GUICtrlRead ($timer_5) * 100
EndFunc   ;==>_timer_5_click
Func timer_6_click()
    $timer[5] = GUICtrlRead ($timer_6) * 100
EndFunc   ;==>_timer_6_click
Func fail_at_changed()
    $fail_at = Random(GUICtrlRead ($fail_at_1), GUICtrlRead ($fail_at_2), 1)
EndFunc
;color function
Func _GetColor($number)
    Local $Colordata
    $Colordata = PixelGetColor(MouseGetPos(0), MouseGetPos(1))
    $Color[$number] = $Colordata
    if $number = 1 Then
        GUICtrlSetBkColor ( $label_11, $Colordata )
    EndIf   
EndFunc;==>_GetColor

;start function
Func _Start()
;GUICtrlSetState($button0, $GUI_DISABLE)
    GUICtrlSetState($button1, $GUI_DISABLE)
    GUICtrlSetState($button2, $GUI_DISABLE)
    $start = 1
EndFunc;==>_Start

;stop function
Func _StopBot()
    If $start Then
        $start = 0
;GUICtrlSetState($button0, $GUI_ENABLE)
        GUICtrlSetState($button1, $GUI_ENABLE)
        GUICtrlSetState($button2, $GUI_ENABLE)
        GUICtrlSetData ( $status_label, "Stopped" )
    EndIf
EndFunc;==>_StopBot

;Get a new drop spot set
Func drop_spot_selector_changed()
    $drop_from_slot = GUICtrlRead ($drop_spot)
EndFunc;==>_drop:spot_selector_changed
Link to comment
Share on other sites

This code was not made correctly, it is not a matter of being old...

this works...

#include <StaticConstants.au3>
#include <ProgressConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
;Build on Generator's bot in AutoIt Forums @ http://www.autoitscript.com/forum/index.php?showtopic=70399&st=0&gopid=601549&#entry601549
;UDF by Developers of AutoIt
;heavily modifyed by Sprille
#NoTrayIcon
#include<GUIConstants.au3>
#include <WindowsConstants.au3>
#include<IE.au3>
#include<Misc.au3>

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC", 0)
AutoItSetOption("MouseCoordMode", 2); sets mouse to use client cordinates
AutoItSetOption("PixelCoordMode", 2); set pixel functions to use client cordinates

;----------------------------------------------------------------------------------------
;                          Declare some variables
;----------------------------------------------------------------------------------------

;Standard detail free world 1 column = 30 px spacing = 12
Dim $drop_x_min[4] = [586, 628, 670, 712]
Dim $drop_x_max[4] = [616, 658, 700, 742]

;standard detail free world - 7 rows - 1 row = 30px spacing = 6
Dim $drop_y_min[7] = [355, 391, 427, 463, 499, 535, 571]
Dim $drop_y_max[7] = [385, 421, 457, 493, 529, 565, 601]

Dim $mode = 0, $version = "", $start = 0
Dim $Color[2], $timer[6], $Cords[2] = [0, 0], $pos[2] = [0, 0]
Dim $menu_cords[2] = [0, 0], $dropped
Dim $get_tired = Random(50, 100, 1), $sleeptime
Dim $drop_from_slot

Dim $fail_at, $fail_counter = 0, $failed_slot = ""


;-----------------------------------------------------------------------------------------
;                         Setup all inventory slots
;-----------------------------------------------------------------------------------------

Dim $slot[29][4]
Dim $i
Dim $row = 0
Dim $column = 0

For $i = 1 To 28
    $slot[$i][0] = $drop_x_min[$column]
    $slot[$i][1] = $drop_x_max[$column]
    $slot[$i][2] = $drop_y_min[$row]
    $slot[$i][3] = $drop_y_max[$row]
    $column += 1
    If $column > 3 Then
        $column = 0
        $row += 1
    EndIf
Next

HotKeySet("{ESC}", "_StopBot")

_Singleton("Power Training")
_IEErrorHandlerRegister()
#Region Welcome GUI
$form0 = GUICreate("Power Training", 400, 70, -1, -1, $WS_CAPTION, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
$label0 = GUICtrlCreateLabel("Welcome to Power Training...Please wait for vertification....", 10, 5, 390, 20, -1)
$progress0 = GUICtrlCreateProgress(10, 25, 240, 20, $PBS_SMOOTH)
$label1 = GUICtrlCreateLabel("Looking for Java plug-in....", 10, 50, 240, 20, -1)
GUISetState(@SW_SHOW, $form0)
For $i = 1 To 100
    GUICtrlSetData($progress0, $i)
    Sleep(5)
Next
If Not _CheckJava() Then
    $label3 = GUICtrlCreateLabel("Get the latest Java", 260, 25, 140, 20, -1)
    GUICtrlSetData($label1, "Please install Java before continuing...")
    _HyperLink($label3)
Else
    GUICtrlCreateLabel("Version: " & $version, 260, 25, 140, 20, -1)
    $label4 = GUICtrlCreateLabel("Start", 370, 50, 30, 20, -1)
    _HyperLink($label4)
EndIf

While Not $mode
    $Info0 = GUIGetCursorInfo($form0)
    If $version == "" Then
        If $Info0[2] And $Info0[4] = $label3 Then
            While _IsPressed("01")
                Sleep(1)
            WEnd
            _GetJava()
            Exit
        EndIf
    ElseIf $Info0[2] And $Info0[4] = $label4 Then
        While _IsPressed("01")
            Sleep(1)
        WEnd
        $mode = 1
        GUIDelete($form0)
    EndIf
    Sleep(1)
WEnd
#EndRegion Welcome GUI
#Region Main GUI

;----------------------------------------------------------------------------------
;                            Setup the GUI
;----------------------------------------------------------------------------------

$form1 = GUICreate("RSClient", 810, 700, -1, -1, -1)

;Create tab page
$tab = GUICtrlCreateTab(20, 10, 770, 125)
GUICtrlSetFont($tab, 9, 400, 0, "Tahoma")

;Create first tab
$tab0 = GUICtrlCreateTabItem("Main")
$button2 = GUICtrlCreateButton("Start Training", 600, 48, 170, 65, -1)
GUICtrlSetFont(-1, 16, 400, 0, "Century Gothic")

$status_label = GUICtrlCreateLabel("", 35, 70, 530, 20, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, "Century Gothic")

;Create thierd tab
$tab3 = GUICtrlCreateTabItem("Inventory")
;Create the label for the scan slots / drop spot
$scan_slots_label = GUICtrlCreateLabel("Start dropping at slot :", 35, 45, 125, 20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$drop_spot = GUICtrlCreateInput(IniRead("power trainer.ini", "inventory", "drop_slot", 2), 165, 43, 40, 20, $ES_READONLY)
$updown_1 = GUICtrlCreateUpdown($drop_spot)
GUICtrlSetLimit($updown_1, 28, 1)

;Timers for before right click
$label_12 = GUICtrlCreateLabel("Time before right click between:", 255, 45, 190, 20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_1 = GUICtrlCreateInput(IniRead("power trainer.ini", "timers", "timer_1", 2), 460, 43, 40, 20, $ES_READONLY)
$updown_2 = GUICtrlCreateUpdown($timer_1)
GUICtrlSetLimit($updown_2, 50, 1)
$label_13 = GUICtrlCreateLabel("and", 510, 45, 30, 20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_2 = GUICtrlCreateInput(IniRead("power trainer.ini", "timers", "timer_2", 5), 540, 43, 40, 20, $ES_READONLY)
$updown_3 = GUICtrlCreateUpdown($timer_2)
GUICtrlSetLimit($updown_3, 50, 1)

;Timers for before mouse move
$label_13 = GUICtrlCreateLabel("Time before mouse move between:", 255, 75, 210, 20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_3 = GUICtrlCreateInput(IniRead("power trainer.ini", "timers", "timer_3", 5), 460, 73, 40, 20, $ES_READONLY)
$updown_4 = GUICtrlCreateUpdown($timer_3)
GUICtrlSetLimit($updown_4, 50, 1)
$label_14 = GUICtrlCreateLabel("and", 510, 75, 30, 20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_4 = GUICtrlCreateInput(IniRead("power trainer.ini", "timers", "timer_4", 10), 540, 73, 40, 20, $ES_READONLY)
$updown_5 = GUICtrlCreateUpdown($timer_4)
GUICtrlSetLimit($updown_5, 50, 1)

;Timers for before menu click
$label_15 = GUICtrlCreateLabel("Time before menu click between:", 255, 105, 210, 20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_5 = GUICtrlCreateInput(IniRead("power trainer.ini", "timers", "timer_5", 2), 460, 103, 40, 20, $ES_READONLY)
$updown_6 = GUICtrlCreateUpdown($timer_5)
GUICtrlSetLimit($updown_5, 50, 1)
$label_16 = GUICtrlCreateLabel("and", 510, 105, 30, 20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$timer_6 = GUICtrlCreateInput(IniRead("power trainer.ini", "timers", "timer_6", 6), 540, 103, 40, 20, $ES_READONLY)
$updown_7 = GUICtrlCreateUpdown($timer_6)
GUICtrlSetLimit($updown_6, 50, 1)

;create the button for color picking
$label_10 = GUICtrlCreateLabel("When finding this color :", 35, 70, 140, 20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")

;this is label for the color display of the picked color
$label_11 = GUICtrlCreateLabel("", 35, 85, 130, 35)
GUICtrlSetBkColor($label_11, IniRead("power trainer.ini", "inventory", "color", 4006425))
;Colorpicker button
$button1 = GUICtrlCreateButton("+", 650, 70, 100, 40, -1)
GUICtrlSetCursor(-1, 3)
GUICtrlSetFont(-1, 30, 400)
;create label for colorpicker
$label8 = GUICtrlCreateLabel("Log/Ore Color", 650, 45, 100, 20, $SS_CENTER)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")

;Create fourth tab
$tab4 = GUICtrlCreateTabItem("Fail-Drop")
;Create the label for the drop
$fail_drop_label = GUICtrlCreateLabel("Hit examine ore random between :", 35, 45, 195, 20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$fail_at_1 = GUICtrlCreateInput(IniRead("power trainer.ini", "inventory", "fail_at_1", 6), 235, 43, 40, 20, $ES_READONLY)
$updown_8 = GUICtrlCreateUpdown($fail_at_1)
GUICtrlSetLimit($updown_1, 99, 1)
$label_17 = GUICtrlCreateLabel("and", 285, 45, 30, 20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
$fail_at_2 = GUICtrlCreateInput(IniRead("power trainer.ini", "inventory", "fail_at_2", 28), 315, 43, 40, 20, $ES_READONLY)
$updown_9 = GUICtrlCreateUpdown($fail_at_2)
GUICtrlSetLimit($updown_1, 99, 1)
$label_18 = GUICtrlCreateLabel("drops", 365, 45, 30, 20)
GUICtrlSetFont(-1, 9.5, 400, 0, "Tahoma")
;end tab definition
GUICtrlCreateTabItem("")

;----------------------------------------------------------------------------------
;               Create the explorer object and navigate to free world
;----------------------------------------------------------------------------------

$oIE = _IECreateEmbedded()
$guiactivex = GUICtrlCreateObj($oIE, 20, 150, 770, 680);, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))

;_IENavigate($oIE, "http://www.autoit3.com", 0)
_IENavigate($oIE, "http://www.runescape.com/game.ws?m=0&j=1", 0)

;----------------------------------------------------------------------------------
;                             set the events for GUI
;----------------------------------------------------------------------------------
;

GUICtrlSetOnEvent($updown_1, "drop_spot_selector_changed")
GUICtrlSetOnEvent($updown_2, "timer_1_click")
GUICtrlSetOnEvent($updown_3, "timer_2_click")
GUICtrlSetOnEvent($updown_4, "timer_3_click")
GUICtrlSetOnEvent($updown_5, "timer_4_click")
GUICtrlSetOnEvent($updown_6, "timer_5_click")
GUICtrlSetOnEvent($updown_7, "timer_6_click")
GUICtrlSetOnEvent($updown_8, "fail_at_changed")
GUICtrlSetOnEvent($updown_9, "fail_at_changed")
GUICtrlSetOnEvent($button2, "_Start")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "_StopBot")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

;----------------------------------------------------------------------------------
;                             Show the GUI
;----------------------------------------------------------------------------------

GUISetState(@SW_SHOW, $form1)

;----------------------------------------------------------------------------------
;                             Init start values
;----------------------------------------------------------------------------------

;init the dropspot in inventory to get cordinates to scan
drop_spot_selector_changed()

;init timer values. All times in GUI are stated in 1/100 of a second
timer_1_click()
timer_2_click()
timer_3_click()
timer_4_click()
timer_5_click()
timer_6_click()

;Init the inventory search color
$Color[1] = IniRead("power trainer.ini", "inventory", "color", 4006425)

;set the fail point where we deliberatly hit examine ore
fail_at_changed()

;----------------------------------------------------------------------------------
;                                Main program
;----------------------------------------------------------------------------------

While 1
    $Info1 = GUIGetCursorInfo($form1)
    ;If $Info1[2] And $Info1[4] = $button0 Then
    ;    While _IsPressed("01")
    ;        Sleep(1)
    ;    WEnd
    ;    _GetColor(0)
    If $Info1[2] And $Info1[4] = $button1 Then
        While _IsPressed("01")
            Sleep(1)
        WEnd
        _GetColor(1)
    EndIf
    While $start
        GUICtrlSetData($status_label, "Searching inventory slot " & $drop_from_slot & " for color match")
        $Cords = PixelSearch($slot[$drop_from_slot][0], $slot[$drop_from_slot][2], $slot[$drop_from_slot][1], $slot[$drop_from_slot][3], $Color[1], 8)
        If Not @error Then

            ;When done we return mouse back to aproximate where we took it from
            $pos = MouseGetPos()
            $pos[0] = Random($pos[0] - 20, $pos[0] + 20, 1)
            $pos[1] = Random($pos[1] - 20, $pos[1] + 20, 1)

            ;we are full start dropping
            For $i = 1 To $drop_from_slot
                GUICtrlSetData($status_label, "Dropping from inventory slot " & $i)
                If $start = 0 Then ExitLoop
                ;get the random drop position
                $Cords[0] = Random($slot[$i][0], $slot[$i][1])
                $Cords[1] = Random($slot[$i][2], $slot[$i][3])

                ;move mouse to get a text displayed if this is an ore
                MouseMove($Cords[0], $Cords[1], 2)
                Sleep(Random($timer[0], $timer[1], 1))

                ;-------------------------------------------------------
                ; check if the text in upper left corner matches an ore
                ;-------------------------------------------------------

                $dummy = PixelSearch(61, 147, 95, 161, 15106873, 40)
                If Not @error Then
                    ;confirmed ore in inventory we need the menu cords
                    $menu_cords[0] = Random($Cords[0] - 30, $Cords[0] + 30, 1)
                    $fail_counter += 1
                    If $fail_at = $fail_counter Then
                        If $i < 25 Then
                            $menu_cords[1] = Random($Cords[1] + 49, $Cords[1] + 63, 1)
                        Else
                            $menu_cords[1] = Random(613, 627, 1)
                        EndIf
                        If IsArray($failed_slot) Then
                            ReDim $failed_slot[UBound($failed_slot) + 1]
                            $failed_slot[UBound($failed_slot) - 1] = $i
                        Else
                            Dim $failed_slot[1] = [$i]
                        EndIf
                        $fail_counter = 0

                        ;-----------------------------------------------
                        ;         Set a new random failpoint
                        ;-----------------------------------------------

                        fail_at_changed()

                    Else
                        If $i < 25 Then
                            $menu_cords[1] = Random($Cords[1] + 34, $Cords[1] + 48, 1)
                        Else
                            $menu_cords[1] = Random(598, 612, 1)
                        EndIf
                    EndIf
                    MouseClick("Right")
                    Sleep(Random($timer[2], $timer[3], 1))
                    MouseMove($menu_cords[0], $menu_cords[1], 2)
                    MouseClick("Left")
                    Sleep(Random($timer[4], $timer[5], 1))
                    $dropped += 1
                    If $dropped = $get_tired Then
                        $sleeptime = Random(7000, 20000, 1)
                        GUICtrlSetData($status_label, "Pausing script for " & Round($sleeptime / 1000, 1) & " seconds.")
                        $get_tired = Random(50, 100, 1)
                        $dropped = 0
                        Sleep($sleeptime)
                    EndIf
                Else
                    ;We might just have been taken by a random event, or something is deffently wrong - so we stop
                    Dim $failed_slot = ""
                    _StopBot()
                    GUICtrlSetData($status_label, "Stopped as i could not confirm ore in inventory")
                    ExitLoop
                EndIf
                Sleep(1)
            Next

            ;--------------------------------------------------------------------------------------------------------------
            ;                     if we deliberatly missed to drop something we will clean it up here
            ;--------------------------------------------------------------------------------------------------------------

            If IsArray($failed_slot) Then
                For $i = UBound($failed_slot) - 1 To 0 Step -1
                    GUICtrlSetData($status_label, "Dropping from inventory slot " & $failed_slot[$i])
                    If $start = 0 Then ExitLoop
                    ;get the random drop position
                    $Cords[0] = Random($slot[$failed_slot[$i]][0], $slot[$failed_slot[$i]][1])
                    $Cords[1] = Random($slot[$failed_slot[$i]][2], $slot[$failed_slot[$i]][3])

                    ;move mouse to get a text displayed if this is an ore
                    MouseMove($Cords[0], $Cords[1], 2)
                    Sleep(Random($timer[0], $timer[1], 1))

                    ;-------------------------------------------------------
                    ; check if the text in upper left corner matches an ore
                    ;-------------------------------------------------------

                    $dummy = PixelSearch(61, 147, 95, 161, 15106873, 40)
                    If Not @error Then
                        ;confirmed ore in inventory we need the menu cords
                        $menu_cords[0] = Random($Cords[0] - 30, $Cords[0] + 30, 1)
                        If $failed_slot[$i] < 25 Then
                            $menu_cords[1] = Random($Cords[1] + 34, $Cords[1] + 48, 1)
                        Else
                            $menu_cords[1] = Random(598, 612, 1)
                        EndIf
                        MouseClick("Right")
                        Sleep(Random($timer[2], $timer[3], 1))
                        MouseMove($menu_cords[0], $menu_cords[1], 2)
                        MouseClick("Left")
                        Sleep(Random($timer[4], $timer[5], 1))
                        $dropped += 1
                        If $dropped = $get_tired Then
                            $sleeptime = Random(7000, 20000, 1)
                            GUICtrlSetData($status_label, "Pausing script for " & Round($sleeptime / 1000, 1) & " seconds.")
                            $get_tired = Random(50, 100, 1)
                            $dropped = 0
                            Sleep($sleeptime)
                        EndIf
                    Else
                        ;We might just have been taken by a random event, or something is deffently wrong - so we stop
                        Dim $failed_slot = ""
                        _StopBot()
                        GUICtrlSetData($status_label, "Stopped as i could not confirm ore in inventory")
                        ExitLoop
                    EndIf
                    Sleep(1)
                Next
                Dim $failed_slot = ""
            EndIf
            ;return mouse to about where it came from
            MouseMove($pos[0], $pos[1], 2)
        EndIf
        Sleep(1000)
    WEnd
    Sleep(1)
WEnd
#EndRegion Main GUI
Func _HyperLink($label)
    GUICtrlSetColor($label, 0x1B2392)
    GUICtrlSetFont($label, 8.5, 400, 4, "Arial")
    GUICtrlSetCursor($label, 0)
EndFunc   ;==>_HyperLink
Func _CheckJava()
    $regread = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Web Start", "CurrentVersion")
    $version = String($regread)
    If Not @error Then
        Return $version And 1
    Else
        Return 0
    EndIf
EndFunc   ;==>_CheckJava
Func _GetJava()
    _IECreate("www.java.com/getjava/", 0, 1, 0, 0)
EndFunc   ;==>_GetJava
Func _Exit()
    IniWrite("power trainer.ini", "inventory", "color", $Color[1])
    IniWrite("power trainer.ini", "inventory", "drop_slot", GUICtrlRead($drop_spot))
    IniWrite("power trainer.ini", "timers", "timer_1", GUICtrlRead($timer_1))
    IniWrite("power trainer.ini", "timers", "timer_2", GUICtrlRead($timer_2))
    IniWrite("power trainer.ini", "timers", "timer_3", GUICtrlRead($timer_3))
    IniWrite("power trainer.ini", "timers", "timer_4", GUICtrlRead($timer_4))
    IniWrite("power trainer.ini", "timers", "timer_5", GUICtrlRead($timer_5))
    IniWrite("power trainer.ini", "timers", "timer_6", GUICtrlRead($timer_6))
    IniWrite("power trainer.ini", "inventory", "fail_at_1", GUICtrlRead($fail_at_1))
    IniWrite("power trainer.ini", "inventory", "fail_at_2", GUICtrlRead($fail_at_2))
    Exit
EndFunc   ;==>_Exit

;timer functions
Func timer_1_click()
    $timer[0] = GUICtrlRead($timer_1) * 100
EndFunc   ;==>timer_1_click
Func timer_2_click()
    $timer[1] = GUICtrlRead($timer_2) * 100
EndFunc   ;==>timer_2_click
Func timer_3_click()
    $timer[2] = GUICtrlRead($timer_3) * 100
EndFunc   ;==>timer_3_click
Func timer_4_click()
    $timer[3] = GUICtrlRead($timer_4) * 100
EndFunc   ;==>timer_4_click
Func timer_5_click()
    $timer[4] = GUICtrlRead($timer_5) * 100
EndFunc   ;==>timer_5_click
Func timer_6_click()
    $timer[5] = GUICtrlRead($timer_6) * 100
EndFunc   ;==>timer_6_click
Func fail_at_changed()
    $fail_at = Random(GUICtrlRead($fail_at_1), GUICtrlRead($fail_at_2), 1)
EndFunc   ;==>fail_at_changed
;color function
Func _GetColor($number)
    Local $Colordata
    $Colordata = PixelGetColor(MouseGetPos(0), MouseGetPos(1))
    $Color[$number] = $Colordata
    If $number = 1 Then
        GUICtrlSetBkColor($label_11, $Colordata)
    EndIf
EndFunc   ;==>_GetColor

;start function
Func _Start()
    ;GUICtrlSetState($button0, $GUI_DISABLE)
    GUICtrlSetState($button1, $GUI_DISABLE)
    GUICtrlSetState($button2, $GUI_DISABLE)
    $start = 1
EndFunc   ;==>_Start

;stop function
Func _StopBot()
    If $start Then
        $start = 0
        ;GUICtrlSetState($button0, $GUI_ENABLE)
        GUICtrlSetState($button1, $GUI_ENABLE)
        GUICtrlSetState($button2, $GUI_ENABLE)
        GUICtrlSetData($status_label, "Stopped")
    EndIf
EndFunc   ;==>_StopBot

;Get a new drop spot set
Func drop_spot_selector_changed()
    $drop_from_slot = GUICtrlRead($drop_spot)
EndFunc   ;==>drop_spot_selector_changed

8)

NEWHeader1.png

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...