Show *realtime* mouse cursor coordinates? (Cursor mod / overlay) Also, copy to clipboard?
I'm looking for a solution that would display the current mouse cursor coordinates in realtime (i.e. NOT xdotool and NOT xev).
I need to move the mouse to a certain position, then press Alt-Tab to flip to another window and record the coordinates there. (This would not move the mouse, so the coordinate display would stay the same).
There's a Windows program that works BEAUTIFULLY for this purpose - http://download.cnet.com/Cursor-Position/3000-2383_4-75449858.html?tag=mncol;1
...but it doesn't even start up in Wine.
Alternately, instead of displaying the coordinates, if this solution could copy the coordinates (in XXX,YYY format) to the clipboard, upon pressing a hotkey, that would be even better.
Any suggestions would be much appreciated!
P.S. I'm running Ubuntu 12.04 LTS.
Solution 1:
Spartan solution: you can show the coordinates in real-time with xdotool if you create a bash script. Just execute this in a new Terminal:
while true; do xdotool getmouselocation; sleep 0.2; clear; done
Change the value after sleep to make it more or less "real-time". This requires bash
, the default user shell in Ubuntu.
Better solution: if you have admin rights, install watch
(sudo apt-get install watch
), and then execute this in a new Terminal:
watch -ptn 0 "xdotool getmouselocation"
It uses xdotool
but does not require bash
.
Thank you b_laoshi for your suggestion!
Solution 2:
Get coordinates and copy to clipboard
Displaying the coordinates in real-time has already been addressed, so I won't repeat that answer here. By creating a script and configuring a keyboard shortcut to run it, we can copy mouse coordinates to the clipboard in x,y
format. Here's how:
-
Install xdotool for grabbing coordinates and xsel for managing the clipboard.
sudo apt-get install xdotool xsel
-
Create a new script file with the following contents. Save the script and make it executable.
#!/bin/bash xdotool getmouselocation | grep -oP "[0-9]+ y:[0-9]+" | sed 's/ y:/,/' | tr -d '\n' | xsel --clipboard
-
Create a custom keyboard shortcut that calls your script for the desired key combination.