#Get and print the mouse coordinates how to
I tried to use the steps from How to get co ordinates of points on mouse click in PyQGIS but when running it jumps right to the end without calling the displaypoint function and there is no reaction to mouse clicks. If you’re trying to map a long series of consecutive mouse movements, here’s a cool suggestion: Modify the above code to copy the following string directly to your clipboard. After filling the UI with information I would like to get the XY coordinates. The position can be displayed simply as (x,y) where x and y are coordinates of the. *crickets chirp* Use it, but don’t abuse it! The application should display the current position of mouse pointer. I may or not be speaking from experience. This is quite handy when you’re, let’s say, trying to program a way to beat an online game in record time. That’s it! You’re finished! Hai finito! When you run your macro, you’ll get a popup messagebox, like the one below:Įach time you move your mouse and rerun the macro, a new messagebox will report your current cursor location. This will return an LPPOINT (pointer to a structure of 2 longs which are the x and y coords). Paste the Cursor Position Example into your new Module If you need to get the screen coords of the mouse position at any point in time you can call the Win32 function GetCursorPos in your message loop.The user32 library can do many things! In addition to returning your cursor coordinates, you can use it to click your mouse and change your cursor position.ĭo you want to read more about the user32.dll library? Check out my mouse control article.Īll you have to do to get this macro to work is: The VBA macro, GetCursorPosDemo, takes advantage of the user32.dll library and our custom data type, POINTAPI, to return your cursor position in a messagebox.