Copying text to custom clipboard

I am new to this program but am already finding it extremely useful and powerful, however one feature keeps escaping me. The custom clipboards seem to be very useful, but I am either using them incorrectly, or there is a bug in storing and retrieving contents.

My desired workflow is something like this:

1.) Two individual text boxes, each with a number.
2.) Copy the contents of each and store it as a separate variable for use later.
3.) When looping back, recall the contents of each and add a certain number to that value (ex. 5 + 7).

I had been trying to accomplish this by doing a Copy to Named Clipboard action followed by a Set Variable to Clipboard action. I created two new custom clipboards for this purpose and wanted to store the values in each clipboard, then name a variable for their contents to be used in a given cycle. But for whatever reason, in this workflow I am finding the contents of that text box are not being saved into the custom clipboard as evident by trying to recall the variable that I declared for their contents. I’m just not understanding why this feature isn’t working. The concept is not complicated, yet the result I’m observing doesn’t make sense.

I hope the above makes enough sense, but if not please let me know so I can clarify.

Variable and clipboards are completely independent of one another. Both are stored in the KM environment.

As best as I can tell, you don’t need named clipboards.
Just copy each text box into a separate variable.

Yes, and that’s what I thought, too. But when I tried to test this by doing the following…

1.) Copy contents of TextBox1 into clipboard.
2.) Name Variable ‘Var1’ from clipboard.
3.) Copy contents of TextBox2 into clipboard.
4.) Name Variable ‘Var2’ from clipboard.

…when I would test the results to see if it was working, Var2’s contents were overwriting Var1’s contents.

If you had two fields and tabbed from one to the next, you can do something like this:

  • Type the ⌘A Keystroke
  • Type the ⌘C Keystroke
  • Type the Tab Keystroke
  • Set Variable ‘Var1’ to Text ‘%CurrentClipboard%’
  • Type the ⌘A Keystroke
  • Type the ⌘C Keystroke
  • Set Variable ‘Var2’ to Text ‘%CurrentClipboard%’

That’s basically exactly what my workflow did, except in place of typing the copy keystroke, I used the Copy action. When I changed the flow to use the actual keystroke as you suggested, the variables are getting populated correctly. So clearly, the Copy action didn’t behave as I expected it would. What is the Copy action actually doing and how should it be used correctly?

Thanks for the reply, Peter.

EDIT: Another question I had in building this workflow is how to paste into one of the text fields a calculation based on a stored variable. For instance, I want to paste into a text box the result of the calculation of Var1 + 1. Then, copy that resulting value into the clipboard and use that to overwrite Var1. Apparently, the Insert Text action doesn’t like my syntax of %Calculate%%Variable%Var1%+1%.

EDIT 2: I ended up solving this by using the action ‘Set Variable to Calculation’ and specifying ‘Var1+1’, then just inserting the variable ‘Var1’ since it was overwritten in the previous step. With this final step, I was able to complete my workflow. Thanks again to you both for your help.

Sigh. I made the Copy action to do: Command-C/Wait for clipboard to change. But I screwed up the Wait for clipboard to change part, so it does not wait long enough. So Copy/Pause 0.1 Seconds would probably be fine. Fixed for the next version. Sigh.

Within the %Calculate% token, you are writing a calculation. When writing a calculation, you reference variables unadorned. So it is %Calculate%Var1 + 1%.

See the Calculate text token documentation which you can get to by holding down the option key and selecting Edit ➤ Insert Token ➤Help: Calculate.

Thanks for the information, Peter!