mirror of
				https://github.com/bspeice/libcvautomation
				synced 2025-11-04 02:10:35 -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:
		@ -146,44 +146,58 @@ click_i ()
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
	out "click_i: matching $@"
 | 
						out "click_i: matching $@"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for x in $@
 | 
						if [ -n "$USE_CENTER" ]; then
 | 
				
			||||||
	do
 | 
							center="c"
 | 
				
			||||||
		if [ -n "$USE_CENTER" ]; then
 | 
						else
 | 
				
			||||||
			center="c"
 | 
							center=""
 | 
				
			||||||
		else
 | 
						fi
 | 
				
			||||||
			center=""
 | 
					
 | 
				
			||||||
 | 
						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_SANE_TOLERANCE" ]; then
 | 
						fi
 | 
				
			||||||
			TOLERANCE_OPTION="-o"
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			TOLERANCE_OPTION="-t"
 | 
					 | 
				
			||||||
		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
 | 
						return $RETURN_CODE
 | 
				
			||||||
}	# ----------  end of function click_i  ----------
 | 
					}	# ----------  end of function click_i  ----------
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user