[SCAR] Optical Neopet Reader

Discussion in 'Code Snippets and Tutorials' started by zav75, Mar 17, 2007.

  1. zav75

    zav75 Level I

    Joined:
    Feb 28, 2007
    Messages:
    76
    Likes Received:
    6
    Location:
    Canada, Province of Québec
    SCAR can do shits !

    You can use this OPR to buy an item,( Yea you can do an autobuyer with scar), but its a little more slow, so don't count on it to rstock r99 items. (Never tryed tho)

    [​IMG]

    Its takes around 100 ms to find the neopet in the picture. (cause there's an writln, else its faster, it can go to 20ms if it's well set). In my image you see where a mouse would clic with, at x,y coodinate that my program have found.

    HOWTO :
    1- Find a buyer picture with a neopet in ( that a program can't find )

    2- Put your firefox/ie in full screen.

    3- Select the firefox/ie window.

    4- start the script


    Code ( (Unknown Language)):
    1. <div class="scar" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000000; font-weight: bold;">program</span> ScarOPR;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000000; font-weight: bold;">var</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">x,y,i,j,startTime,endTime:<span style="color: #993333;">integer</span> ;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;found : <span style="color: #993333;">boolean</span> ;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000000; font-weight: bold;">procedure</span> findNeopet; &nbsp;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000000; font-weight: bold;">begin</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">startTime:= GetSystemTime<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000066;">Writeln</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'Looking the pic'</span><span style="color: #66cc66;">)</span>;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">found:= <span style="color: #000000; font-weight: bold;">false</span>;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">i:= <span style="color: #cc66cc;">324</span> ;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000000; font-weight: bold;">while</span><span style="color: #66cc66;">(</span> i < <span style="color: #cc66cc;">552</span> &nbsp;<span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">and</span> <span style="color: #66cc66;">(</span> <span style="color: #000000; font-weight: bold;">not</span> found<span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #808080; font-style: italic;">//may have to adjust</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000000; font-weight: bold;">begin</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">j:=<span style="color: #cc66cc;">591</span>;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #66cc66;">(</span> j < <span style="color: #cc66cc;">798</span><span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">and</span> <span style="color: #66cc66;">(</span> <span style="color: #000000; font-weight: bold;">not</span> found<span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #808080; font-style: italic;">//may have to adjust</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; <span style="color: #000000; font-weight: bold;">begin</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #66cc66;">(</span> GetColor<span style="color: #66cc66;">(</span>i,j<span style="color: #66cc66;">)</span> < <span style="color: #cc66cc;">4500000</span><span style="color: #66cc66;">)</span> <span style="color: #000000; font-weight: bold;">and</span> <span style="color: #66cc66;">(</span>GetColor<span style="color: #66cc66;">(</span>i,j<span style="color: #66cc66;">)</span> > <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">)</span> &nbsp; <span style="color: #000000; font-weight: bold;">then</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">begin</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; <span style="color: #000066;">Writeln</span><span style="color: #66cc66;">(</span> <span style="color: #000066;">inttostr</span><span style="color: #66cc66;">(</span>GetColor<span style="color: #66cc66;">(</span>i,j<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>+<span style="color: #ff0000;">' at '</span>+<span style="color: #000066;">inttostr</span><span style="color: #66cc66;">(</span>i<span style="color: #66cc66;">)</span>+<span style="color: #ff0000;">' '</span>+<span style="color: #000066;">inttostr</span><span style="color: #66cc66;">(</span>j<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">)</span>;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; found := <span style="color: #000000; font-weight: bold;">true</span>;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">end</span>;<span style="color: #808080; font-style: italic;">//end of if &nbsp;color < 4 500 000</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; j:= j <span style="color: #cc66cc;">+3</span> ; &nbsp;<span style="color: #808080; font-style: italic;">//faster search</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; <span style="color: #000000; font-weight: bold;">end</span>;<span style="color: #808080; font-style: italic;">//end of "for loop' of 'Y'</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">i:= i + <span style="color: #cc66cc;">3</span> ; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//faster search</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000000; font-weight: bold;">end</span>;<span style="color: #808080; font-style: italic;">//end of 'for loop' of 'X'</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp;x:= i ;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp;y := j ;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; endTime:= GetSystemTime<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000066;">Writeln</span><span style="color: #66cc66;">(</span><span style="color: #000066;">inttostr</span><span style="color: #66cc66;">(</span> endTime - startTime <span style="color: #66cc66;">)</span>+<span style="color: #ff0000;">' <-- time of program in ms'</span> <span style="color: #66cc66;">)</span>;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000000; font-weight: bold;">end</span>;<span style="color: #808080; font-style: italic;">//end of procedure</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000000; font-weight: bold;">begin</span> &nbsp; <span style="color: #808080; font-style: italic;">//start of main program</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">ClearDebug;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">findNeopet;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #000000; font-weight: bold;">end</span>. &nbsp;<span style="color: #808080; font-style: italic;">//end of main program</span></li></ol></div>
     
  2. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    omg this looks amazing
    zav75 you should definately apply for the programming team
    edit: while makng my aber, i ofund that it constantly didn't work as it picked the wrong place
    is there anyway to make sure it alway sgoes to the right spot?
     
  3. zav75

    zav75 Level I

    Joined:
    Feb 28, 2007
    Messages:
    76
    Likes Received:
    6
    Location:
    Canada, Province of Québec
    If I understand well, after finding an item, the script clic on it, clic on "ok" and your at the buyer page, now the OPR can't find the item, that because you did not re-spicified the client windows in you're program, there's serveral ways to do so, it clic probably in the right of you're scren.

    If you just want to look if my OPR works and don't play with client window specifications, juste go right at the buyer(where the hidden neopet in the pic is) it'll tell the position if you drag manually the crosshair of client window.

    I'll upload pictures.
     
  4. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    nice pictures
    it doesn't work for me though still it always goes to a piece for dark text for some reason
    oh i pmed you a screenie of what i mean
    EDIT: just want to tell everyone, after a minute change in the code, it works on nearly all of the pictures
    also my msaber in scar is nearly done
    just got to auth and code it
     
  5. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    umm... i cant get this to work, at all. can someone help me with it.
     
  6. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    ok what you need to do is to change the bits which say may have to adjust in comments to your screen (when you go to the buy screen, change them so they are as close to the picture of the neopet box as possible)
     
  7. Billy

    Billy Level IV

    Joined:
    Feb 21, 2007
    Messages:
    1,856
    Likes Received:
    39
    so change the coordinates to the middle of the box?