Author Topic: How to emulate the mouse mid-click with a keystroke?  (Read 2326 times)

Snap

  • Posts: 490
    • View Profile
How to emulate the mouse mid-click with a keystroke?
« on: September 22, 2015, 06:58:33 AM »
I got a nice Logitech M600 mouse. Kinda pad meets a mouse. Great for aleviating hand straining. Lovely in that respect but it has no mid button. I want to use a keystroke to replace that missing button. All the guides I've found start by finding the code for that mid click with xev or whatever... but i don't have that button to beggin with. Any ideas?

hakerdefo

  • Posts: 525
    • View Profile
    • Looking at Linux through the Windows of Life
You Can't Always Git What You Want

misko_2083

  • Posts: 70
    • View Profile
Re: How to emulate the mouse mid-click with a keystroke?
« Reply #2 on: September 23, 2015, 05:10:04 PM »
You could bind some key or key combination with
Code: [Select]
xdotool click 2Need to install Xbindkeys
Code: [Select]
sudo apt-get install xbindkeysNow create a sample file
Code: [Select]
xbindkeys -d > ~/.xbindkeysrcThere are some good examples in that file
Edit the file
Code: [Select]
medit ~/.xbindkeysrcadd next
Code: [Select]
"xdotool click 2"
   F12
Start xbindkeys
Code: [Select]
xbindkeys &Now test with F12

You can set some other key or key combo.
Code: [Select]
xbindkeys -kA blank window will pop up. Press the key(s) to which you wish to assign a command and xbindkeys will output a handy snippet that can be entered into ~/.xbindkeysrc
Then edit the ~/.xbindkeysrc accordingly.
Now restart the xbinkeys daemon.
Code: [Select]
killall xbindkeys
xbindkeys -f ~/.xbindkeysrc

in case it doesn't work use -n to see why
Code: [Select]
xbindkeys -n
Remember to add "xbindkeys &" to your autostart.sh so it always runs when you start up.

You can also assign scroll up and down.
Code: [Select]
xdotool click 4
Code: [Select]
xdotool click 5Scrolls just a bit but you could add a few clicks in the command
Code: [Select]
xdotool click 4 click 4 click 4 click4

Snap

  • Posts: 490
    • View Profile
Re: How to emulate the mouse mid-click with a keystroke?
« Reply #3 on: September 23, 2015, 06:26:18 PM »
Thanks, guys. I was trying xbindkeys without success. For some reason it doesn't work. I was using xte instead of xdotool

Code: [Select]
#Fake mid-click
"xte 'mouseclick 2'"
    m:0x5 + c:94
    Control+Shift + less

Gotta try xdotool instead, but it seems xbindkeys is not working. I've tried other things to test it and none worked.

@hackerdefo. The dependencies seem a lot at first instance, but checked it and only pulls two extra libs to the party. The rest are already in. So good to go. You know, I try to keep my system small and clean. Not for the size/bloat itself. I've learned (specially from Vsido) that simple systems have less chances to break, and if they break they are easier to fix.

Snap

  • Posts: 490
    • View Profile
Re: How to emulate the mouse mid-click with a keystroke?
« Reply #4 on: September 23, 2015, 07:54:55 PM »
Yup, not working.
Code: [Select]
xbindkeys -n

*** Warning ***
Please verify that there is not another program running
which captures one of the keys captured by xbindkeys.
It seems that there is a conflict, and xbindkeys can't
grab all the keys defined in its configuration file.

Need to find out the conflict. No idea of what it can be.

Tried gpointing-device-settings too... don't want that sucker.

misko_2083

  • Posts: 70
    • View Profile
Re: How to emulate the mouse mid-click with a keystroke?
« Reply #5 on: September 23, 2015, 09:11:14 PM »
Yup, not working.
Code: [Select]
xbindkeys -n

*** Warning ***
Please verify that there is not another program running
which captures one of the keys captured by xbindkeys.
It seems that there is a conflict, and xbindkeys can't
grab all the keys defined in its configuration file.

Need to find out the conflict. No idea of what it can be.
Try some other key combo.
Setting F12 works for me.