# Wait for captcha to be solved while 1: if p.locateOnScreen( 'ReferenceImages/captchaSolve.png', confidence=0.85) is None and p.locateOnScreen( 'ReferenceImages/captcha.png', confidence=0.85) is None: sleep(1) if p.locateOnScreen('ReferenceImages/captcha.png', confidence=0.85) is None: break checker.isDetected = False window.configure(width=WIDTH, height=HEIGHT) display.sync() else: # Get the image of the screen raw = window.get_image(0, 0, WIDTH, HEIGHT, Xlib.X.ZPixmap, 0xffffffff) image = Image.frombytes('RGB', (WIDTH, HEIGHT), raw._data['data'], 'raw', 'BGRX') # Act on it targetAngle = ai.act(image) * pi / 180 r = 150 x = cos(targetAngle) * r + centerX y = sin(targetAngle) * r + centerY mouse.position = (x, y) sleep(1 / 60) onDeath()