Controlling Which Macros Are Fired When Tapping Once, Twice, Thrice, or Four Times

No problem. Hope your gig goes well!

Ahhh --Thank you @DanThomas ,

think I got it ... maybe I was completely wrong today ... I'm sorry I misunderstood the template.... have read a lot of stuff the last days..... but i think it goes to @JMichaelTX 's Long Key Press - Template Macro what i've written here...

Hello @DanThomas, @JMichaelTX, @ccstone, @Nr.5-need_input,

I couldn't help myself, I had to take a break and try this.

It worked!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Hot damn, it worked.

I have no idea how its passing variables, or how the semaphore works, but I'll take it apart soon and try to understand it.

@DanThomas, was I right you built this before tapping multiple times was built it? I just have to leave it in tap once. It's just as fast as the built in multi-tapping. Not to get greedy, but do you also have something that cycles through actions after each keystroke instead of waiting for keystrokes?

@ccstone, I'm sure I just have to look harder, but it was your last addition at the bottom that allowed me to see were my actions go.

With consistent ordering of modifiers and tapping I can have one key on a 128 button xKeys launch every version of a GUI configurations for a particular operation like Curves. 21 "buttons" down to 1. Using that same ordering for other actions, muscle memory will be a snap for so many functions.

Thanks to all!!!!!!!!!!!

1 Like

Sounds just like me.

Awesome! And yes, this was way before multi-tapping was added - I didn't even know Peter added that feature.

There's comments throughout the macro that may help.

The concepts involved in this macro are difficult to understand, so if you don't "get it", don't feel bad - they're advanced programming concepts. But here's the gist:

  1. One macro can actually be running multiple instances at the same time. In other words, if a macro is launched by a hot key, and it doesn't finish running before the hot key is pressed again, then a second instance of the macro starts running simultaneously.

    This is a tricky thing to wrap your head around, so you may have to think on it for a while. I suspect some people may never be able to understand this - like I said, it's an advanced-level programming concept.

  2. But if you do understand #1, here's the really mind-blowing part: If one instance of the macro makes changes to a global variable, that change affects the other instance.

    This can cause some really strange things to happen. For example, if you were using a global variable to count the number of times you were going through a loop, and another instance starts running, the counter could get severely confused.

    That's actually why Peter implemented Local and Instance variables. If a second instance of the macro sets a Local or Instance variable, it only affects that instance.

This is all really confusing, I know, and you don't really need to understand it to use the template. If, however, you do manage to wrap your mind around this, then you may have other questions, so feel free to ask. :smile:

Nyet.

There's a discussion with Peter about the multi-tap-trigger several months, before @DanThomas posted the macro.

-Chris

Hey Guys

Again - I'm sorry for yesterdays post...

I have a question for using this template - @DanThomas , @JMichaelTX or @ccstone

Is it possible using this Template to set up for neither detecting in normal mode or for holding down the key ?

I am asking because I have set up my key as a Hyper-Key with Karabiner Elements....

If there is a way to accomplish this – how do I have to do that ??

My Idea looks like this 

Hyper-Key
     Tapped 1x ---> EveryDay Favorite 1 
     Tapped 2x ---> EveryDay Favorite 2
     Tapped 3x ---> EveryDay Favorite 3

Normal use 
     Tapped 1x ---> Once a Week 1 
     Tapped 2x ---> Once a Week 2
     Tapped 3x ---> Once a Week 3

This maybe will be a great feature - NOT ONLY FOR ME – I think many others who use the key as a Hyper-Key will be glad if ther is a way to do this ...

Many Thanks

Greetings from Germany

I don't really understand what you're asking. What does Hyper-Key have do do with it - I thought Hyper-Key just turned something like your shift key into another keystroke?

Hello @DanThomas ,

Sure it can be something like that.... but in my case is not SHIFT the Hyper-Key - it's my CAPSLOCK.

So I can use my CAPSLOCK with one Finger for all 4 Modifiers .... I want to have a Macro Routine running when I press Hyper + A which is different to A

... Is that doable with your Template ??? - or is there something I am missing??

Hey Tobias,

Some people on the forum are using a hyper-key, but I don't and nor do Dan or JM.
So we can't tell you if it will work or not.

Why don' t you just test it out and see?

Then report back.

-Chris

My template is just a standard macro. It triggers like any other macro. So it's up to you to figure out how to trigger it.

Thank you @ccstone , @DanThomas ...

do you guys maybe know someone here who is using Karabiner Elements's Hyper-Key feature ??

that would be great....

I will of course reach out to the Automators Forum and MacPowerUsers .... maybe there are some guys who can help me out ..

but I will also try it by my self - finding out how that will work ...

Greetings from Germany

~ Tobias

