Announcement

Collapse
No announcement yet.

How to assign a keyboard macro (and save a lot of typing)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to assign a keyboard macro (and save a lot of typing)

    I think some of you use various flavours of Linux and even if you use Microsoft Windows there may be an equivalent way to do this there too.

    I have a Microsoft Natural Keyboard 4000 and it has a bunch of extra keys across the top, some of which don't do anything in particular.

    So it occurred to me that I would a lot of typing when filling out forms if I could assign one of those keys to type my email address into a field.


    Create this script, save it somewhere and make it executable.
    #!/bin/bash
    TEXT="example@example.com"
    xdotool sleep 0.5 type $TEXT

    Note: It needs the sleep parameter in there or you only get the last half of the email address typed when you press the hotkey.

    Then system-preferences-hardware-keyboard shortcuts
    Create new shortcut
    Point to that script
    Press the key you want to call it from.

    Done.​

    If you're using Wayland instead of X, you can accomplish the same thing using the ydotool command instead of xdotool.

    (This should work on Wayland but I don't have anything to test it on.)

    #!/bin/bash
    ydotool type --delay 1000 --key-delay 70 "example@example.com"

    Google tells me that there are some xdotool equivalents for Windows too.

    So now the next time I'm filling out a form and it asks for my email address I can just hit one of those do-nothing keys on the top of my keyboard. I've got more of them too, so I suppose I could add my phone number or name to one of them as well.

    The joy of automation.


  • #2
    For when you run out of macro keys, be careful with this rabbit hole:
    https://attackshark.com/blogs/news/c...we2ZXRbKVKIu1P

    Comment


    • #3
      Linux (or at least the Mate desktop, which is what I use) has a keyboard configuration screen that lets you do quite a few things to fine tune your keyboard.

      One of the things I've changed is to swap the caps lock and left ctrl key. I use the vim text editor and having the ctrl key handy (on caps lock) is a lot better than having it at the bottom of the keyboard.

      I've also created a custom do-nothing macro (that just runs the true command, which does nothing successfully) and assigned it to the right menu key since I always hit that one by mistake and ghawd-knows-what pops up whenever I do that. Now, it's effectively a dead key and I like it that way.

      The idea for assigning my email address to one of those unassigned keys at the top came to me a few days ago but it took a while to figure out how it could be done.

      Comment


      • #4
        Well, that's neat. I've always sort of wanted a 122-key 3270 terminal keyboard, but never had a use case for it under Linux (or Windows, for that matter). I might have to get one now. I have used xmodmap to swap ctrl and caps lock in the past, but I type on so many different keyboards in different places that I don't want to have to remember where I have made that change and where I haven't.

        Comment

        Working...
        X