Jump to content

I need some help


Shakala
 Share

Recommended Posts

Hello. First, i will begin with what i would like accomplished. I want Autoit to search a area within a predetermined box. Then, i want it to search for a pixle that is not white but randomly changes colors. It can be any color within the box, as long as if it is not white, and then, begin a set of actions after that. For example, i want it so it finds a single (non white) pixle, holds down the down arrow key, then, left clicks one time on the selected pixle while still holding the Right arrow key down. I am not sure how to begin with this, but ill start by giving the locations of the box it needs to search.

EDIT: Would help if you would know what is happening... There is a picture being displayed within that box, and you have to click it for the next event to happen. You MUST click a part of the picture that is not white b/c it only reads if you click a colored pixel. The picture is a random set of about 100 different pictures. I COULD find a color from each picture and have it search through each of them every time, but making that code would be very time consuming and really not what im looking to do. I am sure there is a easier way to do it.

'(566, 425)__________'(680, 425)

'left, top, right, bottom

'566, 425, 680, 512

'(566, 512)__________'(680, 512)

I would like it to search for any color that shows up in that area that is not white

I was thinking about having it set up something like this... Not even sure if it would work setting it up like this...

Func Search()
    $c_Color = PixelSearch(566, 425, 680, 512, 0x??????) ;Search for the pixle
    If Not @error And IsArray($c_Color) Then ;if there is no error and the colored pixle is visible, click the pixle
        MouseClick("left", ?, ?, 1, $MouseSpeed) ;left clicks *where it would click is where the previously found color was.
    EndIf
EndFunc

If you have any ideas or any direction to point me in, it will be very helpful. I am still kinda new to coding in autoit, but i am able to get around with what i know. this is just a spot that stumped me. Also, if there is any more information that you require to solve this or if you are unclear about any aspect of it, let me know.

~Sorry for this lengthy post, i just thought i would try to add as much information as possible for ease of answering.

Thanks

~Shakala

Edited by Shakala
Link to comment
Share on other sites

No responses yet... if anything needs more clarifying, let me know.

Also, if this is to complicated of a task, speak up also lol.

I don't suppose this would be related to Ladder Slasher?

If this is a game then there are probably more effective ways of approaching your issue.

My best guess is to try to figure out how the tolerance or "step" part of PixelSearch REALLY works. There could be a way to search for anything but a color that way.

Link to comment
Share on other sites

I don't suppose this would be related to Ladder Slasher?

If this is a game then there are probably more effective ways of approaching your issue.

My best guess is to try to figure out how the tolerance or "step" part of PixelSearch REALLY works. There could be a way to search for anything but a color that way.

Ah, ic. yeah it is game related but not Ladder slashers. I'm really just trying to get used to coding in autoit and using the ladderslasher example was the best way for me to get my point across.

Link to comment
Share on other sites

Ah, ic. yeah it is game related but not Ladder slashers. I'm really just trying to get used to coding in autoit and using the ladderslasher example was the best way for me to get my point across.

If you're just learning then you can do what I did. I basically spent time searching for and looking through scripts that did things similar to what I needed to do. Now I can bot almost any 2D game lol.

Link to comment
Share on other sites

If you're just learning then you can do what I did. I basically spent time searching for and looking through scripts that did things similar to what I needed to do. Now I can bot almost any 2D game lol.

That is usually how i learn how to code. i look at other codes and i change them to fit my needs and i learn and grow off of that. That is how i figured out how to do what i can do in auto it atm. Except, i just figured since there is a nice forums here, (and sice im kinda lazy) i figured i would just post my question in its entirety on this site and see what i could get out of it.

Link to comment
Share on other sites

have a look at SendKeyDownDelay in the helpfile, and maybe use it before your mouseclick.

... Ok? Thanks, although it didnt really answer anything. I need to know how to make it go to the random color in the designated area. the clicking and all that i know how to do

Edited by Shakala
Link to comment
Share on other sites

... Ok? Thanks, although it didnt really answer anything. I need to know how to make it go to the random color in the designated area. the clicking and all that i know how to do

I can think of two approaches:

$SearchPosX = 200
$SearchPosY = 500
$SearchWidth = 400
$SeachHeigth = 300

For $iWidth = $SearchPosX To $SearchPosX + $SearchWidth
   For $iHeigth = $SearchPosY To $SearchPosY + $SearchHeigth
      If PixelGetColor($iWidth,$iHeigth) <> 0x000000 Then
          ;your response here
      EndIf
   Next
Next

Which I guess will be to slow, but I havn't tested it, or set PixelSearch() to search for black, but set the variation so high that it will pick up everything but a few very light shades.

Link to comment
Share on other sites

I can think of two approaches:

$SearchPosX = 200
$SearchPosY = 500
$SearchWidth = 400
$SeachHeigth = 300

For $iWidth = $SearchPosX To $SearchPosX + $SearchWidth
   For $iHeigth = $SearchPosY To $SearchPosY + $SearchHeigth
      If PixelGetColor($iWidth,$iHeigth) <> 0x000000 Then
          ;your response here
      EndIf
   Next
Next

Which I guess will be to slow, but I havn't tested it, or set PixelSearch() to search for black, but set the variation so high that it will pick up everything but a few very light shades.

if i do it the way you suggested first, with the for loops, how would i make my mouse go to that position? i realized in a earlier post i said "i know how to do the clicking and all that" but getting the mouse to the position is another issue. Edited by Shakala
Link to comment
Share on other sites

*Shorter version. i want it to search for a non-white pixel in a selected area. the colors of the pixels and locations are random.

well, it has been said before but I think the solution is to use a simple pixlesearch:

Func search ()
$coord = PixelSearch (left,top,right,bottom, 0x000000,254) ;search the area for any non pure white pixel

If @error then 
    msgbox (1,"","there is only pure white") ;no matching pixel was found
Else
    MouseClick ( button, $coord[0], $coord[1],1,0) ;mouse click at the coordinates where the non-white pixel was found
EndIf
EndFunc
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...