Python Forum

Full Version: mouse position
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,
I am new to python
How to get mouse position after click

Example

I clicked on the screen , outuput should show x and y cordinates where i clciked on the screen


Thanks
For what OS? This might be helpful.
Depends largely on the GUI you are using. If wx, then the wx.MouseEvent and wx.MouseState would be helpful. I don't use Tkinter but a quick google search suggests winfo_pointerx() and winfo_pointery(). If pyautogui then apparently pyautogui.position() returns the x and y positions
A lot more information is required. What kind of application are you trying to write; console application, GUI application, game, other?

Why do you need the mouse position?

What have you tried so far to get the mouse position? Of the things you've tried, how are they not working? Do they have an error that prevents them from running? Do they have an error that causes them to crash? Do they run but not provide the mouse position?