Hello, newbie question here, thanks in advance — how can I create macros, triggered by keystroke chord combinations, that will print today's date this way:
And just to let you know I at least tried something - - on the KM editor in the actions section in the search box, I typed the word "date" but it returned no results, regardless of which category I have highlighted. And the KM wiki gets into a complicated discussion of "tokens" but doesn't seem to go straight to the simplest answer.
Always try searching with the search field the Keyboard Maestro Editor Help Menu – you never know what you'll find -- actions, text-tokens, functions, and menu-items...
If you haven't read this it's worth a couple of minutes of your time.
Hi Chris, thank you so much for your detailed reply. This worked the way you told me it would, very nice.
Now just one note about the above, as I use the macros that print today's date in various formats, it looks to me like something about the process makes use of the computer's regular clipboard (copy/paste) register. For example, if I have a block of text from another app, and I went to copy it and then place it in a database, including starting with today's date, using the macro here and then hitting "command-V" for paste, prints only the date, again, rather than the text I had waiting. Then I have to go back to the prior document and select and copy the text again, and then go paste it in.
Is there any way to make this work differently, so that it won't take that memory register space? Or should I just get accustomed to a slightly different workflow, go paste the date and then go back and get the text?
In a word – No. The gateway for any paste action on macOS is the system clipboard and a narrow gate it is...
The only way around that is via AppleScript, and requires either the app to be appropriately AppleScriptable or for a target UI Element's value to be settable.
However the workaround for this is simple once you know about it.
Thanks for following up on this. I have been thinking about this for several days. Yesterday I had a conversation with someone who is also a Keyboard Maestro user.
Sorry to say, your reply and instruction is a bit over my head with regard to complexity. I’m a newbie with the app and way of thinking.
In conversation yesterday, my colleague said, yes of course you can make a date stamp that doesn’t take memory register, you just have to use an AppleScript.
But I’ve never done that, have no idea what that means. Is that what your example is? How would I implement that in Keyboard Maestro?
But, in doing so, will it wipe and replace whatever might be in the clipboard already?
My old workflow, with QuicKeys, was 1. highlight/copy text (in Mail or whatever); 2. change to database app (or TextEdit etc.) and enter date received, using macro; 3. paste the relevant text which was waiting in the memory register.
I never found any apps that that didn’t work in, up through Mac OS 10.11, after which QuicKeys no longer worked. Which is why I’ve gone to KM.
The contents of the clipboard is already saved to that history.
The macro uses the clipboard, because that's the only available gateway for pasting text anywhere on macOS – and then it deletes the NEW clipboard entry and leaves the original clipboard item right where it was in the first place.
Quite.
So try out the macro and see if it works the way you want it to.
Okay, sorry to be a newbie, and thanks for your patient answers.
So a “clipboard history” can be considered to be multiple macOS clipboards? Or some other register of clipboards that KM has as part of its app programming-? The primary clipboard register can keep the data that I have entered, and a date string creation can use a different register? Cool.
Okay I shall try it.
Yes I have imported it and tried it. Seems to work. Trying to understand why, but maybe it’s good enough to just have it there. Thanks for taking the time.
Can I duplicate it and change how it formats the printed date? I like to have the following, for different usages - -
Saturday, February 23, 2019
•2/23/19
2-23-19
BTW this is really helping me to move forward in my understanding of KM.
Yes. Although the system clipboard is static in position (so to speak) you can shuffle stuff in and out of it.
I think there's a Clipboard History macro in the default macro set, but I don't remember for certain.
Click on the “All Macros” group in the Keyboard Maestro Editor and then search for “Clipboard History”.
If you don't find one there should be one in the Macro Library – in the Keyboard Maestro Editor see:
MenuBar > Window > Macro Library
Install it if necessary and give it a keyboard shortcut if needed.
Run it, so you can see the history in action – and discover how useful the Clipboard History Switcher is.
The Insert Text by Pasting action automatically populates the system clipboard and pastes.
The Delete Past Clipboard action with clipboard 0 removes what was put into the system clipboard and the history stack pops back to where it was before the macro was run.
Yes.
Look in the Keyboard Maestro Editor Help menu for:
ICU Date Format Reference
Compare that to the expression I have in my macro and against what you want to do.
If you can't figure out the formats you want in 10-15 minutes of experimenting then report back and we'll help.
Just splashing in to say: implementing a clipboard history manager is one of the most useful things you can do on a computer.
Data always is a string of digits.
We move data all the time. We call this "copy" and "paste".
Every time we "copy" (or "cut" — which is two operations: copy and delete) the string is saved in the system clipboard.
Every time we "copy" the system clipboard is over-written.
Like many things related to computers, it's dead simple. The system clipboard is a location that holds one string of data. The string can be very very very long — say, a video — and it can be internally complex — say, a database — or as short or shorter than a single character. The system clipboard holds one string. When you replace the content, the new string is remembered, and the old string is removed. Once removed, neither the system clipboard nor the system have any access to the old string (though the original may still be accessed by the user).
A clipboard history manager remembers and tracks each entry, allowing you to access strings copied to the system clipboard prior to the current string in the system clipboard. The system keeps one and only one string in the clipboard. The clipboard history manager keeps a stack of strings. (The stack might be limited by duration (e.g.: a week), number (e.g.: a hundred strings), or something else.)
The clipboard history manager's stack is almost always FIFO — First In, First Out. It functions as a Pez dispenser that you manually load with one candy at a time: the last candy (string) you put in is the first one that comes out.
Keyboard Maestro's clipboard history manager is excellent. Within Keyboard Maestro the stacked strings are ordinated (that is, numbered). Typical for computer ordination, the current entry is number 0, followed by 1, 2, 3, etc. That's why in one of the macros supplied above, the Keyboard Maestro Action "Delete Past Clipboard" specifies "0". "Past clipboard 0" is the string currently in the system clipboard. Once the string in position 0 is deleted, every string in the stack moves up one position, so the string that had been at position 1 is moved to position 0, which is the top of the stack (the next Pez candy to be dispensed).
Because I use LaunchBar all-day every day, I use LaunchBar's clipboard history manager. I recommend it/them.
On to your task at hand .
I insert dates all the time. I use seven or eight different formats all the time. My need is best served by having independent macros for inserting the date/time, each assigned to a relatively easy-to-remember typed-string trigger. (All my typed-string triggers start with a period (dot) character. This has served me well since there are very few instances when I type a period followed by a non-space character.) Most of these use the Action "Insert Text by Typing". Some examples below. (I have scores of similar ones, including one for each program I write about — e.g.: ".km" ➞ "Keyboard Maestro ".)
I recommend that you set these up, customized to your needs. If you use the Action "Insert Text by Typing" you won't have any turbulence in your current workflow. (Nevertheless, I can't recommend a clipboard history manager strongly enough.)
All this touches on and begins to highlight the brilliance of Keyboard Maestro. It is exceptionally well-conceived and executed.
Final disclaimer: I am just a computer user. I've never been in a computer class. I've never written a line of code (I copy and paste). What I've presented above is information that, imho, promotes a useful understanding of computers. I know the representation is not completely accurate (improvements are welcome).
I have a much similar setup. In my case all of my typed string text expansions are in Typinator, which I use in addition to KM because I have nearly a thousand text expansions and it offers some features not in KM. Having said that, if I did not have Typinator, I could easily create these in KM.
My naming convention for triggering text expansions is:
Start the typed string abbreviation with a semicolon
Followed by a 2-3 character string (which is never a space) to denote the app or use case
(I use "'km." for my triggers for text that I use in the Keyboard Maestro app)
Followed by a period
Followed by a short string mnemonic which is very easy for me to remember
Terminated by a space
(I don't use any spaces in the trigger. All "words" are separated by a period.)
Example: ISO Date string for use in KM Actions:
";km.idate "
(without the quote marks)
RETURNS: %ICUDateTime%yyyy-MM-dd%
As @Kirby_Krieger mentioned, I find using a prefix of semicolon with a suffix of space ensures I never accidently trigger the expansion, while making it very easy to type.
The key is to work out a system for yourself that is very easy for you to remember and execute.
Hey Christopher, thanks for your kind and informative answers. And thanks to others who have chimed in.
However I seem to be on an email thread where I get lots of responses. Is there any way I could get off of that thread, or at least just get it in digest form once a week or something?