MACRO: Sort Macros Conditionally, v3.0
Download: Sort Macros Conditionally.kmmacros (53 KB)
Documentation
PURPOSE
When this macro is triggered, the macros in the selected Macro Group or Smart Group will be conditionally sorted. The conditions, based on the name of the group, can be optionally adjusted using settings for Date Created, Date Modified, Date Used, Size, and/or Trigger. If none of the configured conditions are met, the macros will be sorted by Name.
If the hot key trigger includes the Option and Shift keys (⌥⇧), or if ⌥ and ⇧ are down when the macro is triggered, the View>Sort Macros by>Disabled to Bottom menu item will be selected if it is not already checked. Conversely, without the ⌥⇧ modifiers, View>Sort Macros by>Disabled to Bottom will be deselected if it is checked.
SETTINGS
The conditional sorting can be adjusted by changing the values for five macro settings. Note that these values should be configured using regex patterns. Match checks within the macro are case insensitive.
The default values for the five settings as follows:
local_SortByCreated
create
local_SortByModified
modif[iy]|date
local_SortByUsed
use|execute|run
local_SortBySize
size|large|big
local_SortByTrigger
trigger|hot\s?key
RELATED MACRO
This macro is designed to intelligently change the View>Macros Sort by selection; it will remain this value until:
• this macro is run again, or
• the Keyboard Maestro editor menu value is manually changed.
For conditional sorting that occurs continuously, see Toggle Smart Sort.
TESTED WITH
• Keyboard Maestro 11.0.3
• Sequoia 15.3 (24D60)/MacBookPro18,2
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445
VERSION HISTORY
1.0 initial version
1.1
When ⌥⇧ is used for Disabled to Bottom:
a) changed toggle to set, and
b) added a low volume sound (Funk) when it is checked.
2.0
a) Changed method to detect the Group name (from using %WindowName%1% to AppleScript). This enables the macro to function as expected if a group is selected, even if it is not focused.
b) Changed ⌥⇧ logic: if selected, mark Disabled to Bottom; if not selected, unmark Disabled to Bottom.
c) Removed low volume sound (Funk).
3.0
a) Regex pattern checks are now case insensitive.
b) Moved documentation from a header comment to the Keyboard Maestro forum. This has two advantages: i) reduces the size of the macro, and ii) streamlines maintenance of the macro.
c) For conditional steps that contain simple conditions, converted If Then Else actions to Switch/Case actions. When it can be used, the latter action has two advantages: i) it occupies less vertical space in the KM editor, and ii) if the logic does not have a false branch, then the action can be configured to have only a true section.