I currently have created an automator workflow (in Catalina) that will paste in a two-step authentication code by a keyboard shortcut within the Cyberduck app. However, I am wondering how to possibly create a workflow that can automatically paste the code in via the shortcut whenever a certain pop-up comes up. For example, in Cyberduck we have:

enter image description here

I am wondering how automator can generally be used here. I have seen something that might adhere to what I want, displayed as "text" in the automator workflow options:

enter image description here

but would like to know if this is the right path. Thanks!

  • Do you mean you want to automatically paste some text in whenever a particular dialog appears? I'm not sure that Automator can do that. I'm not even sure that AppleScript can do that, as you'd need some way of notifying the script or testing for that dialog. I wait to be proved wrong. Also, if you're automating an authentication process, think about what will happen if someone else has the Mac when that script runs.
    – benwiggy
    Mar 19, 2020 at 7:40

1 Answer 1


I have a solution that may work for you. This approach will not require the use of Automator or keyboard shortcuts for pasting text into password fields. In Script Editor.app, paste this following AppleScript code into a new document and save it as a .scpt file. I named my version Cyber_Test.scpt. For this following approach to work correctly, you will need to go into Script Editor Preferences/ General/ and select the option to "Show Script menu in menu bar".

enter image description hereNext, open Cyberduck.app and while it is front most, click on the Script menu in menu bar/ Open Scripts Folder/ Open Cyberduck Scripts Folder. Finder.app will then reveal and open that folder. That is where you will need to put your version of the "Cyber_Test.scpt" file you previously created and saved.

enter image description here

Because of all those previous steps, now anytime Cyberduck.app is running and front most, you can simply run your "Cyber_Test.scpt" by selecting it in the Script menu in menu bar.

enter image description here

set authenticationText to "verification_code"
set cyberDuckIsRunning to application "Cyberduck" is running

if cyberDuckIsRunning then activate application "Cyberduck"

repeat while cyberDuckIsRunning
    tell application "System Events" to tell application process "Cyberduck"
            if exists of text field 1 of sheet 1 of window 1 then
                set value of text field 1 of sheet 1 of window 1 to authenticationText
                delay .1
                click button "Continue" of sheet 1 of window 1
            end if
        end try
    end tell
    delay 0.1
    set cyberDuckIsRunning to application "Cyberduck" is running
end repeat

I was not able to produce the same verification code window as the one in your image but I was able to provoke a similar window to insert a password or verification code of sorts. Because of this, the code in my example may not work for you. If this is the case, you could follow my solution here https://apple.stackexchange.com/a/315091/210407 About using Automator and Watch Me Do, to identify the name of Windows and other UI elements, which can then be inserted into your code.

Basically, this script will continue to run, continually checking if the verification code window exists and if it does, will insert the text (which you will define in the authenticationText variable. Then after that, it will click the "Continue" button. Then it will continue monitoring for that verification window again etc., only while Cyberduck.app is running. When Cyberduck.app is no longer running, the "Cyber_Test.scpt" will also stop running.

enter image description here

Some people will tell you that it would be more resource efficient to create a stay open application with an idle handler... And inserting some variation of the code within the idle handler. Generally I would agree with that but for purposes of this task, the amount of code running in the repeat loop is so minimal that I don't think it makes much of a difference. On another note, if it were an application file… you would need to deal with the hassle of adding the app in your security preferences… to the list of applications allowed to control your computer. Then anytime you make changes to the code and re-save it, you will need to go back and re-add it in your Security Preferences again. With .scpt files being run from the script menu in the menu bar, I believe only System Events.app and Script Editor.app need to be added to your Security Preferences (one time only)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .