You are not logged in.

#1 2006-07-21 07:14:02

Galdona
Member
Registered: 2006-03-15
Posts: 196

a way to emulate mouse-button-down (and not release it)

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

#2 2006-07-21 07:31:15

Galdona
Member
Registered: 2006-03-15
Posts: 196

Re: a way to emulate mouse-button-down (and not release it)

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

#3 2006-07-21 08:16:01

paranoos
Member
From: thornhill.on.ca
Registered: 2004-07-22
Posts: 442

Re: a way to emulate mouse-button-down (and not release it)

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

#4 2006-07-21 13:13:10

Galdona
Member
Registered: 2006-03-15
Posts: 196

Re: a way to emulate mouse-button-down (and not release it)

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

#5 2006-07-21 13:17:17

Galdona
Member
Registered: 2006-03-15
Posts: 196

Re: a way to emulate mouse-button-down (and not release it)

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

Board footer

Powered by FluxBB