Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #248036 > unrolled thread

which program can show X/Y position of mouse pointer

Started bylou <loushanguan2015@sina.com>
First post2022-05-09 13:00 +0200
Last post2022-05-10 02:50 +0200
Articles 10 — 5 participants

Back to article view | Back to linux.debian.user


Contents

  which program can show X/Y position of mouse pointer lou <loushanguan2015@sina.com> - 2022-05-09 13:00 +0200
    Re: which program can show X/Y position of mouse pointer Dan Ritter <dsr@randomstring.org> - 2022-05-09 13:30 +0200
      Re: which program can show X/Y position of mouse pointer lou <loushanguan2015@sina.com> - 2022-05-09 14:00 +0200
        Re: which program can show X/Y position of mouse pointer Dan Ritter <dsr@randomstring.org> - 2022-05-09 15:40 +0200
          Re: which program can show X/Y position of mouse pointer lou <loushanguan2015@sina.com> - 2022-05-10 01:30 +0200
            Re: which program can show X/Y position of mouse pointer David Wright <deblis@lionunicorn.co.uk> - 2022-05-10 03:50 +0200
      Re: which program can show X/Y position of mouse pointer Michael Lange <klappnase@freenet.de> - 2022-05-11 11:30 +0200
        Re: which program can show X/Y position of mouse pointer lou <loushanguan2015@sina.com> - 2022-05-12 04:40 +0200
          Re: which program can show X/Y position of mouse pointer Michael Lange <klappnase@freenet.de> - 2022-05-12 11:00 +0200
    Re: which program can show X/Y position of mouse pointer John Hasler <john@sugarbit.com> - 2022-05-10 02:50 +0200

#248036 — which program can show X/Y position of mouse pointer

Fromlou <loushanguan2015@sina.com>
Date2022-05-09 13:00 +0200
Subjectwhich program can show X/Y position of mouse pointer
Message-ID<El9hn-ej4N-1@gated-at.bofh.it>
i use twm for bullseye

i want to record screen with ffmpeg, it allows me to select some region 
of screen

i need a program that can display X/Y coordinates of mouse pointer as i 
move mouse

[toc] | [next] | [standalone]


#248037

FromDan Ritter <dsr@randomstring.org>
Date2022-05-09 13:30 +0200
Message-ID<El9Kp-ejts-7@gated-at.bofh.it>
In reply to#248036
lou wrote: 
> i use twm for bullseye
> 
> i want to record screen with ffmpeg, it allows me to select some region of
> screen
> 
> i need a program that can display X/Y coordinates of mouse pointer as i move
> mouse

xdotool getmouselocation does it once.

You may wish to run it via watch in a tiny xterm and make that
xterm always-on-top.

-dsr-

[toc] | [prev] | [next] | [standalone]


#248038

Fromlou <loushanguan2015@sina.com>
Date2022-05-09 14:00 +0200
Message-ID<Eladr-ejCA-9@gated-at.bofh.it>
In reply to#248037
On 5/9/22 7:09 AM, Dan Ritter wrote:
> xdotool getmouselocation


Thanks!

are you sure that xterm can be made always-on-top in twm?

[toc] | [prev] | [next] | [standalone]


#248041

FromDan Ritter <dsr@randomstring.org>
Date2022-05-09 15:40 +0200
Message-ID<ElbMd-ekEk-3@gated-at.bofh.it>
In reply to#248038
lou wrote: 
> 
> On 5/9/22 7:09 AM, Dan Ritter wrote:
> > xdotool getmouselocation
> 
> 
> Thanks!
> 
> are you sure that xterm can be made always-on-top in twm?

No, I've never used twm. fvwm, sawmill/sawfish, and xfwm can all
do that. Probably most others.

-dsr-

[toc] | [prev] | [next] | [standalone]


#248058

Fromlou <loushanguan2015@sina.com>
Date2022-05-10 01:30 +0200
Message-ID<ElkZb-eqhF-1@gated-at.bofh.it>
In reply to#248041
On 5/9/22 9:21 AM, Dan Ritter wrote:
> No, I've never used twm. fvwm, sawmill/sawfish, and xfwm can all
> do that. Probably most others.
>
> -dsr-


