← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #708157]: Want to continue with my Script when a counter on screen stops

 

Question #708157 on SikuliX changed:
https://answers.launchpad.net/sikuli/+question/708157

Emma Jackson posted a new comment:
<p>Hello! It sounds like you're dealing with a dynamic counter in
Sikulix. To address this, you can use Sikulix's image recognition
capabilities to continuously monitor the counter and perform actions
accordingly. Here's a simple script to get you started:</p>

<pre>
<code>
# Import the necessary Sikulix modules
from sikuli import *

# Function to click on a specific part of the screen
def click_on_screen(x, y):
    click(Location(x, y))

# Main script
counter_image = "counter.png"  # Replace with the actual image file of the counter
max_seconds = 5  # Adjust as needed

while True:
    if exists(counter_image):
        # Counter is still going up
        for _ in range(max_seconds):
            click_on_screen(100, 200)  # Replace with the coordinates you want to click
            wait(1)  # Wait for 1 second before clicking again
    else:
        # Counter has stopped, continue with the rest of your script
        break
</code>
</pre>

<p>Make sure to replace "counter.png" with the actual image file
representing the counter, and adjust the coordinates (100, 200) to the
location you want to click. This script will continuously click on the
specified location as long as the counter is detected on the screen,
waiting 1 second between each click. Once the counter disappears, the
script breaks out of the loop and continues with the rest of your
code.</p>

<p>Feel free to customize the script further based on your specific
requirements.</p>

<p>For more information on Medical Diagnostic Imaging, you can visit <a
href="https://maxresolutionimaging.com/";>Medical Diagnostic
Imaging</a>.</p>

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for SikuliX.