Jump to content

Finding a Color


Duran
 Share

Recommended Posts

I dunno if there is a cleaner why to write this but tell me what you guys think. This script finds a color in a specified area and performs a click each time it finds the color.

HotKeySet("{F1}", "Terminate")

While 1
    $var = PixelGetColor(x, y)
    $Color = Hex($var, 6)
    if $Color = "FF9933" Then
        MouseClick("Left", x, y, 2)
        Sleep(500)
    EndIf
WEnd

Func Terminate()
    Exit 0
EndFunc
Link to comment
Share on other sites

yours would work, possibly this also? its shorter by a few lines. . ..

$Color = "FF9933"

while1

pixelsearch(x,x,y,y,FF9933)

if not @error then MouseClick("Left", x, y, 2)

sleep(500)

wend

not much smaller but slightly

GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size
Link to comment
Share on other sites

yours would work, possibly this also? its shorter by a few lines. . ..

$Color = "FF9933"

while1

pixelsearch(x,x,y,y,FF9933)

if not @error then MouseClick("Left", x, y, 2)

sleep(500)

wend

not much smaller but slightly

This would probably work just as well but it's much shorter

;
[/code


            
                


    Edited  by martin
    
    

            
        

        

        
            

    
        

        
            
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
        
    

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


Duran
            
            
                Posted 
                
            
        
    
    
        


Duran
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                Active Members
                
            
            
                
                    
                        
                            
                                
                            
                                 27
                            
                                
                            
                        
                        
                    
                
            
            
                

            
        
    
    
        



    
        
            
                
                    
                        Author
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                
            
        
    

    

    

    
        
        
            This would probably work just as well but it's much shorter
 

;

[/code

You missed the closing of that bracket "]"

But yeah that does look a little smaller but do you think looking for the color my way would be quicker or would the pixelsearch go faster? This was just a simple clicker I had made a bit back to click in an area that had the color which it would not be moving nor have to really look for it because the color comes up in the area that its set at. Just trying to see if there is any other cleaner ways to put it so that I can maybe learn a few different ideas to work with.

Link to comment
Share on other sites

You missed the closing of that bracket "]"

But yeah that does look a little smaller but do you think looking for the color my way would be quicker or would the pixelsearch go faster? This was just a simple clicker I had made a bit back to click in an area that had the color which it would not be moving nor have to really look for it because the color comes up in the area that its set at. Just trying to see if there is any other cleaner ways to put it so that I can maybe learn a few different ideas to work with.

Yes I missed the bracket somehow.

I was being a bit unkind, but since the x and y values are never set then I would not expect the script to run so I thought my code would be just as effective.

If you want to know which way is faster then just try them both and add a counter and a timer to find out.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

$Var = PixelSearch( Left, Top, Right, Bottom, FF3399); Tells it to find the x and y coordinates ;of ;FF3399 color, in the rectangle you created by filling in "left, top, right, bottom" with the ;appropriate coords.

If NOT @error Then ; self explanitory

MouseClick( $Var[0], $Var[1], 1) ; Tells it to click on the coordinates it retrieved, one time. ( ;Default = left click, and a speed of about 10.)

;That would find the specified color ( you can find this color by using the Autoit Window tool )

I used this last program I made to find things and click them, or something similar. I'm new to autoit but I do like helping :P sorry if I misunderstood the Q.

Edited by Drew
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...