简体   繁体   中英

Automator, AppleScript or other?

I need to automate my app by passing a series of parameters to it at once. In Windows I pass them all as a command line from a shortcut but I need to do the same for OSX.

I have been looking at AppleScript but it seems I would need to send each parameter separately like tell myapp to use <x> then tell myapp to use <y> . Automator looks like it could do what I want but looks way too complicated.

My ultimate goal is to send a series of text parameters followed by a list of file paths by dropping files onto an icon on the desktop.

What would be the best way to achieve this?

If I understood correctly, the app in question accepts command line arguments. Then, all you need is an AppleScript droplet which receives files and passes their paths as (whitespace-separated) arguments to the shell command:

on open these_items
    set file_args to ""
    repeat with one_item in these_items
        set file_args to file_args & " " & quoted form of POSIX path of one_item
    end repeat
    set command to "open" -- replace this with your shell command + arguments
    do shell script (command & file_args)
end open

(based on this forum post )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM