How can I get position of a screen text with python?

Viewed 28

I need to write a program that press a button, so python have to find the text of the button on the screen and it needs to find the position of this button to press it. But I can do this?

I searched a lot on google, but I don't find an answer. I only use pytesseract to find the text on the screen.

1 Answers

You can do binary search:

  1. Divide your screen in two
  2. Use pytesseractto know in which half the wanted text is.
  3. Divide it again in two.
  4. Repeat step 2

Another way to do it, if the screen is your browser, is use HTML, find the button using re(Regular expressions), get the link which button calls (normally it's a javascript function). Then you can call it to artificially click on the button.

Related