Reputation: 11
I'm looking for assistance with passing a variable from AppleScript to Automator.
I am working on a small automator app. I need to type a number that will be added to the end of a PDF's name. I used "Ask for text" in automator, however, I found out that, first, the pop-up window does not stay at the centre of screen. (27" iMac.), and second, every time after I input a number, I need to use mouse to click OK, the Enter key does not work.
So I turned to AppleScript for help. And here is what I found, a window that let me input the number, then click continue, then pass the number to Automator to add to PDF's name.
on run {input, parameters} display dialog "Please enter QC Round." default answer "" with icon stop buttons {"Cancel", "Continue"} default button "Continue" --> Result: {button returned:"Continue", text returned:"MySecretPassphrase"} return input end run
But it does not work. Can anyone help me fix it?
Upvotes: 1
Views: 1795
Reputation: 3412
In Automator, an action gets its input from the previous action, and passes its results on to the next action. In a Run AppleScript action, the input is in the input
argument to the run handler, and items returned by the handler are what get passed on.
In your example, you are just passing on the input
, which doesn't have a value since the action is ignoring its input. The solution is to return the text from the dialog, for example:
on run {input, parameters}
set dialogResult to (display dialog "Please enter QC Round." default answer "" with icon stop buttons {"Cancel", "Continue"} default button "Continue")
return text returned of dialogResult
end run
Upvotes: 1