Jump to content
Sign in to follow this  
Duran

Finding a Color

Recommended Posts

Duran

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

Share this post


Link to post
Share on other sites
sebgg

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

Share this post


Link to post
Share on other sites
martin

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.
  


        
    

    
        
            Share this post
            
            Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    

    

                    
                        
                    
                
                    
                    
                    






    

    
        
            
Duran
              

    
        
    
             0
    
        
    

        
        
            

    
        
    

        
    
    
        
Duran   

    
        
    
             0
    
        
    

        
        
            
                Seeker
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             0
    
        
    

                27 posts
                
                

            
        
    
    
        


    

    
        
            
                
                    Report post
                
                
                
                    
                
                
            
        

        
            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.

Share this post


Link to post
Share on other sites
martin

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.

Share this post


Link to post
Share on other sites
Drew

$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

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  

×