How to use if 4 colors positions of 5 are equal? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pr1mal
Posts: 4
Joined: 08 Mar 2017, 13:29

How to use if 4 colors positions of 5 are equal?

Post by pr1mal » 02 Apr 2023, 05:45

Hi,

I'm running a script wich scans five locations via PixelGetColor.

if (ColorPos1==ColorPink) and (ColorPos2==ColorPink) and (ColorPos3==ColorPink) and (ColorPos4==ColorPink) and (ColorPos5==ColorPink)
gosub, Pink

If all 5 ColorsPositions equal ColorPink the script is hopping to Pink: , so far so good :)

It would be nice to have the script hopping to Pink: even if only 4 of thoses ColorPositions equal ColorPink..

Using
if ((ColorPos1==ColorPink) and (ColorPos2==ColorPink) and (ColorPos3==ColorPink)) and ((ColorPos4==ColorPink) or (ColorPos5==ColorPink)) and
((ColorPos1==ColorPink) and (ColorPos2==ColorPink) and ((ColorPos3==ColorPink) or (ColorPos4==ColorPink)) and (ColorPos5==ColorPink)) and [..]

looks like a mess.. can someone help me to clean this up?

tyvm


[Mod action: Moved topic to v1 section. The main section is for v2.]

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: How to use if 4 colors positions of 5 are equal?  Topic is solved

Post by mikeyww » 02 Apr 2023, 07:18

Code: Select all

#Requires AutoHotkey v1.1.33
sum := (ColorPos1 = ColorPink)
     + (ColorPos2 = ColorPink)
     + (ColorPos3 = ColorPink)
     + (ColorPos4 = ColorPink)
     + (ColorPos5 = ColorPink)
If (sum > 3)
     MsgBox 64, Sum = %sum%, Done!
Else MsgBox 48, Sum = %sum%, Not done!

pr1mal
Posts: 4
Joined: 08 Mar 2017, 13:29

Re: How to use if 4 colors positions of 5 are equal?

Post by pr1mal » 02 Apr 2023, 10:52

tyvm!

Post Reply

Return to “Ask for Help (v1)”