Macros I Use All the Time

Oh man, I knew EBCDIC before I knew ASCII!

2 Likes

Tried to have a variable on the Current Clipboard.

Where is/ are the mistake(s)? Of course it shouldn't be "to plain text".

Why are there 3 %%% ?

/okn

I recently had built this for myself using applescript and pulling the macro list from specific folders I want to generate a list to filter/choose from. So this might accomplish more of what you want.

It does give a list of the macros by default this way without needing to type.

You can list as many folders as you want in the within the 'set macroGroupName' area.

tell application "Keyboard Maestro"
	-- List of macro group names
	set macroGroupNames to {"GROUP1", "GROUP2"}
	
	-- Create the lists
	set macroNames to ""
	set nameToUUID to ""
	
	-- Loop through each macro group
	repeat with macroGroupName in macroGroupNames
		set macroGroup to macro group macroGroupName
		set macroList to macros of macroGroup
		
		-- Loop through each macro in the group
		repeat with aMacro in macroList
			set macroName to name of aMacro
			set macroID to id of aMacro
			set macroNames to macroNames & macroName & linefeed
			set nameToUUID to nameToUUID & macroName & "||" & macroID & linefeed
		end repeat
	end repeat
	
	-- Trim the trailing newline
	if length of macroNames > 0 then
		set macroNames to text 1 thru -2 of macroNames
	end if
	if length of nameToUUID > 0 then
		set nameToUUID to text 1 thru -2 of nameToUUID
	end if
	
	-- Set the Keyboard Maestro variables
	tell application "Keyboard Maestro Engine"
		setvariable "MacroNames" to macroNames
		setvariable "NameToUUID" to nameToUUID
	end tell
end tell

Custom Macro Menu from Group.kmmacros (5.1 KB)

1 Like

Thank you, very interesting. For me, that method has pros and cons compared to using the conflict palette, which I shall weigh up carefully... It's certainly a convincing option.

1 Like

What's the search string for the app-specific group here? Does its contents somehow change based on the front app, or are you just making a group for a specific app like Logic?

I find it a shame you need to press → to type without deleting the initial string. I wish that was an option.

If you always want to append, rather than overtype -- write a "Keystroke: " macro that has a 0.1s pause before typing , then call that macro asynchronously just before you pop the search:

...and:

Thanks! It's a little hacky but it will do in the meantime…

Out of interest, why does it only work with a macro run asynchronously?

Peter is following Apple's "Human Interface Guidelines" -- pre-populated dialogs should have their contents selected ready for the user to replace. It may not even be an option to do otherwise in standard dialogs. So "the meantime" could be "a very long time", hence the workround.

If it's synchronous then it must complete before the "Trigger Macro by Name" action is executed -- the keystroke will be before the prompt is up. And you can't do it after the "Trigger Macro by Name" action because the prompt blocks execution. So you fire it off before, asynchronously and with a slight delay, so the keystroke happens after the dialog appears (but before the user gets bored of waiting!).

That's the bit I was missing, thank you.

That makes sense, though I do understand the frustration of the few threads I've seen on this behaviour. Another workaround is to do a Prompt with List or use a launcher like Alfred, but neither of these give you the macro's icon.

This neat little macro, I'm no sure how to set it up:

image

@DanThomas writes only:

Insert %Variable%(clipboard)%

Let's say you have a variable named "Local_Result" on the clipboard. Press the hotkey, and it gets pasted in as %Variable%Local_Result%. I've used this over 2,500 times. Again, it's just one action long.

How does Local_Result get 'populated'?

How is this meant to function?

/
best regards,
OmarKN

If my home had a driveway I would place a camera facing the driveway and use an OCR action running in a loop to check license plates coming into my driveway and send me an SMS message with the plate number being sent to my Apple Watch with cellular data plan.

I would use a dictionary to implement it so that no license plate alert would be sent to me more than once per hour.

From @DanThomas's post:

Let's say you have a variable named "Local_Result " on the clipboard.

(Emphasis mine)

So you can Copy a variable name from, say, a "Set Variable to Calculation" action:

image

...then run the macro to insert the correct form of that variable in a "Display Text" action:

image

Thought I'd add these too, even though it's a little like bragging - I thing they would be useful to most people:

I use these literally ALL the time:

And of course

and last but certainly NOT least:

3 Likes

Just copy a variable name to the clipboard, then execute this macro (I have it assigned to Ctrl-V). It inserts it with %Variable%...%

1 Like

Thank you for posting this. Is there any special reason why you assign the hot key ⌃⇧V to Paste by Name (used over 3,500 times) and the simpler hot key ⌃V to Insert %Variable%(clipboard)% (used 1,00 times less)? :wink:

Yes. I already had ^V, and was used to it. And if I'm not mistaken, when Peter first recommended the Paste By Name, I think that's the shortcut he used. But I could be wrong.

It would indeed be a nice cosmetic enhancement if any leading numbers plus brackets would be filtered out:

I'm sure @DanThomas will be able to do better than this inside the script action -- but in the meantime you can bodge it yourself by adding the following between the "Execute..." and "Abort..." actions:

2 Likes

Thank you. That works like a charm. What does the double underscore represent here?

A literal double underscore. @DanThomas is creating the pick list in the "friendly labels" format -- valueThatIsReturned__valueShownToUser -- and the digits and ) to be removed are at the start of valueShownToUser.