The time now is Sun 24 Jan 2021, 05:41
All times are UTC - 4 |
Author |
Message |
sc0ttman

Joined: 16 Sep 2009 Posts: 2806 Location: UK
|
Posted: Thu 29 Dec 2011, 11:36 Post subject:
Detecting mouse clicks... Any help or ideas? Subject description: (using xdotool, shell, or any other lightweight or 'built in' method... |
|
UPDATE: Most of this is solved, so I changed the title...
The only thing left to do is DETECT mouse clicks...
How do I use xdotool (or other methods?) to detect a mouse-click?
This should work, but it doesn't:
Code: | xdotool search --name "VLC" behave %@ mouse-click exec 'myscript' |
However, this does work, but is not what I need:
Code: | xdotool search --name "VLC" behave %@ mouse-enter exec 'myscript' |
I'm using xdotool version 2.20101012.304.. EDIT: I also just compiled and tried xdotool version 2.20110530.1...
Same result for both version - 'mouse-click' does not work, but 'mouse-enter' and 'mouse-leave' DO work
_______________________________________________________________
Older post:
I'd like to add a right click menu to VLC video playback windows, by;
1. detecting if a right click is within the VLC window in question,
2. then loading a gtkdialog GUI with <menu> stuff...
I already have stuff in place to detect the window id needed..
It could almost certainly be simplified and improved...
Code: | get_wids () {
#BK vlc 1.1.5 does not display a window with "XVideo output" in title...
#BK note, default video output setting is saved in /root/.config/vlc/vlcrc, exs: vout=xcb_glx, vout=xcb_x11, vout=xcb_xv, vout=vout_sdl
for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #BK delay is needed.
do
wid=`xdotool search --name "(XVideo output)"` # get the vlc playback windowid specifically
[ "$wid" = "" ] && wid=`xdotool search --name "VLC (hardware YUV SDL output)"` #BK output: SDL
[ "$wid" = "" ] && wid=`xdotool search --name "VLC media player"` #BK outputs: XVideo, X11, GLX
[ "$wid" != "" ] && break
CNT=$(($CNT+1))
sleep 0.25
done
vlcwid=`xdotool search --name "vlc"` # look for the vlc window(s)
vlcgtkwid=`xdotool search --name "vlc-gtk"`
guiwid=`xdotool search --name "VLC Controls"`
# start double-checking for wids
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # delay is needed
do
if [ "$wid" = "" ] || [ "$vlcwid" = "" ];then # dont include guiwid here, it wont be created on first call
wid=`xdotool search --name "(XVideo output)"`
[ "$wid" = "" ] && wid=`xdotool search --name "VLC (hardware YUV SDL output)"` #BK output: SDL
[ "$wid" = "" ] && wid=`xdotool search --name "VLC media player"` #BK outputs: XVideo, X11, GLX
vlcwid=`xdotool search --name "vlc"`
vlcgtkwid=`xdotool search --name "vlc-gtk"`
guiwid=`xdotool search --name "VLC Controls"`
sleep 0.25
else
break
fi
done
} |
_________________ Pkg, mdsh, Woofy, Akita, VLC-GTK, Search
Last edited by sc0ttman on Mon 02 Jan 2012, 15:06; edited 2 times in total
|
Back to top
|
|
 |
puppyluvr

Joined: 06 Jan 2008 Posts: 3512 Location: Chickasha Oklahoma
|
Posted: Thu 29 Dec 2011, 14:00 Post subject:
|
|
Hello,
getcurpos
will return cursor location..
Maybe something in
grep "$MOUSE:" /proc/interrupts
to detect clicks???
_________________ Close the Windows, and open your eyes, to a whole new world
I am Lead Dog of the
Puppy Linux Users Group on Facebook
Join us!
Puppy since 2.15CE...
|
Back to top
|
|
 |
seaside
Joined: 11 Apr 2007 Posts: 937
|
Posted: Fri 30 Dec 2011, 17:34 Post subject:
|
|
sc0ttman,
Just a total shot in the dark and I'm not anywhere to test...
maybe mouseup or mousedown?
Regards,
s
|
Back to top
|
|
 |
sc0ttman

Joined: 16 Sep 2009 Posts: 2806 Location: UK
|
Posted: Fri 30 Dec 2011, 21:01 Post subject:
|
|
seaside wrote: | sc0ttman,
Just a total shot in the dark and I'm not anywhere to test...
maybe mouseup or mousedown?
Regards,
s |
Unfortunately not...
Code: | # xdotool search --name "VLC" behave %@ mouse-down exec 'woofy'
Unknown event 'mouse-down'
# xdotool search --name "VLC" behave %@ mouse-up exec 'woofy'
Unknown event 'mouse-up'
# xdotool search --name "VLC" behave %@ mouseup exec 'woofy'
Unknown event 'mouseup'
# xdotool search --name "VLC" behave %@ mousedown exec 'woofy'
Unknown event 'mousedown' |
_________________ Pkg, mdsh, Woofy, Akita, VLC-GTK, Search
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4878 Location: Blue Springs, MO
|
Posted: Fri 30 Dec 2011, 22:04 Post subject:
|
|
My laptop just died on me, so I can't test, but xwininfo to get vlc location and geometry and some Keylogger/getcurpos to hack for mouse clicks. (bonus with a Keylogger, you can have hotkeys)
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
sc0ttman

Joined: 16 Sep 2009 Posts: 2806 Location: UK
|
Posted: Sat 31 Dec 2011, 09:52 Post subject:
|
|
technosaurus wrote: | My laptop just died on me, so I can't test, but xwininfo to get vlc location and geometry and some Keylogger/getcurpos to hack for mouse clicks. (bonus with a Keylogger, you can have hotkeys) |
Yet to tackle mouse clicks, but this is what I got so far:
Code: | # XPOS=`xwininfo -name Transmission | grep geometry | cut -f4 -d' '| cut -f2 -d'+'`
# YPOS=`xwininfo -name Transmission | grep geometry | cut -f4 -d' '| cut -f3 -d'+'`
# WIDTH=`xwininfo -name Transmission | grep geometry | cut -f4 -d' '| cut -f1 -d'x'`
# HEIGHT=`xwininfo -name Transmission | grep geometry | cut -f4 -d' '| cut -f2 -d'x' | cut -f1 -d'+'`
# XPOSEND=$(($XPOS + $WIDTH))
# YPOSEND=$(($YPOS + $HEIGHT))
# CURX=50
# CURY=300
# echo "$XPOS+$WIDTH=$XPOSEND, $YPOS+$HEIGHT=$YPOSEND, $CURX and $CURY"
21+447=468, 0+310=310, 50 and 300
# [ $CURX -gt $XPOS ] && [ $CURX -lt $XPOSEND ] && [ $CURY -gt $YPOS ] && [ $CURY -lt $YPOSEND ] && echo inside || echo outside
inside
# CURX=500
# [ $CURX -gt $XPOS ] && [ $CURX -lt $XPOSEND ] && [ $CURY -gt $YPOS ] && [ $CURY -lt $YPOSEND ] && echo inside || echo outside
outside
# CURX=100
# CURY=450
# [ $CURX -gt $XPOS ] && [ $CURX -lt $XPOSEND ] && [ $CURY -gt $YPOS ] && [ $CURY -lt $YPOSEND ] && echo inside || echo outside
outside
# CURY=250
# [ $CURX -gt $XPOS ] && [ $CURX -lt $XPOSEND ] && [ $CURY -gt $YPOS ] && [ $CURY -lt $YPOSEND ] && echo inside || echo outside
inside |
Also can use this:
Code: | # CURX=`getcurpos | cut -f1 -d' '`
# CURY=`getcurpos | cut -f2 -d' '` |
_________________ Pkg, mdsh, Woofy, Akita, VLC-GTK, Search
Last edited by sc0ttman on Sat 31 Dec 2011, 11:25; edited 2 times in total
|
Back to top
|
|
 |
big_bass
Joined: 13 Aug 2007 Posts: 1742
|
Posted: Sat 31 Dec 2011, 10:41 Post subject:
|
|
Hey sc0ttman
--------------------------------------------------------------------------
a different topic but this may interest you
well it uses mplayer but you could modify this frontend for VLC
and it calls gtk directly so events are allowed
also shows the power of BaCon
http://www.murga-linux.com/puppy/viewtopic.php?t=69647&start=11
------------------------------------------------------------------------
now I will get to your question
here you replace the rxvt with your apps name its only so you can test
and get an idea what to expect
this gets your display info
Code: | xwininfo -name rxvt |
this monitors the events taking place
*I had to compile xev I got it from the X11 sources
(I used slackware sources ) it works fine for me
oh I dont want to forget most of all have fun
these are the spices I can offer to your code soup
use any to your preferences or none at all its your soup
Joe
|
Back to top
|
|
 |
sc0ttman

Joined: 16 Sep 2009 Posts: 2806 Location: UK
|
Posted: Sat 31 Dec 2011, 10:58 Post subject:
|
|
thanks bigbass... I added xev to my system about 2 or 3 months ago.. then forgot about it! lol.. I will look into `xev -name`...
And thanks for the links as well, I'll have a look through the thread, see what I am missing out on
_________________ Pkg, mdsh, Woofy, Akita, VLC-GTK, Search
|
Back to top
|
|
 |
sc0ttman

Joined: 16 Sep 2009 Posts: 2806 Location: UK
|
Posted: Sat 31 Dec 2011, 12:25 Post subject:
|
|
Damn.. so close.. Al I need is what I thought would be the easy part - detecting a mouse click.. I can verify if the mouse is within a given program window, I just need to monitor for mouse clicks and run my script when the mouse is clicked.. my script will do the rest..
I am using this:
Code: | #!/bin/sh
# sc0ttman, 31/12/2011
XPOS='' YPOS='' WIDTH='' HEIGHT='' XPOSEND='' YPOSEND='' CURX='' CURY='' INSIDEPROG=''
[ "$1" = "" ] && PROG="Transmission" || PROG="$1"
# get X and Y positions of $PROG
XPOS=`xwininfo -name "$PROG" | grep geometry | cut -f4 -d' '| cut -f2 -d'+'`
YPOS=`xwininfo -name "$PROG" | grep geometry | cut -f4 -d' '| cut -f3 -d'+'`
# get dimensions of $PROG window
WIDTH=`xwininfo -name "$PROG" | grep geometry | cut -f4 -d' '| cut -f1 -d'x'`
HEIGHT=`xwininfo -name "$PROG" | grep geometry | cut -f4 -d' '| cut -f2 -d'x' | cut -f1 -d'+'`
# get screen dimensions taken by $PROG
XPOSEND=$(($XPOS + $WIDTH))
YPOSEND=$(($YPOS + $HEIGHT))
# get current mouse position
CURX=`getcurpos | cut -f1 -d' '`
CURY=`getcurpos | cut -f2 -d' '`
#echo "$XPOS+$WIDTH=$XPOSEND, $YPOS+$HEIGHT=$YPOSEND, $CURX and $CURY"
# test if mouse cursor is inside $PROG
[ $CURX -gt $XPOS ] && [ $CURX -lt $XPOSEND ] && [ $CURY -gt $YPOS ] && [ $CURY -lt $YPOSEND ] && INSIDEPROG=true || INSIDEPROG=false
# do something here if $INSIDE_PROG is true
if [ "$INSIDEPROG" = true ];then
echo true
else
echo false
fi |
And I will do something like this (not real code, of course):
Code: | while [ 1 = 1 ];do
VAR=''
[ "$(mouse_click_detector)" = true ] && VAR=`myscript`
[ "$VAR" = true ] && dostuff || sleep 0.5
done |
_________________ Pkg, mdsh, Woofy, Akita, VLC-GTK, Search
|
Back to top
|
|
 |
sc0ttman

Joined: 16 Sep 2009 Posts: 2806 Location: UK
|
Posted: Sat 31 Dec 2011, 12:50 Post subject:
|
|
Mouse Events: http://myfreebsd.homeunix.net/freebsd/mouse_events_shell.html
Th above site seems to have to solved it,
but I'm too thick to apply (or even find) the relevant stuff..
EDIT:: The script seems to only register clicks in a terminal emulator window, not elsewhere, which is no good...
_________________ Pkg, mdsh, Woofy, Akita, VLC-GTK, Search
|
Back to top
|
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|