Thanks! i have success with icewm, not with fvwm

xeyes knows mouse movement, it's too bad it doesn't show X/Y coordinates

[toc] | [prev] | [next] | [standalone]


#248061

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2022-05-10 03:50 +0200
Message-ID<ElnaF-errV-3@gated-at.bofh.it>
In reply to#248058

[Multipart message — attachments visible in raw view] — view raw

On Mon 09 May 2022 at 19:20:25 (-0400), lou wrote:
> 
> On 5/9/22 9:21 AM, Dan Ritter wrote:
> > No, I've never used twm. fvwm, sawmill/sawfish, and xfwm can all
> > do that. Probably most others.
> > 
> 
> Thanks! i have success with icewm, not with fvwm
> 
> xeyes knows mouse movement, it's too bad it doesn't show X/Y coordinates

It works just fine in fvwm. I ran this script in an xterm:

while /bin/true
do
    printf '%s ' "$(date +%H:%M:%S)" >> /tmp/mousey-pos
    xdotool getmouselocation >> /tmp/mousey-pos
    sleep 1
done

I ran this command in another xterm:

$ tail -f /tmp/mousey-pos

I then moved the mouse around the corners of the screen, and then
the corners of the xterm window on the screen. I shifted to another
viewport¹ and repeated (screen, then xterm). Then I switched back
to the original viewport to interrupt the script. The mousey-pos
output is attached.

The coordinates are always for the screen that you are staring at,
not the entire virtual desktop. When you move viewports, the window
numbers naturally all change (except for the clocks/pager/xconsole),
but the X/Y values don't.

There's no need to keep any xterm in view while it's running, if
you're recording the output in a file.

If it really doesn't work for you, there may be some dependency on
the way you start fvwm in .xsession which affects the parent-child
relationships, but that's just a guess.

I also tested using it from a bound keystroke, borrowing the
contortionist's keystroke for re-execing my xinput configuration,
Shift-Ctrl-Alt-/, thus:

#Key    slash           A       CMS     Exec exec xinput-xsession quiet
Key     slash           A       CMS     Exec exec xdotool getmouselocation

$ tail -f .xsession-fvwm-0-log

confirmed that this works too:

[fvwm][Echo]: Reading /home/david/.fvwm/main-menu-pre.hook Last edited 2003 July 21
[fvwm][Echo]: Reading /home/david/.fvwm/post.hook Last edited 2022-04-02
[fvwm][Echo]: Reading /home/david/.fvwm/last-post.hook-axis-0 Last edited 2020-04-04
[fvwm][Echo]: Reading /home/david/.fvwm/kbd-base.hook Last edited 2021-11-27
[fvwm][Echo]: Reading /home/david/.fvwm/kbd-axis.hook Last edited 2021-06-18
x:740 y:461 screen:0 window:16777248
x:118 y:83 screen:0 window:16777248
x:1385 y:739 screen:0 window:65011750

I must bind it to a better key. It's a much more controllable
output than xev, John, but I can see virtues in both.

¹ viewport: I have a desktop that's five times wider and four times
higher than the screen, and I switch between these twenty viewports
with clicks in the pager window, or with WindowsKey-arrows or with
Ctrl-Alt-arrows.

A few of the window numbers: root is 1707, …561 and …409 are
swissclocks for two timezones, …761 is the pager, …750 the xconsole,
and all of these are the same in every viewport. …248 is where I ran
the program, started and finished (obviously), and drew the (2nd)
outline round. …400 is an identical xterm on the viewport "next door"
for the 4th outline to go round.

Cheers,
David.

[toc] | [prev] | [next] | [standalone]


#248087

FromMichael Lange <klappnase@freenet.de>
Date2022-05-11 11:30 +0200
Message-ID<ElQPn-eJqg-3@gated-at.bofh.it>
In reply to#248037
On Mon, 9 May 2022 07:09:57 -0400
Dan Ritter <dsr@randomstring.org> wrote:

