I have moved to Apple Calendar from Google Calendar. The main thing I miss is the ability to switch views using "d" Day, "w" Week, etc. I know I can use Apple-n etc but the muscle memory is strong for the google shortscuts.
In my attempt to use keyboard maestro to add the google shortcuts to apple calendar, I have run into the problem that if I create a entry as soon as I press for example "w" it switches view. Here is my attempt.
As a first time user, I want you to feel welcome here asking questions. So, welcome.
I drafted a reply but I see Nige is replying at the same time as me, and his answers are always twice as good as mine, so I'll let him handle this one.
The problem is that "unmodified letter" shortcuts are an app or web app thing -- they can tell if you are in an active text-entry context and behave accordingly, Keyboard Maestro can't with total reliability.
You might be able to get away with a menu item check as a proxy for "am I in a text field?" -- the most likely in this case is whether or not "Edit" -> "Select All" is available. Give these a go and see!
Nuts -- "Month" is the one view where "Select All" is an available choice in the Edit menu... Time to go searching again.
I don't use Calendar much, so you'll probably find something usable quicker than me. Want you are looking for is a menu item that is either always available when you want to be able to type the "D", "W", "M" and "Y" characters and have them interpreted as normal text, or is never available in that situation (you could even use a combination of menu items).
Looking at it, the "Edit" menu's "Start Dictation" might be a suitable candidate -- I think you can only dictate when a text field is active. Just change the "If" action's text from "Select All" to "Start Dictation" and see if that's any better.
If that does work we can look at the next step -- combining all four macros into one... That'll introduce a couple of useful concepts. Or you can leave them as individual macros if you're happier.
Yes, as @Airy has just said, this is great. It is much more robust than the old "Select All" method to determine if the cursor is in a text field. It seems that "Edit>Start Dictation" is available in just about every App on the Mac and is only active in text fields ("Select All" is sometimes available when not in a text field).
This discovery might make using single letter hot keys in KM a lot more viable... I have always avoided single letter key hot keys before, even though potentially they are so nice to use.
Is "Edit>Start Dictation" a relatively new menu item?
Good point. I just tried it in Keyboard Maestro and it worked for hot keys in Keyboard Maestro itself. I have βvβ to toggle Actions or Macros enabled status and it seems to work.
Actually, in testing this doesn't seem to be the case. It is enabled if in a text field only (which is a lot of the time in Safari) but if not in a text field it is disabled like in the other Apps.
@LtGimlet If you can live with short/long press, you avoid the problem of KM not knowing which field the cursor is in. Although the menu idea is ingenious.
In any case, if you tap βdβ, βwβ or whatever letter you want, briefly (normally), the letter is typed. If you hold the key a little longer, the view changes.
This is not perfect either. If some letters are typed when the key is released and others when the key is pressed, problems arise when typing quickly. But only then. And maybe you don't write that fast.
OK -- I can see what's going on. If you've never enabled Dictation the menu item is always available in Safari (and maybe other apps). After you've enabled Dictation for the first time and gone through the Privacy prompts, etc the menu item will behave as you describe.
I'm back a good few versions of macOS so I don't know what may have changed, but here in Mojave the Edit > Duplicate command is only enabled when there's also a text field in use.
If you changed to using β1 etc to switch views -- instead of trying to use the Google Calendar shortcuts you're used to -- that would certainly solve the problem! No macros needed...
The problem isn't in the macro, it's with the way you want to trigger it. Unmodified hot key triggers can be difficult because there's no global, certain, method of determining if a text input widget is currently active.
Hot key triggers are "swallowed" by Keyboard Maestro and never reach the frontmost application. So while you can use D, W, M and Y as triggers, as soon as you try to make an event to Walk the dogs with Mandy it'll actually come out as alk the ogs ith and.
All it's doing is trying to determine if a text input area is currently active, using the presence/absence of a menu item as an indicator of such -- the start of the "If" action. There's two possible results:
If it thinks you are trying to input text it types the keystroke for you -- that works because KM doesn't consider its own typing to be potential triggers.
If it thinks you aren't in an input area then you must be trying to change views, so it selects the appropriate menu item