I use Karabiner Elements and the Hyperkey mod. but if you are asking if it is possible to trigger a KM macro by pressing the hyper key alone (that's the normal caps-lock key) or just the combination of ⌃⌥⇧⌘ then I think you're out of luck.

This is where you specify the macro trigger in KM:
KM 0 2021-02-10_16-04-39

You can see there is no possibility to choose the caps-lock key from the pick list and just pressing caps-lock or the ⌃⌥⇧⌘ combination does not register with KM.

If I have misunderstood what you are trying to achieve then I apologise! Put me straight, if you will!

EDIT:

If you specify the trigger to be from a USB Device Key, then you can get it to recognise the Control, Option, Command keys like this:

But if you press the Hyper key all you get is "Try Again" like this:

Hello @tiffle ,

thank you for your reply .. I've Installed the Rule for the Hyper-Key which I found a long long time ago in the shared-page for Karabiner/Karabiner-Elements - don't know the site name now.... I wanted a quick solution for Shortcuts like ⇧⌃⌥⌘ + A , ⇧⌃⌥⌘ + S , ⇧⌃⌥⌘ + X or ⇧⌃⌥⌘ + Y for just triggering with one Hand (using QWERTZ-Layout).

The rule does nothing more than "Do Nothing if Capslock pressed alone and if there is another key it will change that Key to + the pressed Key...."

maybe there is a way to change the rule ? maybe adding an exec written in shell to run a "Helper Macro" which activates the Macro I want to run ?

Yes, I just looked at Karabiner-Elements preferences and you can change the rule.

I changed mine to the following:

and sure enough, when caps-lock is pressed on its own it generates the escape key.

To change the rule, click on the Add Rule button at the bottom of this window and select the rule you want in the following window, shown here:

This will now let you trigger this multi-tap macro by pressing the hyper key on its own.

Must go - there's a COVID-19 briefing...

Good luck!

2 Likes

thanks @tiffle ,

sounds great I will give it a try the next days... I'll come back if I stuck on it

Greetings from Germany

hello @tiffle ,

have found the Rules JSON Code - in my case it is yet a File with digits in it's name

the Path to the corresponding Rule:

~/.config/karabiner/assets/complex_modifications/1595689590.json

I think I should give them real names or build a search Macro some days to find that file :joy::joy::joy::joy:

Here are the first 35 lines of this JSON Code


{
  "title": "Change caps_lock key (rev 4)",
  "rules": [
    {
      "description": "Change caps_lock key to command+control+option+shift if pressed with other keys",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "caps_lock",
            "modifiers": {
              "optional": [
                "any"
              ]
            }
          },
          "to": [
            {
              "key_code": "left_shift",
              "modifiers": [
                "left_command",
                "left_control",
                "left_option"
              ]
            }
          ],
          "to_if_alone": [
            {
              "hold_down_milliseconds": 100,
              "key_code": "caps_lock"
            }
          ]
        }
      ]
    },

That is the Option of the CapsLock Rule I changed it to on my MacBook Pro
What I can read here is that I can use any Key with it to get all 4 Modifiers and if I press and hold it alone for at least 0.1 seconds I'll get the regular CapsLock behaviour. - maybe will change the "hold" to something like press 3 times

but that is not the thing .... This Rule will maybe work as expected if I only use the CapsLock Key with any other Key

so to follow my Idea from Post #16 which was this:

My Idea looks like this 

Hyper-Key
     Tapped 1x ---> EveryDay Favorite 1 
     Tapped 2x ---> EveryDay Favorite 2
     Tapped 3x ---> EveryDay Favorite 3

Normal use 
     Tapped 1x ---> Once a Week 1 
     Tapped 2x ---> Once a Week 2
     Tapped 3x ---> Once a Week 3

seems only possible to me with two Binding Setups and an option to change between them like

press CapsLock twice while holding right Shift Key  (It should not be easy to switch)

* runs Macro with Global Variable and is checking for SetupName 

   * If SetupName = Setup 1 ---> activate Macros for Setup 1, deactivates Macros for 
      Setup 2, change Variable 
    
   * If SetupName = Setup 2 ---> activate Macros for Setup 2, deactivates Macros for 
      Setup 1, change Variable
     

but seems that is not the only thing - sure - I have to add this rule in both Setups

In the second Setup there should not be the Hyper-Key but at least the Press 3 times to envoke the CapsLock behaviour.
This will make it possible to have a "normal 4Modifier HotKey " and a "Hyper-Key one"

how can I set up the JSON for CapsLock with Holding any Key? is this even Possible ? - It would be great .. this will make it possible to use @JMichaelTX 's Hold A Key Template Macro the same way....

Greetings from Germany

~ Tobias

Hi @Nr.5-need_input.

I'm afraid configuring Karabiner-Elements is not something I can help you with any further - perhaps ask in their support forum?

Stay safe!

thanks for your help anyway @tiffle ,

Maybe you can't help me withconfiguring the JSON - but It wa YOU who remembered me that there were more Options than just one in the RuleSet !!

Thank you for that !!!

Since you did that Yesterday is was more than absolutely nothing :+1: :pray:

have found an article a few minutes ago called Karabiner God Mode from @nikivi who is also on this forum ... meybe he can help me with that ...

Stay safe, too

Greetings from Germany

~Tobias

1 Like

Hello @nikivi ,

since you've written about Karabiner / Karabiner-Elements maybe you could help me out with my Problem.

Maybe yo read this thread from the beginning to get a little bit background

it would be great if you can help me out

Thank you

Greetings from Germany

~Tobias

@DanThomas, @JMichaelTX, @ccstone

I can't thank you guys enough for this help. I think this macro is built into over 160 keys now.

Is there a time when you have too many macros and that slows the system down? How does it work with grabbing mouse position for example. That seems always live. So if I have a 160 actions always reading the mouse position does that slow things down eventually?

1 Like