Jump to content
Sign in to follow this  
LmdL123

PixelGetColor Problem!

Recommended Posts

Hello,

Can you help me with some part of my script? I have small window of some program. Let's say 600x400 pixels. This is a Flash program. All the problem is that in this program all the background is one color and its a small square there, about 25x25 pixels and different color from background, that is moving all the time in that area. My problem is how to manage my script to move mouse cursor so it will click on that background all the time in different places until it finnaly clicks on this small square.

I think I need to use PixelGetColor (x,y), but how do I use it in this case?

It's small square and it moves along big window in different ways and I need to "catch" this square as fast as possible.

Any suggestions will be helpful. Post!

Share this post


Link to post
Share on other sites

You don't need to click more than once. This is literally like 2 lines of code.

PixelSearch(): Find the X,Y location of a hex color

MouseClick(): Click at previously found X,Y

Share this post


Link to post
Share on other sites

Hmm...

Can somebody help me with script? I don't need something very hard to do. That's all:

Posted Image

1. I need that Autoit scan this Flash-program and find blue "square" (Red arrow points to this square). (Coordinates of window of Flash-program are: 250x185; 930x185; 250x420; 930x420)

2. Left-mouse click on "square".

3. Left-mouse click on point(coordinates 270x150)

4. Waiting for a 60 seconds.

5. Left-mouse click on point(coordinates 620x330).

6. And all from the beginning, finds "square" (it already appears in the different place), clicks on it, .....

Thanks again for you help!!!

Share this post


Link to post
Share on other sites

I got mistake in my script. Can anybody tell me what is wrong?

For $i = 500000 to 1 Step -1
    $coord = PixelSearch ( 250, 185, 420, 930, 0x00FFFF,100 )
    If Not @error Then
    MouseClick( "left" [[[,$coord[0] ,$coord[1]] ,1],10] )
    MouseClick( "left" [[[,270 ,180] ,1],10] ) 
    Sleep(60000)
    MouseClick( "left" [[[,620 ,350] ,1],10] ) 
    EndIf
Next
MsgBox(0,"", "Time Out")

Thanks.

Edited by LmdL123

Share this post


Link to post
Share on other sites

Ok... Read it carefully. Get rid of the '[' and ']'. They are used in arrays only to my memory...

EDIT:

Should end up like:

For $i = 500000 to 1 Step -1
    $coord = PixelSearch ( 250, 185, 420, 930, 0x00FFFF,100 )
    If Not @error Then
        MouseClick( "left" ,$coord[0] ,$coord[1] ,1,10)
        MouseClick( "button" ,270 ,180,1,1)
        Sleep(60000)
        MouseClick( "button" ,620 ,350 ,1,10 )
    EndIf
Next
MsgBox(0,"", "Time Out")

I also changed the If @error == 0 Then to If Not @error, as it works better... :)

Edited by Bert

Share this post


Link to post
Share on other sites

One more problem =) It didn't finds the "square". What color should I enter? I tried aqua (#00FFFF), DarkTurquoise (#00CED1), DeepSkyBlue (#00BFFF).....

Share this post


Link to post
Share on other sites

You need to use the AutoIt Window Info tool to get the EXACT color of the square. Its on your start menu. Just run it and place the mouse over the square to get the hex code.

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  

×
×
  • Create New...