You are not logged in.
I was looking for a way to emulate a mouse button press, so that holding down a key or keyboard combination will send a DOWN mousebutton event, and then releasing the key will send a RELEASE event (at the position of the mouse pointer).
Does anyone know how to do this?
I wanted to bind such a thing to WIN+1 or some such combination.
(I use a graphics tablet for my work and this would be quite useful)
maybe there is some idea here:
http://hocwp.free.fr/xbindkeys/double_click.sh.txt
Offline
or maybe it could just toggle the state (UP or DOWN) using the same key combination. that would be good as well.
there is this package in AUR called click, but it sends BOTH down and up events.
Offline
having a look at the source for click, it actually has a feature to do mouse press / mouse release
"click 3 1" presses mouse button 3
"click 3 2" releases mouse button 3
"click 3" presses and releases button 3
Offline
I see. It didnt occur to me, I assumed I wouldnt understand the source code (I am not programmer, although I have rudimentary understanding of the concepts).
But if I wanted to toggle the state with just one key, I guess I would have to save its current state somewhere (a text file, maybe?). How could I do that?
#click.c
/* gcc -g -Wall -o click click.c -L /usr/X11R6/lib/ -lX11 -lXtst */
#include <X11>
#include <X11>
#include <stdio>
#include <stdlib>
int main( int argc, char *argv[] ) {
Display *dpy = XOpenDisplay( NULL );
int butnum;
int click;
butnum=1;
click=0;
if (argc > 2) {
butnum = atoi(argv[1]);
click = atoi(argv[2]);
} else if (argc > 1) {
butnum = atoi(argv[1]);
}
if ((click == 0) || (click == 1)) {
printf ("Faking button %d downn", butnum);
XTestFakeButtonEvent( dpy, butnum, True, CurrentTime );
}
if ((click == 0) || (click == 2)) {
printf ("Faking button %d upn", butnum);
XTestFakeButtonEvent( dpy, butnum, False, CurrentTime );
}
XCloseDisplay( dpy );
return 0;
}
Offline
oh, this gets complicated because I would want the saved state to revert if a real mouse button was clicked, or if I log off. It should also probably be saved in main memory..
Offline