Jump to content
Sign in to follow this  
RyGoTypE

PixelSearch() & Frames

Recommended Posts

RyGoTypE

Does PixelSearch() work in website frames? It doesn't seem to be working for me.

; Search for Box A Color: 0xFFFFD8
$box_a = PixelSearch(135, 503, 253, 354, 0xFFFFD8, 5)
If Not @error Then
    MouseMove($box_a[0], $box_a[1], 10)
    ToolTip('Found Box A! Now find Link A.',0,0)
    Sleep(5000)
EndIf

; Find Link A and click it Color: 0x0000FF
$link_a = PixelSearch(140, 500, 258, 351, 0x0000FF, 5)
If Not @error Then
    MouseMove($link_a[0], $link_a[1], 10)
    ToolTip('Found Link A! Now click Link A.',0,0)
    Sleep(2000)
    MouseClick ("left", $link_a[0], $link_a[1], 1, 10)
    ToolTip('Clicked Link A! Now wait for the page to count down before clicking the arrow.',0,0)
EndIf

Sleep(30000) ; 30 second rest

; Search for the top section for the Next Arrow Color: 0xFFFFCC
$coord = PixelSearch( 0, 135, 1023, 225, 0xFFFFCC )
If Not @error Then
    MouseMove($coord[0], $coord[1], 10)
    ToolTip('Next Arrow Located!',0,0)
    Sleep(2000) ; 2 second rest
    MouseClick ("left", $coord[0], $coord[1], 1, 10)
    ToolTip('Next Arrow clicked! Now wait for the page to load and find Box B.',0,0)
    Sleep(5000) ; 5 second rest
EndIf

ToolTip('Script not finished, but this is a decent start.',0,0)

Sleep(5000) ; 5 second rest

It works perfectly on the top frame, but the bottom frame doesn't seem to work. (Bottom frame is where boxes and links are being searched and the top frame is where the arrow is being searched.)

Edited by RyGoTypE

Share this post


Link to post
Share on other sites
JohnOne

I'm far from certain about this

$boxa = PixelSearch(135, 503, 253, 354, 0xFFFFD8, 5)
$linka = PixelSearch(140, 500, 258, 351, 0x0000FF, 5)

If Not @error Then

But would that only return an error if $linka was not found ?

Im not sure its checking for error with $boxa


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
RyGoTypE

Okay, I updated the code. Does that seem more accurate?

It still does nothing with the bottom frame. It just skips the find Box A and find Link A. Sleeps for 30 seconds, then clicks the arrow in the top frame.

I don't know why it's not doing anything with the bottom frame...

Share this post


Link to post
Share on other sites
JohnOne

Ive had problems in the past with @error, I dont quite get it sometimes

Put this line in your code to test you are getting your array of coords

It may be that it needs to be If @error = 0

not sure but this should disp[lay an array if there is one there

#include <Array.au3>

; Search for Box A Color: 0xFFFFD8
$box_a = PixelSearch(135, 503, 253, 354, 0xFFFFD8, 5)
_ArrayDisplay($box_a,"Result") ;Put line in to test your array
If Not @error Then
    MouseMove($box_a[0], $box_a[1], 10)
    ToolTip('Found Box A! Now find Link A.',0,0)
    Sleep(5000)
EndIf

edit: Missed include

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
AndyG

Hi,

PixelSearch ( left, top, right, bottom, colour [, shade-variation [, step [, hwnd]]] )

$linka = PixelSearch(140, 500, 258, 351, 0x0000FF, 5)

if 500 is the top koord, then 351 is not the bottom^^ . Your coordinates mark the bottom left corner and the top right corner of the rectangle. Pixelsearch expects the left top and right bottom corners of the area imho. 

I am not really sure, but there were changes (beta?) of the pixelsearch-function, which allow to search from right to left or something like this.....so your coordinates could not be so wrong :)

Andy

Share this post


Link to post
Share on other sites
RyGoTypE

@JohnOne

There was no need to apply your code, AndyG corrected my issue here!

@AndyG

PixelSearch --

Searches a rectangle of pixels for the pixel color provided.

PixelSearch ( left, top, right, bottom, color [, shade-variation [, step [, hwnd]]] )

You were right champ! Thank you very much. I had my coordinates mixed up. Script works perfectly now with correct coordinates! haha.

Thanks guys.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.