Please see Post #16 to find version 6.00 of this macro. (Link)
EDITED 2023/01/24 15:12 CDT
Hey Folks,
I finally got around to automating the date-stamps in my paste attribution macro.
Currently the pasted attribution looks like this:
But you can edit the XML to suite yourself – OR you can create a new attribution comment – export it as an action – open it in a text editor like TextWrangler – and copy the new XML into the set attributionAction variable action.
The action will be imported into the macro you're currently editing in the Keyboard Maestro Editor.
-Chris
[Edit: updated 2016/05/22 09:38 CST to v1.0.1]
[Edit: updated 2018/03/13 00:18 CST to v4.00 -- see post 11 below.]
As a JavaScript for Automation footnote (in case anyone wants to explore further) I wondered if we could create the plist by writing something like:
function run() {
// ISOLocal :: Date -> String
function ISOLocal(dte) {
var xs = ['FullYear', 'Month', 'Date',
'Hours', 'Minutes', 'Seconds'
]
.map(function (k, i) {
var n = dte['get' + k](),
s = (n + (i === 1 ? 1 : 0)).toString();
return (s.length === 1 ? '0' : '') + s;
});
return xs.slice(0, 3).join('-') + ' ' + xs.slice(3).join(':')
}
var strNow = ISOLocal(new Date());
$.NSDictionary
.dictionaryWithDictionary({
ActionColor: 'Aqua',
ActionName: 'A Macro by Your Name <Your EmailAddress>',
MacroActionType: 'Comment',
Text: 'Authored by Your Name <Your Email Address>\n' +
strNow + ' : Created\n' +
strNow + ' : Modified'
})
.writeToFileAtomically(
$('~/Library/Caches/TemporaryItems/kmImportAction.kmactions')
.stringByStandardizingPath, true
);
}
Only gave myself 25 mins and now the time is running out the verdict is ‘close but no cigar’. The code above creates a single <dict> group (not wrapped in an <array>), so KM can’t read it.
If anyone else has 25 mins and a curiosity about plists in JSA, it might be worth looking more closely at NSDictionary
So far I have only got:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ActionColor</key>
<string>Aqua</string>
<key>ActionName</key>
<string>A Macro by Your Name <Your EmailAddress></string>
<key>MacroActionType</key>
<string>Comment</string>
<key>Text</key>
<string>Authored by Your Name <Your Email Address>
2016-5-21 18:23:19 : Created
2016-5-21 18:23:19 : Modified</string>
</dict>
</plist>
Added an Execute a Shell Script action at the beginning to make certain the temp directory exists.
I did this, because the macro failed after a reboot (when the temp dir was deleted).
Added a Click on Found Image action to dismiss the notification center banner.
The last 2 actions may need adjusting for your system depending upon how you have Notifications set up. (I have them set to Alerts for Keyboard Maestro.)
Regarding the settings for Notifications, I have them set up as Alerts for the Engine, but Banners for the editor. This has worked well for me so far - you might want to try that? And if you already have, in what way didn’t it work for you (just curious)?
(I’m not saying you shouldn’t put the Click on Found Image action in your macro - I’m just talking about using Notifications in general.)
This macro auto-generates an attribution action (as seen above) and places it in the macro currently being edited in the Keyboard Maestro Editor. (Macro must be in edit mode.)
I've improved the macro in a couple of ways – now version 6.01.
KM Variables have been added to make adding user-data into the macro easier.
Styled Text is now supported.
Default is Lucida Grande 14, but users may change that as they like.
Changes to font family and/or font size may necessitate small adjustments in the attribution text for the text-table to align properly.