Paste Versions of App and macOS (Simple Ver) (KM 8.2+)

Video Demo of Macro

(Video is for Ver 2.1. Will be updated soon)

  • You only need to type as much of app name as is needed to identify it.
  • If Exact match of AppName is NOT found, then choose from Prompt with List of All Apps

UPDATED: 2019-06-29 20:56 GMT-5
Ver 2.2

  • Revise design to support any type of Macro Trigger
    • Typed String Format (begins and ends with a semicolon):
        ;ver.AppName;	<== App Ver AND macOS Ver
        ;ver;			<== macOS ver only
  • You can type an Abbreviation for the App Name IF you have entered it in the Local__AppAbbrevList Action

  • If Exact match of AppName is NOT found, then choose from Prompt
    .

    • Any Other Trigger (like HotKey or byName),
      THEN a Prompt with List will be shown directly.
    • Type a few characters of the App Name
      OR
    • Type "all:" (without the quotes) to see the full list
  • Replace script that gets list of all apps with much faster script by Chris @ccstone.


MACRO:Β Β Β Paste Versions of App and macOS (Simple Ver)

~~~ VER: 2.2Β Β Β Β 2019-06-29 ~~~

DOWNLOAD:

Paste Versions of App and macOS (Simple Ver).kmmacros (46 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • Paste Versions of App and/or macOS
    • Example Output:
      • Keyboard Maestro 8.2.4 on macOS 10.14.5

HOW TO USE

  1. First, make sure you have followed instructions in the Macro Setup below.
  2. Make sure your text cursor is in a text field/area in the FrontMost app, as the result will be pasted in it.
  3. Trigger this macro by any of the following:
    .
    • Typed String Format (begins and ends with a semicolon):
      • ;ver.AppName; <== App Ver AND macOS Ver
      • ;ver; <== macOS ver only
      • You can type an Abbreviation for the App Name IF you have entered it in the Local__AppAbbrevList Action
      • If Exact match of AppName is NOT found, then choose from Prompt
        .
    • Any Other Trigger (like HotKey or byName),
      THEN a Prompt with List will be shown directly.
      • Type a few characters of the App Name
        OR
      • Type "all:" (without the quotes) to see the full list

MACRO SETUP

  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. ??
      .
  1. Assign a Trigger to this maro.
  2. Move this macro to a Macro Group that is only Active when you need this Macro.
  3. ENABLE this Macro.
  4. EDIT the Actions with Magenta Color:
    • SET Local__AppAbbrevList

REQUIRES:

  1. KM 8.2+
  2. macOS 10.11.6 (El Capitan)

TAGS: @Version @Apps @macOS @RegEx @Strings @ShellScript @Perl

USER SETTINGS:

  • Any Action in magenta color is designed to be changed by end-user

ACTION COLOR CODES

  • To facilitate the reading, customizing, and maintenance of this macro,
    key Actions are colored as follows:
  • GREEN -- Key Comments designed to highlight main sections of macro
  • MAGENTA -- Actions designed to be customized by user
  • YELLOW -- Primary Actions (usually the main purpose of the macro)
  • ORANGE -- Actions that permanently destroy Variables or Clipboards,
    OR IF/THEN and PAUSE Actions

USE AT YOUR OWN RISK

  • While I have given this a modest amout of testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:
    • Ask first
    • Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

1 Like

Just updated my above post with a new script. Usage and functionality remains the same.

1 Like

thank you for your video today, and for the macro.
the short video is a very good idea.

just an idea: the macro would only be used from time to time. I noticed that I forget the syntax after 5 minutes and have to review the macro to remember.
I was wondering if an alternative would be to the the KBM keyboard macro trigger βŒƒβŒ₯ ⌘T β†’ the user types the word 'version' to run your macro β†’ the macro requests user input (name of the app) β†’ the resulting text is sent to clipboard

That's a valid alternative. Indeed you are almost describing an approach that I used in a Macro that I uploaded today that fetches macOS System Information. It's triggered by a keystroke and gives you a window asking you what information you want via buttons, then pastes the information. I guess it's a question of style. I think your style works better for me too.

@ronald @Sleepy This macro can be made to work essentially like what you describe just by modifying the regex used to extract the app name:

(?:;ver\.?)?([^;]*);?
image

This way, if you run the macro via the Trigger Macro by Name action, you can either type the full or partial name of the app in the action itself by prefacing it with //:

Or just trigger the macro and then choose the name of the app you want from the Prompt With List action:

14%20PM

While this latter way does initially load the Prompt With List action with the macro name itself:

17%20PM

It's simple enough to just overwrite it by typing the desired app name. This way, you can use the macro either via its typed string trigger if you remember its syntax, or Trigger Macro by Name if you can't.

1 Like

works perfectly ! just as a precaution, because I will not be using it that often, I also want to display the path at the end in a text box, but I don't know which variable to display.
the following obviously only displays the app name
Your mastering of regex is incredibly powerful !
thank you !

image

Yep, we each have different preferences on how to trigger macros.
For me, I try to reserve HotKey triggers for those macros I use most often.
I have found that Typed String Triggers work well for me because I have a consistent format, and I always try to use key characters in the string that are very mnemonic for me.

  • All of my Typed String triggers (and Typinator snippets) start with a semicolon
  • Since this macro is about "versions", the characters "ver" are easy for me to remember, as I often use just that for an abbreviation.

If you, or anyone prefer a different Typed String, it is fairly easy to change:
Whatever you use here:

image

Needs to be consistent with the RegEx here:
image

So, let's say you would rather it be triggered by:
/appver.YourAppName/

Then the RegEx would simply change to:
/appver\.?([^\/]*)/

I hope that makes sense. If not, just ask.

Yes. And actually I think you have the skills to make those very changes. :smile:
That's the great thing about sharing Macros -- each of us can customize to our own liking.
And the more you make customizations, the better you will become at it.

@gglick showed you one way to achieve what you requested, but I'd prefer NOT to change the Typed String RegEx.
It is actually simple to add one more KM Variable, and then adjust the IF/THEN Actions accordingly:
Just add this Action at the very top of the Macro:
image

The Trigger Type, or %TriggerBase% as KM calls it, returns the type of Trigger used to trigger the macro. So, for a Typed String trigger, it returns "Typed String". We can then use that in our IF/THEN Actions, something like this:

image

The above is NOT the full logic, but close to it, and serves as a good example of how to do this.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So, I do thing you have some good ideas, and I have incorporated them into my revised Macro. I will make an update to my OP above shortly to post this update.

1 Like

Just posted an update to my macro in the OP above.

very interesting. thank you.
I once read a comment about typed string triggers in which the author said he stopped using them because he realized you had to be in some kind of editor mode to trigger it

Hey @ronald,

This is true after a fashion.

It is safest/best to be in an editor when using typed-string triggers but you can use them elsewhere if you're prepared for the possibility of side-effects – and you make COMPLETELY SURE this setting is OFF:

image

If this setting is NOT off then there is GREAT potential for DESTRUCTIVE side-effects.

Really – if you want typed-triggers outside of text-abbreviation-expansion you should probably use a Prompt With List action.

There are exceptions of course.

With a Prompt With List action you can go-completely-to-town with all kinds of custom string abbreviations including (or not) text-tags to make certain you can find what you want.

-Chris

1 Like

thank you very much. I think that Prompt with List which I did not know about is much safer for someone like me. @JMichaelTX is at a whole other level. I have had disasters in the past just with KBM shortcuts I had forgot about, so typed string triggers in my case would be an accident waiting to happen.

Typed String triggers, better known as text expansion abbreviations, are best suited for, and perhaps only for, use with typing/pasting something into the textbox/area in which you typed the string.

==Typed String triggers should NEVER be used outside of a textbox/area.==

==IMO, you are far more likely to accidentally trigger a macro or script using a HotKey than you are with a typed string trigger.== This is especially aggravated by the fact that you can create HotKeys in multiple apps. For example:

  • KM
  • FastScripts
  • macOS System Preferences/Keyboard
  • etc

I have been using typed string triggers for almost a decade now, and have NEVER had one be triggered unintentionally. This is mostly because of the way I format ALL typed strings:
<semicolon><GroupID>.<KeyChars><space>

The fact that I use a semicolon followed by some character means I should never accidently trigger it since in normal typing any sentence/phrase that ends with a semicolon will be followed by either a space or a end-of-line character.

Example:
;km.n
which returns:
Keyboard Maestro

I now mostly use Typinator for my text expansions, and I use some form of typed string to trigger text expansions many, many times a day.

Finally, the very name of this Macro, which starts with "Paste", is a huge clue that the Typed String must be typed in a textbox/area that can receive a paste from the Clipboard.

Having said all that, I fully appreciate that different users have different preferences. So that's why ==my last update to this Macro allows it to be triggered by virtually any trigger==. If it is NOT triggered by a Typed String, then you will always get a Prompt with List to choose the app.

2 Likes

thank you for the flexible macro.
Concerning the typed strings, you have a point. Thinking back, my strings were never as sophisticated as yours. You taught me to use strings completely unlikely to be typed by accident.

I don't use string triggers myself. I'm a little scared of them, and I don't like having to memorize things. That's why I went into computers instead of other sciences, because there was much less to memorize. I did some of my University computer exams (eg, Fortran) without trying to memorize a single thing, whereas my other exams required days of memorizing.

1 Like

Fortran !
thanks for your comment

Yes, and I wrote Fortran programs on punched computer cards. That was a very slow debugging process. It made you learn to get things right the first time.

I think I also tinkered with the B language, which, for those who don't know, preceded the C language. Our university hadn't installed C yet. We were stuck on B.

1 Like

never head of B !

In those days many college students took computing courses, wrote little programs in basic, etc which gave them some elements of understanding of logic, algorithms etc which can be applied today at a basic but useful level with Mac Automation.

I am surprised at how many people today were brought up using GUIs and have strictly absolutely nada understanding of computing.

They do not even understand that the smartphone is the belated implementation of Shannon's 1948 information theory. Without that theory, the iPhone would be a piece of junk.

Nothing to be scared of, if you properly design the Typed String trigger.

Then you should like Typed String triggers, since they can contain mnemonic words/characters that make it much easier to remember than some hotkey which can use any combination of 4 modifier keys.

I find it much easier to remember ";ver.AppName" than βŒ˜βŒƒV, mainly because I associate "V" with "paste", and "ver" is very easy to remember as a mnemonic for "version". And what happens if all of the "V" hotkeys are already in use? then what letter/key do you use? How do you remember it?

That has not been my experience, and I have degrees in both engineering and computer science. Every field, including Computer Science, has many terms, commands, etc that must be remembered ("memorized") if one wants to be efficient and productive in that field. Just think of all of the commands one needs to know in Windows Batch files, Unix command line, and Mac Terminal. To be productive in writing KM Macros, you need to remember many of the basic Actions, Tokens, and Functions.

And then there is AppleScript, maybe one of the hardest languages I have ever learned, because of its very un-intuitive commands and syntax. There is much to memorize in AppleScript.

I didn't realize they were still teaching FORTRAN at universities these days. May I ask when you took FORTRAN, and at what university?

1 Like

"These days"? I'm flattered that you think I'm young. I don't consider myself old but I'm definitely not young. You can ask how old I am, but I decline to give out personal details of myself other than I'm from Ottawa. No harm done. But it was several decades ago in Canada.

You asked me how I remember hotkeys. I don't. If I need more than one hotkey, I consider my programs to be a failure. If there's more than one function a user can call, he should be able to get it by invoking one hotkey and choosing which function from a menu. Hotkeys are like, say, the vi editor. You have to memorize a bunch of arbitrary shortcuts. No thanks. After many decades I still don't know any vi commands except dd and i. (Just a slight exaggeration, but not by much.)

If a user needs to be able to choose from a bunch of different options they should be visible on a pop up window perhaps via buttons. If you need one hotkey to bring up the menu, so be it. People can memorize one key.

But we're talking about two different things here, the burden on the programmer and the burden on the end user. I'm not quite as worried about the burden on the programmer. In some cases the user is the programmer, sure.

I don't recall they ever tested me in university about memorizing command line parameters. The tests I did were about writing algorithms based on English-worded questions. The focus was on writing code using standard language features, not talking about obscure command line parameters. For example yesterday I posted a macro that solved that glass water pouring puzzle. That's an example of the test questions I faced. It was about problem solving skills, not memorizing skills.