0

I'm making a script in Python (without an interface) that requires the user to click certain places on the screen so I can retrieve the mouse position.

With pyautogui it's pretty easy to get the position of the mouse. Yet, there seems to be no click event, wait click or anything like that.

Considering that the click can be ANYWHERE (including outside of the IDE, and even if the IDE is minimized), is there any way to get a click event or actively wait for a click?

9
  • 1
    Can you use pynput? E.g. Commented Feb 8, 2024 at 23:36
  • @importrandom, sounds like a good thing to try Commented Feb 8, 2024 at 23:40
  • Does the job for me. Commented Feb 8, 2024 at 23:52
  • You could also use mouse, although it isn't great. Only thing you could do is check if a mouse click happened, using mouse.is_pressed('left'), and you'd need a while loop to do that, just a suggestion in case pynputdoesn't work. Commented Feb 9, 2024 at 22:11
  • pynput works well but not everywhere.... sometimes it captures the clicks outside the IDE, sometimes it doesn't, especially if the click is on another program. Commented Feb 10, 2024 at 1:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.