make GetPixelColor> work liek GetCursorPos>

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Mark Gevry
Pro Scripter
Posts: 63
Joined: Sat Dec 25, 2004 3:23 pm

make GetPixelColor> work liek GetCursorPos>

Post by Mark Gevry » Wed Dec 29, 2004 2:32 am

Is it possible to do this..

GetPixelColor>x,y,Variable (but leave the x and y like GetCursorPos>x,y
so that it searches the whole screen for the color..so you dont have to do this...)
GetPixelColor>333,444
GetPixelColor>333,445
GetPixelColor>333,446
GetPixelColor>333,447
ETC....
This would be a ncie feature.

-Mark

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Dec 29, 2004 8:27 am

No, but you can search the whole screen with a simple nested loop. You don't need multiple GetPixelColor commands.


Let>XMax=600
Let>YMax=480
Let>X=0
Repeat>X
Let>X=X+1
Let>Y=0
Repeat>Y
Let>Y=Y+1
GetPixelColor>X,Y,c
Message>c
Until>Y,YMax
Until>X,XMax
MJT Net Support
[email protected]

Mark Gevry
Pro Scripter
Posts: 63
Joined: Sat Dec 25, 2004 3:23 pm

Post by Mark Gevry » Wed Dec 29, 2004 2:57 pm

Thank you support. That is just what i needed.

Mark Gevry
Pro Scripter
Posts: 63
Joined: Sat Dec 25, 2004 3:23 pm

Post by Mark Gevry » Wed Dec 29, 2004 3:00 pm

support wrote:


GetPixelColor>X,Y,c
Message>c
Until>Y,YMax
Until>X,XMax
Now after the GetPixelColor> i can add an if> right...I dont want to confuse myself here because i have never used what you just showed me. Everythign is still the same right?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Dec 29, 2004 3:28 pm

Yes, in place of the "Message>c" line (which just displays the colour code in a message box) you can put an If statement and do whatever you want to do should the color match.

If you want to do something only on the first instance of the chosen colour I would use a Goto and jump out of the loop.

On the other hand if you want to perform some routine for every instance of the color you are searching for I would use a GoSub and create a subroutine for the code you want to perform. That way the loop will continue after the subroutine has been performed.
MJT Net Support
[email protected]

Mark Gevry
Pro Scripter
Posts: 63
Joined: Sat Dec 25, 2004 3:23 pm

Post by Mark Gevry » Mon Jan 03, 2005 11:03 pm

support wrote:No, but you can search the whole screen with a simple nested loop. You don't need multiple GetPixelColor commands.


Let>XMax=600
Let>YMax=480
Let>X=0
Repeat>X
Let>X=X+1
Let>Y=0
Repeat>Y
Let>Y=Y+1
GetPixelColor>X,Y,c
Message>c
Until>Y,YMax
Until>X,XMax



Can i do that but only in a certain spot...like a rack of basketballs..just have it look for colors where the coordinates are of the balls.

    User avatar
    support
    Automation Wizard
    Posts: 1450
    Joined: Sat Oct 19, 2002 4:38 pm
    Location: London
    Contact:

    Post by support » Tue Jan 04, 2005 8:00 am

    Yes, just change the start and end positions. Change XMax and YMax accordingly and instead of Let>X=0 and Let>Y=0 at the start of each loop change to the new start positions.
    MJT Net Support
    [email protected]

    Ze penny

    Post by Ze penny » Tue Feb 15, 2005 1:19 am

    Okay, and how would i edit the above script in order to detect 7364178 and after detecting it... it should wait for say 10 seconds and then start searchin for that colour again.

    Guest

    Post by Guest » Tue Feb 15, 2005 5:36 am

    I don't know what you guys are asking for...

    For Ze Penny, couldn't you just monitor one pixel location and have it check whether the color changes to the color you want?
    It wouls just be like
    Label>Start
    Getpixelcolor>X,Y,PC
    If>PC=yourcolor
    place action here (which would likely include a goto to get out of the loop)
    wait>10
    endif
    goto>start

    (I suppsoe using Repeat and Untill would be better, but I didn't know they existed untill recently (I'm used to for loops and while loops, etc.)

    I have no idea What Mark Gevry is suggesting for the program, nor do I know what you want done with your basketball racks or whatever

    Xapti

    Post by Xapti » Tue Feb 15, 2005 5:38 am

    (same user as above)
    Oh yeah forgot to add this:
    Isn't the "message>c" line wrong? it should be "message>%c%"

    Ze penny

    Post by Ze penny » Tue Feb 15, 2005 4:28 pm

    Thanks for the reply guest.
    Could you show me a complete working script that detects multiple colours on the screen and then clicks on it and after clicking once on it .. it starts searching for another one after 10 seconds.

    Also its a particular window that i need the colour detected in but i dont know how to get the x y co-ordinates of that particular window but in the script could u show me how would i be able to do with with the whole window screen. Sorry for the annoying questions.. its just that i am completely new to these stuff. Thanks.

    Post Reply
    Sign up to our newsletter for free automation tips, tricks & discounts