mirror of
https://github.com/bspeice/libcvautomation
synced 2024-12-04 13:58:11 -05:00
Fix the licvautomation_funcs waiting improperly
If you specify multiple images, it would wait for the first, and then the second. Instead, switch this to alternate between each image $TIMEOUT times, so you don't wait forever on the first image to find the second immediately
This commit is contained in:
parent
1dbe466302
commit
528f6d04e5
@ -146,45 +146,59 @@ click_i ()
|
||||
|
||||
out "click_i: matching $@"
|
||||
|
||||
for x in $@
|
||||
do
|
||||
if [ -n "$USE_CENTER" ]; then
|
||||
center="c"
|
||||
else
|
||||
center=""
|
||||
fi
|
||||
if [ -n "$USE_SANE_TOLERANCE" ]; then
|
||||
TOLERANCE_OPTION="-o"
|
||||
else
|
||||
TOLERANCE_OPTION="-t"
|
||||
if [ -n "$USE_CENTER" ]; then
|
||||
center="c"
|
||||
else
|
||||
center=""
|
||||
fi
|
||||
|
||||
if [ -n "$USE_SANE_TOLERANCE" ]; then
|
||||
TOLERANCE_OPTION="-o"
|
||||
else
|
||||
TOLERANCE_OPTION="-t"
|
||||
fi
|
||||
|
||||
|
||||
if [ -n "$USE_WAIT" ]; then
|
||||
#Alternate between each image until a match is found, or we loop $TIMEOUT times
|
||||
#This is a bit weird, since we need to lower the TIMEOUT value for the "waitfor"
|
||||
#function, and then restore it at the end.
|
||||
OLD_TIMEOUT=$TIMEOUT
|
||||
TIMEOUT=1
|
||||
|
||||
for loop in {1..$OLD_TIMEOUT}
|
||||
do
|
||||
for x in $@
|
||||
do
|
||||
|
||||
waitfor "$x"
|
||||
CVA_RETURN=$?
|
||||
|
||||
if [ $CVA_RETURN -lt $RETURN_CODE ]; then
|
||||
RETURN_CODE=$CVA_RETURN
|
||||
fi
|
||||
|
||||
if [ $CVA_RETURN -eq 0 ]; then
|
||||
#We found the image, click it
|
||||
TIMEOUT=$OLD_TIMEOUT
|
||||
eval "$CVAINPUT $TOLERANCE_OPTION $TOLERANCE --search-method $SEARCH_METHOD -s 'i${center}mouseclick $x' >> $OUTFILE"
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
#We'll get here if we don't find a match
|
||||
OLD_TIMEOUT=$TIMEOUT
|
||||
TIMEOUT=1
|
||||
else
|
||||
eval "$CVAINPUT $TOLERANCE_OPTION $TOLERANCE --search-method $SEARCH_METHOD -s 'i${center}mouseclick $x' >> $OUTFILE"
|
||||
CVA_RETURN=$?
|
||||
|
||||
if [ $CVA_RETURN -lt $RETURN_CODE ]; then
|
||||
RETURN_CODE=$CVA_RETURN
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$USE_WAIT" ]; then
|
||||
waitfor "$x"
|
||||
CVA_RETURN=$?
|
||||
|
||||
if [ $CVA_RETURN -lt $RETURN_CODE ]; then
|
||||
RETURN_CODE=$CVA_RETURN
|
||||
fi
|
||||
|
||||
if [ $CVA_RETURN -eq 0 ]; then
|
||||
#We found the image, click it
|
||||
eval "$CVAINPUT $TOLERANCE_OPTION $TOLERANCE --search-method $SEARCH_METHOD -s 'i${center}mouseclick $x' >> $OUTFILE"
|
||||
else
|
||||
return $RETURN_CODE
|
||||
fi
|
||||
else
|
||||
eval "$CVAINPUT $TOLERANCE_OPTION $TOLERANCE --search-method $SEARCH_METHOD -s 'i${center}mouseclick $x' >> $OUTFILE"
|
||||
CVA_RETURN=$?
|
||||
|
||||
if [ $CVA_RETURN -lt $RETURN_CODE ]; then
|
||||
RETURN_CODE=$CVA_RETURN
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
return $RETURN_CODE
|
||||
} # ---------- end of function click_i ----------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user