Jump to content

Pixelsearch restriction


 Share

Recommended Posts

Hi,

I made a script that find a color and click on it. I want to add a restriction to my code so that it cannot reclick the last coordinate after a certain amount of time it have clicked the color.

While 1

        $coord = PixelSearch(362,220,912,517, 9192969)
        If Not @error Then
            MouseClick ( "left" , $coord[0], $coord[1], 1 , 1  )
        Endif

    Wend

How can I set it so it wont click those coordinates?

The last coordinate it found with those specifications:

x: +- 52

y: +-38

*That mean it cannot reclick immediatly in a certain region.

Edited by J0ker
Link to comment
Share on other sites

I need help :whistle:

There could be another way to do it. Set it so during the next search it wont search on the region it clicked before . That way It wont click this region for sure. Can I use a Pixelsearch but use it as a DONT Pixelsearch

Link to comment
Share on other sites

Up !!! Please I need help :whistle:

I tried alot of things but nothing is working.

Uhm, I don't know of a way to use restriction in PixelSearch, but what comes to mind is keeping an array of recently clicked coördinates and timestamps (created by TimerInit), and then whenever you are trying to click something, first get the appropriate timestamp and run a TimerDiff to see if your certain amount of time has passed, if not don't let it click. If you don't click very very often so there is not a very big array to use, it is probably worth the trouble of periodically (after each click?) sort the list so you can BinarySearch through it, which makes your searching very much faster (but sorting takes some time though).

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Yes I tried exactly what you said but the problem is that it click very very fast, there's almost no delay between the clicks so there must be no to time to sort.

and also, If I start a check with BinarySearch after each PixelSearch, it wont work because nothing will happen.

1. PixelSearch will find a pixel

2. The array will prevent the mouse from clicking

3. Loop restart, it will find the same pixel

4. The array will prevent the mouse from clicking

It's why I must have something during my pixelseatch to prevent the script from searching in this region.

Edited by J0ker
Link to comment
Share on other sites

I have the same problem with my bot, here is what I thought about doing(only theoretical because I have not bothered programming it yet due to severe slackage). Well consider the geometery of your pixel search, you want to search an area that is a rectangle. after the first pixelsearch is done then how about you cut out that area which you just have search by means of pixelsearching 4 rectangles around the previously searched area (with a little extra space in the middle). then you could create an array, or four variables (top, left, bottom, right) of the area which you don't want to have searched. You should also probably include the additional space so the search does not come up with the same as the previous result. I will demonstrate what I'm talking about because I probably didn't explain very well :whistle:

Global $top  ; these are for you to declare
Global $left
Global $bottom
Global $right
Global $coord
Global $colour ; = 0x "colour here" also note that I am canadian so colour is spelt colour not color - incase you think I'm a bad speller :P
Global $extraspace ;this is a precautionary measure
$coord=pixelsearch($top,$left,$bottom,$right,$colour)   ; please note that this script is simple for understanding, I am not putting that much work into it, to make it work much better you should make a function to break each pixelsearch area down and store new x and y values in an array. the info that the function would have to have would be first the number of pixelsearches to perform intotal and the top left bottom right values of each pixel search.
if not @error then
mouseclick( "left" , $coord[0], $coord[1], 1 , 1  )
endif
;note the use of + $extraspace and - $extraspace depends on which of the constant variables ($top, $left, $bottom, $right) are being used because the idea is to leave some room in the middle incase there are other pixels around the colour you're looking for that will trigger the pixelsearch but you don't want it to. ex. you search for the colour of a sword and that colour in the sword occurs in that area a few times directly left and right of the coords found in the pixel search.

$coord1=pixelsearch($top, $left,$coord[1]-$extraspace,$coord[0]-$extraspace,$colour) 
if not @error then
mouseclick( "left" , $coord1[0], $coord1[1], 1 , 1  )
endif
$coord2=pixelsearch($coord[1]+$extraspace, $left, $bottom, $coord[0]-$extraspace,$colour)
if not @error then
mouseclick( "left" , $coord2[0], $coord2[1], 1 , 1  )
endif
$coord3=pixelsearch($coord[1]+$extraspace, $coord[0]+$extraspace,$bottom,$right,$colour)
if not @error then
mouseclick( "left" , $coord3[0], $coord4[1], 1 , 1  )
endif
$coord4=pixelsearch($top, $coord[0]+$extraspace, $coord[1]-$extraspace, $right,$colour)
if not @error then
mouseclick( "left" , $coord4[0], $coord4[1], 1 , 1  )
endif
;also note that the coords returned from pixelsearch may be better off in an array so you have to write less script to use and work with the variables
;** remember this is theoretical so far but I think this solves you're problem, you just have to do the mental work to program it. let me know if you do make it and it works or if it works well. the only down side I can see is that it might take a bit to find the colour.
Edited by crislivinitup
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...