Automator app variable and AppleScript

I have an Automator app to set up a new project in Finder. It works well enough for my needs. However, there are two issues which annoy me from an automation point of view.

First, I have a dialog to set the new project’s name. If I run the automation in Automator itself, the cursor for text entry is at the insertion point in the dialog. When I launch the automation as an app, however, I have to mouse into the dialog box and click to place the text insertion point. If it were possible, it would be more “automated” if the cursor was already in the insertion point.

Second, I would like to use the same automation to set up the new project in Omnifocus. I have got the automation to the point where it will set up the new project in the right folder in Omnifocus. The only way I have found give the project the new project’s name, however, is to have another dialog box to type in the new project’s name.

This is obviously better than having to launch Omnifocus and enter the new project manually but I am wondering if there is a way to pass the variable from Automator into Applescript? The resources I have looked at through Google searches don’t seem to address this or, if they do, I haven’t understood them. Any pointers where to look would be much appreciated!

I am not sure how to upload an automaton to the forum, so here is a link to the app.

Thanks in advance, Warwick

Try the suggestions here:

Here’s an example. I have explicitly captured input to a variable, and then purposefully broken the flow of data you typically have to show an example of how the variable can be independently referenced in both an automator native action and in AppleScript.

The workflow captures input, then displays a notification and a dialog with the captured text. The former uses a native action, and the latter an AppleScript script; it is purely an example and not how I would choose to do this.


As an aisde, if you have not already begun exploring the capabilities of Shortcuts on the Mac, I would strongly recommend that you do. I suspect you will find that it becomes even easier to do the interactions across automation solutions with Shortcuts as the backbone, and Apple has indicated that Automator is slated to be deprecated in favour of Shortcuts. You might find this automation and what you want to do with it is an ideal candidate to migrate to Shortcuts and act as a platform to get to know Shortcuts capabillities further assumign you have not fully got into it.


I just get a code signing error because it is from an unidentified developer. Hence rather than modifying what you shared I have given an example.

Hope that helps.

Thanks, the link to pocketfulofcheese solved problem 1.

I couldn’t get the variable set for the Finder to be picked up in Omnifocus but now I just have to type in the new name twice so that at least can all be done from the keyboard.

I have a little bit of familiarity with Shortcuts. However, one of the two computers I use in these days of working from home and “work” stopped at Catalina and is not Apple silicon.

Much appreciated!

Great.

Was there something about the example that you could not reproduce to get that working?

Apple Silicon makes no difference (I have Intel Mac’s and is Shortcuts on them), but the OS does. I agree that Automator is therefore the logical choice for what to use to have a single solution across your Mac’s.

The problem I think I am running into is passing the variable used to name the folder being created in the Finder into Omnifocus.

For example, if I try:

Screen Shot 2022-07-17 at 6.08.28 pm

I get an error:

Screen Shot 2022-07-17 at 6.08.16 pm

I have also tried several variation of the line " set newProjectName to" including just:

set newProjectName to input

set newProjectname to input works just fine for me. It is also as I would expect, because it is text, it is passed in, and it is being used as text. It should not need any coercion to be usable. Here is a screenshot showing it running, and a dialog displaying as the AppleScript step is running. I’ve used the display dialog just to show the use of the newProjectName once it has been set - though you could just continue to use input. I entered “Test 11” just as per your error just to explicitly rule out it being something about the value.

2022-07-17-10.59.18

What happens if you plug in (and amend for the variable name) the non-OmniFocus AppleScript from my previous example into your Automator workflow/app? Does that work? If it does, then that would suggest the issue is in the OmniFocus AppleScript and I would suggest double-checking it. If it does not, that would suggest the issue is with any capture or manipulation of the variable content prior to the running of the AppleScript.

Hope that helps.

Thanks.

Yes, your display dialog example worked.

So, I retyped the Applescript and took out a few extraneous returns and spaces and VOILA! it is working!

Thank you!