Keyboard Maestro Variables can be addressed by array delimiters.
By default the delimiter is a comma ,
For a Global Variable called Lightroom_Timestamp that contains the text
one,two,three
you would access "two" by this syntax
Lightroom_Timestamp[2] or in a text field %Variable% Lightroom_Timestamp[2]%
Lightroom_Timestamp[0] gives you the total number of items stored (in this case 3)
You can also use a custom delimiter to separate the entries. For example you could use the symbol ★ This can be useful if your data entries might contain commas.
So the data in your variable array might look like one★two★three
And for a multiline array like:
one
two
three
you can access specific lines by using \n as the custom delimiter. So to get line 2 into a text field you would use %Variable%Lightroom_Timestamp[2]\n%
For example, you could have a "collecting macro" that builds your variable from the clipboard. Put in a Group that is only active in Lightroom Room Classic, the macro would be triggered each time the Clipboard changes, looks at the clipboard data and if it matches your criteria, appends it to your variable with your delimiter (or appends it to a new line in your variable, if you want to use lines as the delimiter. (Using the Append to Variable
Action). As Lightroom_Timestamp is a Global Variable this data is stored between macro runs.
Or, to make this simpler and more robust, instead of being triggered on clipboard changing, you could just give your collecting macro a hotkey and press this each time you want to save an entry (I think this is the way I would do it).
Since this is just text we are saving, no need to limit it to 5 entries. You could limit it to say, 20.
Using [0] to check the total number of entries, if the entries are more than 20 you would remove entry 1 (oldest) entry.
You would have a second Macro that uses this data to restore the playhead. Just like the clipboard history switcher you can call back the data from any position in the array.
The most recent entry would be the total number of entries. Let's say you had collected 7 entries and you were using the delimiter ★
Lightroom_Timestamp[0]★ would return "7"
To get "7" in an easily usable from, set a Variable like this:
Set Local_Total to Lightroom_Timestamp[0]★ (which in this case sets Local_Total to 7)
Use this Variable like this to access the most recent entry in your array:
Lightroom_Timestamp[Local_Total]★
to get the entry before last use
Lightroom_Timestamp[Local_Total - 1]★
In a text field, this is written as %Variable%Lightroom_Timestamp[Local_Total - 1]★%
That should give you the tools to build your Macros.
EDIT - One practical thing to be away of. If you build your array by appending your data plus delimiter symbol each time you might have an array that looks like this:
one★two★three★
When getting the total entries, Lightroom_Timestamp[0]★ would return 4 as the answer rather than 3 as it would expect to see one★two★three to get the answer 3. So, in this case to access the most recent entry you would actually use %Variable%Lightroom_Timestamp[Local_Total - 1]★%
EDIT 2 In my original post I used all Local Variables as examples - but your "collecting" Variable would need to be a Global Variable to store the data between Macro runs. I've edited my original post to make this clearer.
.