Sign in to follow this  
Followers 0
Sleepyguy

Apply offsets to a PixelSearch result

4 posts in this topic

I am very new to autoit and have been working my way though problems with wikis but ran into something I can't find online. My goal is to search for a color on screen and then apply offsets to the coordinates. Basically find the colored spot then click low and right of it. Something like this:

$sm = PixelSearch( 239, 279, 301, 337, $Green, 15)
If Not @error Then
    MouseClick("PRIMARY", ($sm [0]+20) , ($SMr [1]+20) , 1, 5)
    Sleep(500)
EndIf

 

I likely will have loads more questions as I evolve but for now hope to limit it to this. The target is always lower right but targets move around so I need a moving detection with a constant offset.

Share this post


Link to post
Share on other sites



Sorry the $smr is a typo and will be changed.

$sm = PixelSearch( 239, 279, 301, 337, $Green, 15)
If Not @error Then
    MouseClick("PRIMARY", ($sm [0]+20) , ($sm [1]+20) , 1, 5)
    Sleep(500)
EndIf

 

Also tried:

$sm = PixelSearch( 239, 279, 301, 337, $Green, 15)
If Not @error Then

$sma = $sm [0] + 30

$smb = @sm [1] + 30
    MouseClick("PRIMARY", $sma , $smb , 1, 5)
    Sleep(500)
EndIf

Share this post


Link to post
Share on other sites

I figured it out. Thank you.

 

added Local $sma = $sm [0] + 30

 

And it works. Likely not cleanest coding but as time progresses I shall learn better. Looking forward to making more advanced scripts as there is loads of tasks at work would like to automate. Like clicking okay, yes, yes, ok, confirm just for a single export.

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  
Followers 0