Continuing the discussion from
KM8: A Few Miscellaneous Bugs:
I’ve been wondering about this since launch, but have no impressive examples myself. I’ve been able to drop macros like
[KM] Put Selected Actions into Group Action in favor of the new Engroup feature, etc., but I’d like to see what improvements y’all have made.
I don't have any macros to post yet, but here are a few of the new features that I find very helpful:
These greatly simplify macros where you want to support both Safari and Chrome
These will help insure that variables are used/set only where they are intended to be used, and to greatly reduce the variable clutter caused by Global Variables.
I expect to rewrite many of my macros using these.
However, I'm waiting for the new prefix character to be established, and I also hope that two underscores will be supported in addition to a space in the prefixes, as in "Local__" and "Instance__"
The New "Always Activated and ..." Option for Macro Groups:
This is really huge, and makes use of Palettes, IMO, much much more powerful.
We can now have BOTH:
Individual Macros always active and can be triggered any time
Show a Palette for the same Macro group when we need it.
(Note to @peternlewis: is this new feature documented anywhere in the Wiki? I couldn't find it.)
And I am sure there will be many more. That's all for now.
All right, here's the best (read: only, at least for now) example I have to share. Background: a few months ago,
I made a thread asking for help with a date converter macro, which in turn led to this thread where Peter teased an upcoming KM8 improvement that promised to make this surprisingly tricky task considerably simpler. Now that KM8 is here, I was finally able to take a crack at streamlining it and seeing how much simpler I could make it (spoiler: quite a lot simpler).
To illustrate, here's the original, KM7 macro:
And here's the newly KM8-optimized macro:
(download for anyone interested)
KM8-Optimized JP Dates → US Dates.kmmacros (5.7 KB)
To put that in number form, the original macro used 25 actions and 4 variables altogether, and the KM8-optimized one uses 9 actions and
zero variables. The new version achieves this entirely thanks to KM8's ability to use regex matches and capture groups in tandem with the %Calculate% token, especially the new %CalculateFormat% token (without which the date conversions couldn't be formatted properly). These new abilities also completely eliminate the need for the original's
For Each loops and variable "placeholders" (which were used in the original version to ensure that only one matching pattern at a time was used for calculation and replacing) as the necessary calculations can now be searched, done in-place, and written back en-masse.
I doubt this particular macro will be very useful for anyone who doesn't regularly work with Japanese dates, but hopefully this helps show what KM8 makes possible
Not that it matters, but I think this was already possible with KM7. IIRC.
It seems my “IIRC” was wrong. Can’t make it work with KM7. Must have mixed it up with some other thing.
And, before you ask: Yes, I still have one Mac with KM7 running. Shame one me. But the sole purpose of that KM7 Mac is to verify whether something I perceive as
new with KM8 really is new. Or vice versa
Here is an example of mine how I used the new KM8 features in a macro:
Macros for Retina Screenshots on the Forum
The macros are exclusively using local and instance variables
Since some of the macros are executing another macro, it may serve as a demo where to use instance variables and where to use local variables.
One of the macros also uses a Calculation token in a regex replacement (apparently without me knowing that this didn’t work before ;))
The new operators of the If…Then action (for example “<=”) are used.
Version 7 would process the tokens of the replacement, but only once before the search & replace started.
Version 8 processes the token for each replace, allowing you to use the results of the match as part of the replacement, changing the replacement each time.
I've been toying with KM8's AppleScript support and kludged together these two scripts to 1) backup and rename macros before tinkering with them and 2) revert to the original name when I'm ready to go back. I'm a novice with AppleScript so there are definitely cleaner ways, but here's a start:
1. [BU] Backup, Duplicate, and Disable Selected Macros Before Tinkering
Keyboard Maestro 8
Smile companion osax
As @JMichaelTX always says:
Carefully review the Release Notes and the Ma…
I wrote two small macros utilizing KM8’s scripting support.
Bulk Prepend/Append Macro Names
Requires: Keyboard Maestro 8
Note: No check for prefixes/suffixes that are just spaces, etc.. Whatever you type will be added to the name.
Bulk Prepend:Append Macro Names.kmmacros (31.3 KB)
One more small improvement.
Now as you’re mentioning it, I also wrote one with KM8’s new AppleScript classes:
This is a variant on
@peternlewis's Create Text Expansion From Selection macro.
What it does
It creates a new text expansion macro from selected text (as plain text).
The macro runs only with KM 8 or newer.
In any application, select the text you want to create an abbreviation for.
Launch the macro via hotkey
Enter the abbreviation in the user prompt.You'll see the abbreviation field pre-populated with a semicolon ;. This is the default abbreviation prefix and you can change it…
Was able to drastically pare down and improve a macro I came up with a few months ago for searching text files and displaying results thanks to Prompt With List:
Thanks to KM8’s new Prompt With List action, this whole macro has essentially been made obsolete in the best way possible. I’ve been able to pare it down from this: [image] to a single action: [image] There is a downside in that this version doesn’t support searching with regular expressions, but it more than makes up for that by being able to see and filter results instantly, and by being able to copy them to the clipboard with a single press of the Enter key (not to mention drastically sim…
Still haven‘t tried the List Prompt. Thanks for the reminder.