How to use the pyscreeze.ImageNotFoundException function in PyScreeze

To help you get started, we’ve selected a few PyScreeze examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asweigart / pyscreeze / tests / test_pyscreeze.py View on Github external
def test_locate_filename(self):
        self.assertEqual((94, 94, 4, 4), tuple(pyscreeze.locate('slash.png', 'haystack1.png')))
        self.assertEqual((93, 93, 4, 4), tuple(pyscreeze.locate('slash.png', 'haystack2.png')))

        self.assertEqual((94, 94, 4, 4), tuple(pyscreeze.locate('slash.png', 'haystack1.png', grayscale=True)))
        self.assertEqual((93, 93, 4, 4), tuple(pyscreeze.locate('slash.png', 'haystack2.png', grayscale=True)))

        pyscreeze.USE_IMAGE_NOT_FOUND_EXCEPTION = True
        with self.assertRaises(pyscreeze.ImageNotFoundException):
            pyscreeze.locate('slash.png', 'colornoise.png')
        with self.assertRaises(pyscreeze.ImageNotFoundException):
            pyscreeze.locate('slash.png', 'colornoise.png', grayscale=True)

        pyscreeze.USE_IMAGE_NOT_FOUND_EXCEPTION = False
        self.assertEqual(pyscreeze.locate('slash.png', 'colornoise.png'), None)
        self.assertEqual(pyscreeze.locate('slash.png', 'colornoise.png', grayscale=True), None)
github asweigart / pyscreeze / tests / test_pyscreeze.py View on Github external
def test_imageNotFound(self):
        colorNoiseFp = open('colornoise.png' ,'rb')
        colorNoiseIm = Image.open(colorNoiseFp)
        slashFp = open('slash.png' ,'rb')
        slashIm = Image.open(slashFp)

        pyscreeze.USE_IMAGE_NOT_FOUND_EXCEPTION = True
        with self.assertRaises(pyscreeze.ImageNotFoundException):
            pyscreeze.locate(slashIm, colorNoiseIm)

        pyscreeze.USE_IMAGE_NOT_FOUND_EXCEPTION = False
        self.assertEqual(pyscreeze.locate(slashIm, colorNoiseIm), None)

        colorNoiseFp.close()
        slashFp.close()
github niksaz / dota2-expert-demo / dotaenv / dota_runner.py View on Github external
def __wait_until_image_is_displayed(image_path):
    # Wait for 60 seconds at maximum
    for _ in range(60):
        try:
            point = gui.locateOnScreen(image_path)
            if point:
                return True
        except ImageNotFoundException:
            pass
        time.sleep(1.0)
    return False
github AXeL-dev / Dindo-Bot / pyautogui / __init__.py View on Github external
def wrapper(*args, **kwargs):
        try:
            return wrappedFunction(*args, **kwargs)
        except pyscreeze.ImageNotFoundException:
            raise ImageNotFoundException  # Raise PyAutoGUI's ImageNotFoundException.
github asweigart / pyautogui / pyautogui / __init__.py View on Github external
def wrapper(*args, **kwargs):
        try:
            return wrappedFunction(*args, **kwargs)
        except pyscreeze.ImageNotFoundException:
            raise ImageNotFoundException  # Raise PyAutoGUI's ImageNotFoundException.