(...)
> xdotool getmouselocation does it once.
> 
> You may wish to run it via watch in a tiny xterm and make that
> xterm always-on-top.

just for fun I wrote a little Python/Tk script that does what I believe
the OP wants (requires python3-tk):

#############################################################

#!/usr/bin/python3
# -*- coding: utf-8 -*-
'''Shows a tooltip-like window that displays the
x- and y-positions of the mouse pointer on the screen.
Left-click into this window to quit the program.'''

# coordinates of upper left window corner, edit to fit your needs:
WINDOW_X = 0
WINDOW_Y = 0

from tkinter import *
from signal import signal

root = Tk()
root.withdraw()
l = Label(root, text='Mouse position:\nX: 9999   Y:9999',
          width=18, relief='solid', bd=2)
l.pack()
l.is_running = 0
root.wm_overrideredirect(1)
root.wm_geometry('+%d+%d' %(WINDOW_X, WINDOW_Y))

def show_mouse_pos():
    x, y = l.winfo_pointerxy()
    l.configure(text='Mouse position:\nX: %d   Y: %d' % (x, y))
    if l.is_running:
        l.after(100, show_mouse_pos)

def start():
    l.is_running = 1
    l.after(100, show_mouse_pos)

def quit(*args):
    l.is_running = 0
    l.after(200, root.quit)

root.bind('<1>', quit)
for sig in (2, 3, 6, 15):
    signal(sig, quit)
root.update_idletasks()
start()
root.deiconify()
root.mainloop()
root.destroy()

#####################################################

Have a nice day,

Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Killing is wrong.
		-- Losira, "That Which Survives", stardate unknown

[toc] | [prev] | [next] | [standalone]


#248116

Fromlou <loushanguan2015@sina.com>
Date2022-05-12 04:40 +0200
Message-ID<Em6U9-eSRD-5@gated-at.bofh.it>
In reply to#248087
Thank Michael Lange!

it's what i need, and it works fine in twm

no wonder python is so popular these days

PS: why isn't there some existing application that can do this job? is 
my need too special?

[toc] | [prev] | [next] | [standalone]


#248118

FromMichael Lange <klappnase@freenet.de>
Date2022-05-12 11:00 +0200
Message-ID<EmcPU-eWnZ-5@gated-at.bofh.it>
In reply to#248116
Hi,

On Wed, 11 May 2022 22:34:00 -0400
lou <loushanguan2015@sina.com> wrote:

> 
> Thank Michael Lange!
> 
> it's what i need, and it works fine in twm

I am glad if I could help.

Btw, I noticed there is a small bug in the script, there should be an
additional line towards the script's end, so that the end of the script
looks like:

root.bind('<1>', quit)
for sig in (2, 3, 6, 15):
    signal(sig, quit)
root.wm_protocol('WM_DELETE_WINDOW', quit) # I forgot this the other day
root.update_idletasks()
start()
root.deiconify()
root.mainloop()
root.destroy()


There shouldn't happen anything nasty without this "WM-protocol" handler,
however when the window is removed by the window manager, without this
line some ugly "crash message" might show up.

> 
> no wonder python is so popular these days

I guess this could be done with even fewer lines of code when written in
Tcl/Tk, I am just more familiar with Python ;)

> 
> PS: why isn't there some existing application that can do this job? is 
> my need too special?
> 

Actually there is at least one:

https://sourceforge.net/projects/mouseposition/

It works here, looks like it just didn't make it into debian.

Have a nice day,

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

No one wants war.
		-- Kirk, "Errand of Mercy", stardate 3201.7

[toc] | [prev] | [next] | [standalone]


#248060

FromJohn Hasler <john@sugarbit.com>
Date2022-05-10 02:50 +0200
Message-ID<ElmeB-eqUW-3@gated-at.bofh.it>
In reply to#248036
xev -root
-- 
John Hasler 
john@sugarbit.com
Elmwood, WI USA

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web