Jump to content

Detect change of pixels


Recommended Posts

I am making a bot for runescape and need help in detecting when the inventory is full. I have used PixelChecksum but this fails to detect it. Could you help me out thanks!

This is the image...

post-34577-12489867324584_thumb.gif

The code (please don't steal this code, thanks)...

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
 #AutoIt3Wrapper_icon=Runescape.ico
 #AutoIt3Wrapper_outfile=RUN3-B0T.exe
 #AutoIt3Wrapper_Compression=4
 #AutoIt3Wrapper_Allow_Decompile=n
 #AutoIt3Wrapper_Res_Comment=Run3 B0T
 #AutoIt3Wrapper_Res_Description=Run3 B0T
 #AutoIt3Wrapper_Res_Fileversion=0.0.0.5
 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
 #AutoIt3Wrapper_Res_Language=1033
 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
 ;#NoTrayIcon
 #include<GUIConstants.au3>
 #include<IE.au3>
 #include<Misc.au3>
 #include<GuiComboBox.au3>
 #Include <Misc.au3>
 $DESK_HIGHT = @DesktopHeight
 $DESK_WIDTH = @DesktopWidth
 $AD_CODE = @CRLF & @CRLF & @CRLF & "--------------------------------------------------" & @CRLF & "http://www.Binary-Dev.x10hosting.com"
 Global $WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $status, $WS_EX_TOPMOST, $BOT_INFO_GUI, $dll, $continue
 HotKeySet("{F9}", "Continue")
 
 ProgressOn("System Checks", "Checking System...", "0 percent")
 Sleep(500)
 
 ; Internet Explorer
 If FileExists("C:\Program Files\Internet Explorer\iexplore.exe") = True Then
     ProgressSet(40, "Internet Explorer Detected")
     Sleep(500)
 Else
     Return_Error(1)
 EndIf
 
 ; Java ™
 If FileExists("C:\Program Files\Java\jre6\bin\java.exe") = True Then
     ProgressSet(70, "Java Detected")
     Sleep(500)
 Else
     Return_Error(1)
 EndIf
 
 ; Finished
 ProgressSet(100, "System check has completed", "Complete")
 Sleep(500)
 ProgressOff()
 
 ;$status = @CRLF & "Bot is starting up..."
 ;ToolTip($status & $AD_CODE, $DESK_WIDTH - 100, $DESK_HIGHT - 30, "Bot Info", 1, 4)
 Open_IE_Window()
 WinMove("http://www.runescape.com/?m=0&j=1 - Runescape Game - ", "", -1, -1, $DESK_WIDTH, $DESK_HIGHT)
 WinSetOnTop("Runescape Game", "", 0)
 
 ToolTip("")
 $status = "Waiting for user login. Press F9 when logged in."
 ToolTip($status & $AD_CODE, $DESK_WIDTH - 100, $DESK_HIGHT - 30, "Bot Info", 1, 4)
 Sleep(3000)
 
 While $continue = False
     Sleep(500)
 WEnd
 
 $continue = False
 
 ToolTip("")
 $status = "Please place cursor over object color to gather from and press F9."
 ToolTip($status & $AD_CODE, $DESK_WIDTH - 100, $DESK_HIGHT - 30, "Bot Info", 1, 4)
 Sleep(3000)
 
 While $continue = False
     Sleep(500)
 WEnd
 $continue = False
 ToolTip("")
 
 $color = PixelGetColor(MouseGetPos(0), MouseGetPos(1))
 $first_time = 1
 While True
     $location = PixelSearch(0, 0, $DESK_WIDTH, $DESK_HIGHT, $color, 3, 3)
     If @error = 1 Then Send("{left}")
     MouseClick("Left", $location[0], $location[1])
     Sleep(20000)
     If $first_time = 1 Then
         $status = "Please place cursor over game space (where you click to move) then press F9. Do the same to the other corner."
         ToolTip($status & $AD_CODE, $DESK_WIDTH - 100, $DESK_HIGHT - 30, "Bot Info", 1, 4)
         While $continue = False
             Sleep(500)
         WEnd
         $continue = False
         $game_x1 = MouseGetPos(0)
         $game_y1 = MouseGetPos(1)
         While $continue = False
             Sleep(500)
         WEnd
         $continue = False
         $game_x2 = MouseGetPos(0)
         $game_y2 = MouseGetPos(1)
         ToolTip("")
         $status = "Please place cursor over object color in your invitory. Please press F9 after."
         ToolTip($status & $AD_CODE, $DESK_WIDTH - 100, $DESK_HIGHT - 30, "Bot Info", 1, 4)
         While $continue = False
             Sleep(500)
         WEnd
         $continue = False
         ToolTip("")
         $invintory_item = PixelGetColor(MouseGetPos(0), MouseGetPos(1))
         $status = "Please place cursor over the center of the last object spot in your invintory then press F9."
         ToolTip($status & $AD_CODE, $DESK_WIDTH - 100, $DESK_HIGHT - 30, "Bot Info", 1, 4)
         While $continue = False
             Sleep(500)
         WEnd
         $continue = False
         ToolTip("")
         $mouse_x = MouseGetPos(0) - 3
         $mouse_y = MouseGetPos(1) - 3
         $last_spot = PixelChecksum($mouse_x, $mouse_y, 10, 10)
     EndIf
     $first_time = 0
     $location = PixelSearch($game_x1, $game_y1, $game_x2, $game_y2, $color, 3, 3)
     If @error = 1 Then Send("{left}")
     MouseClick("Left", $location[0], $location[1])
     Sleep(20000)
     If $last_spot <> PixelChecksum($mouse_x, $mouse_y, 12, 12) Then MsgBox(0, "Run3 B0t", "Invintory is full.")
 WEnd
 
 MsgBox(0, "INF0", "Bot Closed")
 
 
 ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Func Return_Error($error_code)
     MsgBox(0, "Run3-B0T", "The program has encounted error " & $error_code & ", and needs to close. Please check that your computer is running with Java ™.")
     Exit
 EndFunc   ;==>Return_Error
 
 Func Open_IE_Window()
     $oIE1 = _IECreate("http://www.runescape.com/game.ws?m=0&j=1", 0, 1)
     $oIE1.AddressBar = 0
     $oIE1.MenuBar = 0
     $oIE1.StatusBar = 0
     $oIE1.ToolBar = 0
     ;$oIE1.Fullscreen = 1
     $uID1 = Random(1000, 100000000)
     $oIE1.document.Title = "Runescape Game"
     WinWait($uID1, "", 5)
     ;$hoIE1 = WinGetHandle($uID1)
     ;$pid1 = WinGetProcess ($hoIE1)
 EndFunc   ;==>Open_IE_Window
 
 Func Continue ()
     $continue = True
 EndFunc

Thanks for your help!

Link to comment
Share on other sites

You might want to remove your name from that screenshot... >_<

Also if your not moving the browser window or scrolling down then you should have no problems with adding in a PixelGetColor and then comparing that received colour to the normal inventory colour. However, if you are changing from between mem and non mem worlds then that won't work (due to the ad not being there). I'm only a newb when it comes to Autoit and judging by your code you're probably more experienced at this than me.

Hope it helps :(

Edited by Lithium
Link to comment
Share on other sites

Parameters

left left coordinate of rectangle.

top top coordinate of rectangle.

right right coordinate of rectangle.

bottom bottom coordinate of rectangle.

try like this

PixelChecksum($mouse_x, $mouse_y,$mouse_x+10,$mouse_y+10)

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
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...