Checking whether an icon exists answers a yes-or-no question. Some Android routines need a number instead: continue when three cards are visible, stop acting when no pending marker remains, or open the next screen only when a list has fewer than five matching items.
EmuloAgent provides an Image counter condition for this case. It captures one visual reference, counts its occurrences inside a detection region, compares the result with a number, and releases the associated action only when that comparison is true.
Use automation only where the app, game, or service allows it. A counter makes a macro’s decision more explicit; it does not change third-party rules.
When an image counter is better than image present
Use a regular image condition when the only meaningful distinction is present or absent. Use the counter when the quantity changes what the macro should do.
Good candidates are repeated elements with a consistent appearance:
- identical status markers in a list;
- repeated cards, slots, or rows with the same icon;
- pending badges inside one panel;
- empty-state markers that should reach zero before the next action;
- a small set of identical controls whose count determines the next step.
Do not use the counter for visually different items just because they mean the same thing. One reference image represents one appearance. If several variants are valid, use separate conditions and combine them deliberately with AND or OR groups.
Define the comparison before opening the builder
Write the condition as a sentence first. This prevents an off-by-one choice in the comparator.
For example:
- “run when there are exactly 3 markers” becomes Equals 3;
- “run when there are more than 2 markers” becomes Greater than 2;
- “run while there are fewer than 5 cards” becomes Less than 5;
- “run when the count is no longer 1” becomes Not equals 1;
- “run when no pending marker remains” becomes Equals 0.
The available comparisons are exact: Equals, Not equals, Greater than, and Less than. There is no “greater than or equal to” option, so express that boundary explicitly. For three or more occurrences, choose Greater than 2.
How to add the Image counter condition
Prepare the emulator on a screen that contains a clean example of the repeated element. Then open the macro and locate the action that should depend on the count.
- On the action card, choose Add condition.
- In the Detection section, select Image counter.
- Drag a tight box around one occurrence of the element. Capture the element itself, not the entire row or panel around it.
- Set the image threshold so the real element matches without accepting similar icons.
- In the Image counter dialog, choose the comparator.
- Enter the Reference count from 0 to 999.
- Confirm, save the macro, and review the resulting condition card.
During execution, EmuloAgent looks for every match above the threshold in the detection region. Nearby detections of the same occurrence are consolidated so one element is not counted repeatedly. The action runs only if the final count satisfies the selected comparison.
Separate the reference image from the detection region
The reference image and the detection region have different jobs:
- the reference image defines what one occurrence looks like;
- the detection region defines where EmuloAgent is allowed to count it.
Capture a compact, distinctive reference. Include enough shape and color to separate the target from nearby elements, but avoid changing text, counters, animation frames, or background that varies from row to row.
Then set the detection region to the part of the screen that contains the full group you want to count. A region that covers only the captured example will usually return one even when more occurrences exist elsewhere. A region that covers the whole emulator may include unrelated matches and does more visual work than necessary.
Open the condition’s menu to use Select detection region independently from Select new image. This separation lets you keep a good reference while expanding or narrowing the search area.
For more guidance on reference images and thresholds, read how to choose and fine-tune image, color, and text detection.
Practical example: continue when no pending badge remains
Suppose a test screen displays the same red pending badge beside every unfinished row. The next action should capture a final screenshot only after all pending items disappear.
Configure the screenshot action with this condition:
count red pending badge equals 0
Build and verify it as follows:
- While at least one pending badge is visible, capture one badge as the reference.
- Set the detection region around the list, excluding navigation and other red icons.
- Choose Equals and enter
0as the reference count. - Save the macro.
- Test a screen with one or more pending badges: the screenshot action must stay blocked.
- Test the completed screen with no pending badge: the screenshot action may run.
This is different from checking whether a completion message exists. The counter tests the state you actually care about: no repeated pending marker remains inside the list.
Tune false counts methodically
If the count is too high, first inspect the reference crop and detection region. The reference may include too little distinctive detail, the threshold may be too permissive, or the region may contain the same icon in an unrelated area.
If the count is too low, check whether:
- some occurrences are partly outside the detection region;
- the element changes color, size, or content between rows;
- an animation was captured instead of a stable frame;
- the threshold rejects valid rendering differences;
- overlapping elements hide part of the reference.
Use the condition menu to Edit image, Select new image, Edit counter, or Select detection region without rebuilding the action. Change one variable at a time and repeat the same test screen so you know which adjustment fixed the count.
Test boundaries, not just the happy path
A numerical condition needs boundary tests. If the rule is Greater than 2, test counts of 2 and 3. If the rule is Equals 0, test 0 and 1. If the rule is Less than 5, test 4 and 5.
Use this compact checklist:
- confirm the count that should keep the action blocked;
- confirm the nearest count that should release it;
- repeat after saving and reopening the macro;
- run one complete pass on one emulator profile;
- verify the profile resolution before expanding execution.
The macro stabilization checklist covers the next step: validating the starting state, waits, stopping behavior, and resolution before running across profiles.
Turn repeated elements into an explicit decision
The Image counter condition is useful when presence alone is not enough. Capture one stable element, restrict counting to the relevant region, choose the exact numerical comparison, and test both sides of its boundary. The macro then acts on an observable quantity instead of assuming how many items are on screen.