my findColor method

Discussion in 'Programming General' started by slashshot007, Dec 21, 2007.

Thread Status:
Not open for further replies.
my findColor method
  1. Unread #1 - Dec 21, 2007 at 10:10 PM
  2. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    my findColor method

    basically what the title says.
    Code:
    	Private Function findColor(ByVal Color As Color, ByVal Area As Rectangle) As Point
    		Dim AreaSize As Size = Area.Size
    		Dim TempBitmap As New Bitmap(AreaSize.Width, AreaSize.Height)
    		Graphics.FromImage(TempBitmap).CopyFromScreen(Area.Location, New Point(), AreaSize)
    		For x As Integer = 0 To Area.Height - 1
    			For y As Integer = 0 To Area.Width - 1
    				If TempBitmap.GetPixel(x, y) = Color Then Return New Point(Area.X + x, Area.Y + y)
    			Next
    		Next
    		Return New Point(-1, -1)
    	End Function
    for actually getting the Color to find:
    or using a button where you press down, and release over the selected color, use this as an example
    in this case, a picturebox called PictureBoxColor has its background color changed to the hovered over color.

    Code:
    	Private Sub btnGetColor_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnGetColor.MouseDown
    		tmrGetColor.Start()
    	End Sub
    
    
    	Private Sub tmrGetColor_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrGetColor.Tick
    		Dim TempBitmap As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
    		Graphics.FromImage(TempBitmap).CopyFromScreen(Screen.PrimaryScreen.Bounds.Location, New Point(), Screen.PrimaryScreen.Bounds.Size)
    		PictureBoxColor.BackColor = TempBitmap.GetPixel(System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y)
    	End Sub
    
    	Private Sub btnGetColor_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnGetColor.MouseUp
    		tmrGetColor.Stop()
    	End Sub
     
  3. Unread #2 - Nov 3, 2008 at 3:51 PM
  4. christb123
    Referrals:
    0

    christb123 Guest

    my findColor method

    please help me i want to make a bot which, using colour detection will go to a general store on runescape, buy items (i want water filled vials) then go back and bank. I have tried to do this with a simple autoclicker but it does not work as the shopkeeper moves!
    will your thingy above help me? if so wat on earth do i do with it? where do i paste it etc... thanks
     
  5. Unread #3 - Nov 3, 2008 at 8:22 PM
  6. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    my findColor method

    Please don't revive a thread; make your own if you feel necessary.
     
< Trackbar control to change richtextbox font size? | Loading The Runescape Client. >

Users viewing this thread
1 guest
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site