Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: An Ubuntu analog of a basic Autohotkey script

  1. #1
    Join Date
    Oct 2019
    Beans
    6

    An Ubuntu analog of a basic Autohotkey script

    I spent a week worth of free time researching this simplest of questions, tried several approaches, asked Stack Exchange - all to no avail. The script is supposed to disable my broken mouse wheel and let me use the numpad for mouse scrolling:

    Code:
    WheelUp::return
    WheelDown::return
    $NumpadSub::Send {WheelUp}
    $NumpadAdd::Send {WheelDown}
    What I tried already:


    1. xbindkeys + xdotool. Mouse wheel blocking works but mouse wheel emulation does not: 'clicks' emulated by xdotool get blocked by xbindkeys too.
    2. xmodmap. All kinds of weird side effects. People say it is deprecated and should not be used.
    3. xinput. Does not work at all, supposedly because of a conflict with libevent. Removing the latter disabled my keyboard and mouse completely.
    4. Took a look at xkb but could not find any actionable documentation.


    Ubuntu 18.04.3. Any suggestions?

  2. #2
    Join Date
    Dec 2014
    Beans
    1,215

    Re: An Ubuntu analog of a basic Autohotkey script

    Finding the name for the mouse with xinput
    Code:
    xinput -list
    Killing the scrollwheel-function using the name found in the previous step (could use the numerical id, but that's subject to change on boot so it's not so good for use in scripts;obviously the name will be different on your machine)
    Code:
    xinput --set-button-map "Logitech USB-PS/2 Optical Mouse" 1 2 3 0 0
    Using xdotool to scroll up and down
    Code:
    xdotool click 4; xdotool click 5
    Works fine as far as that. Now just assign those two commands to the keys in your "~/.xbindkeysrc"
    Code:
    ...
    "xdotool click 4"
      KP_Subtract
    
    "xdotool click 5"
      KP_Add
    ...
    Seems to work for me on XUbuntu 18.4.3 ...

    Holger

  3. #3
    Join Date
    Oct 2019
    Beans
    6

    Re: An Ubuntu analog of a basic Autohotkey script

    Sadly, the xinput part does not work for me. The sequence below blocks mouse wheel in Firefox and Double Commander but not in Chromium or Gnome terminal.

    Code:
    $ xinput --list
    ⎡ Virtual core pointer                        id=2    [master pointer  (3)]
    ⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
    ⎜   ↳ VirtualBox mouse integration                id=9    [slave  pointer  (2)]
    ⎜   ↳ ImExPS/2 Generic Explorer Mouse             id=11    [slave  pointer  (2)]
    ⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
        ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
        ↳ Power Button                                id=6    [slave  keyboard (3)]
        ↳ Sleep Button                                id=7    [slave  keyboard (3)]
        ↳ Video Bus                                   id=8    [slave  keyboard (3)]
        ↳ AT Translated Set 2 keyboard                id=10    [slave  keyboard (3)]
    $ xinput --set-button-map "ImExPS/2 Generic Explorer Mouse" 1 2 3 0 0 6 7 8
    Last edited by zorath2; 1 Week Ago at 08:12 PM.

  4. #4
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: An Ubuntu analog of a basic Autohotkey script

    I use Actiona quite often for emulation and automation of workflows.

    I have not tried the wheel action in the library of objects but it is described here.

    Actiona is an alternative to autohotkey.

    P.S. the script can be run without GUI by command

    actexec myscript.ascr
    Last edited by dragonfly41; 1 Week Ago at 08:32 PM.

  5. #5
    Join Date
    Oct 2019
    Beans
    6

    Re: An Ubuntu analog of a basic Autohotkey script

    dragonfly41, could you please provide something like a complete script with a trigger? Because I tried all these tools in every combination imaginable and they always do one of the two things:


    1. Refuse to block the physical mouse wheel outright.
    2. Block the synthesized mouse wheel events along with the physical ones.


    There is no middle ground like Autohotkey has.

  6. #6
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: An Ubuntu analog of a basic Autohotkey script

    Actiona emulates actions and does not react to external events. For that you need to look at devilspie2 or Autokey
    which can use defined rules to trigger scripts such as Actiona or xdotool or bash.
    Last edited by dragonfly41; 1 Week Ago at 09:36 PM. Reason: added Autokey

  7. #7
    Join Date
    Oct 2019
    Beans
    6

    Re: An Ubuntu analog of a basic Autohotkey script

    Unfortunately, devilspie2 does not seem to be relevant either.

  8. #8
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: An Ubuntu analog of a basic Autohotkey script

    Found this ..

    https://askubuntu.com/questions/8742...pressing-a-key

    This needs to be run in two steps

    Detect hot keys to launch a script

    System Settings > Keyboard > Shortcuts > Custom shortcuts
    Create a new shortcut for mousewheel up
    Create a new shortcut for mousewheel down

    Now create a script for each action.

    I have tried
    Super+Up -> mouse wheel up
    and
    Super+Down -> mouse wheel down

    Note: your screen might freeze while setting accelerator keys for each new shortcut. This happened to me.
    Just hit backspace to clear freeze.
    Last edited by dragonfly41; 1 Week Ago at 10:58 PM. Reason: note on possible freeze during key setting

  9. #9
    Join Date
    Oct 2019
    Beans
    6

    Re: An Ubuntu analog of a basic Autohotkey script

    Emulating the mouse wheel is not a problem. The difficulty lies in blocking the physical mouse wheel at the same time.

  10. #10
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: An Ubuntu analog of a basic Autohotkey script

    disable mouse up and down

    I would try that.

Page 1 of 2 12 LastLast

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
  •