Results 1 to 5 of 5

Thread: assign a keyboard key to lock the mouse's button (start the "drag" in "drag&drop")

  1. #1
    Join Date
    Jun 2011
    Beans
    6

    Question assign a keyboard key to lock the mouse's button (start the "drag" in "drag&drop")

    Hi

    I have an injury in both my wrists in which I cannot "drag and drop" with the mouse. but it is very important to me to do so....

    for years I have been using an application in my windows desktop in which I can click a key on a keyboard (for example the "F8" key) that holds down the left mouse button for me, than I can "drag"
    using the mouse, and finally release the F8 key in order to "drop" (finish the "drag and drop")

    recently I installed Ubuntu 12.04 and need to be able to perform the same action.

    an example of something that does just that in 12.04 is by setting "pointer can be controlled by using the keypad" on:
    http://www.bbc.co.uk/accessibility/g...x/gnome/#setup

    than I use the "INS" key to "Lock Mouse Button":
    http://www.bbc.co.uk/accessibility/g...nome/#howtouse

    problem is, this disables the keypad as a keypad (the numbers on it, the "Enter" button, the plus key etc.) and I really want the keypad to work as a keypad.
    if only I could assign a different key to "Lock Mouse Button"... ?

    there is another option: my mouse has 6 button.
    if I could assign one of those buttons to start the drag and click it again to release it - that would be just as good.

  2. #2
    Join Date
    Oct 2008
    Beans
    3,509

    Re: assign a keyboard key to lock the mouse's button (start the "drag" in "drag&drop"

    This xdotool command will simulate holding down left mouse....
    Code:
    xdotool mousedown 1
    Bind this command to a keyboard shortcut or use easystroke to bind it to a spare mouse button....
    Code:
    sh -c "sleep 0.2 && xdotool mousedown 1"
    I describe HERE how to use easystroke.
    Just alter to use a command instead of key.
    You will need to install xdotool and easystroke.

    Whichever way you set it up, once activated you just need to press left mouse to release the dragged item.


    Another option would be use this script as a left mouse up/down toggle and bind to a single key like F8.
    Press your shortcut key once for left mouse down....press again to release.
    Use the full path to the script as the command.
    toggle-mouse1.sh
    Code:
    #!/bin/bash
    
    # script to toggle left mouse button up/down.
    # Initial run will create ~/.mouse-state.txt and will then toggle with subsequent runs.
    
    if [ "$(cat ~/.mouse-state.txt)" = "0" ]; then
       	sleep 0.2 && xdotool mousedown 1 && echo 1 > ~/.mouse-state.txt
    else
    	sleep 0.2 && xdotool mouseup 1 && echo 0 > ~/.mouse-state.txt
    fi
    Attached Images Attached Images
    Last edited by stinkeye; December 2nd, 2013 at 04:37 AM.

  3. #3
    Join Date
    Jun 2011
    Beans
    6

    Re: assign a keyboard key to lock the mouse's button (start the "drag" in "drag&drop"

    thank you. the xdotool solution worked perfectly for me.
    now I would like to do the same at work on which I have redhat installed.

    would this work on redhat as well ?

  4. #4
    Join Date
    Oct 2008
    Beans
    3,509

    Re: assign a keyboard key to lock the mouse's button (start the "drag" in "drag&drop"

    Quote Originally Posted by lamigam View Post
    thank you. the xdotool solution worked perfectly for me.
    now I would like to do the same at work on which I have redhat installed.

    would this work on redhat as well ?
    Don't see why not.
    Fedora should have an xdotool rpm.
    Last edited by stinkeye; December 3rd, 2013 at 02:13 PM.

  5. #5
    Join Date
    Jun 2011
    Beans
    6

    Re: assign a keyboard key to lock the mouse's button (start the "drag" in "drag&drop"

    thanks stinkeye.
    it works on redhat too.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •