使用AppleScript打开应用程序

时间:2013-04-23 07:49:50

标签: applescript automator

我已经调整了'add - new item alert'苹果脚本并将其作为文件夹操作应用到我的'Volumes'文件夹中。调整后的脚本用于检测插入新USB驱动器的时间并打开应用程序(Automator工作流程),然后将该文件复制到驱动器并将其弹出。

第1期

当我在AppleScript编辑器中运行脚本时,它可以工作。 但是,当插入USB驱动器时脚本自动运行时,它只会告诉我它已检测到新驱动器并没有打开应用程序。我正在使用do shell脚本“open -a Conference_Copy_Paste”来打开位于我的应用程序文件夹中的应用程序(请参阅下面的AppleScript代码)。

使用的代码开始--->

property dialog_timeout:0 - 设置对话框自动应答之前的时间。

执行shell脚本“open -a Conference_Copy_Paste”

在收到added_items后将文件夹项添加到this_folder     尝试         告诉应用程序“Finder”              - 记住文件夹的名称             将folder_name设置为this_folder的名称         结束告诉

    -- find out how many new items have been placed in the folder
    set the item_count to the number of items in the added_items
    --create the alert string
    set alert_message to ("Folder Actions Alert:" & return & return) as Unicode text
    if the item_count is greater than 1 then
        set alert_message to alert_message & (the item_count as text) & " new items have "
    else
        set alert_message to alert_message & "One new item has "
    end if
    set alert_message to alert_message & "been placed in folder " & «data utxt201C» & the folder_name & «data utxt201D» & "."
    set the alert_message to (the alert_message & return & return & "Would you like to view the added items?")

    set the user_choice to the button returned of the result

    if user_choice is "Yes" then
        tell application "Finder"
            --go to the desktop 
            activate
            --open the folder
            open this_folder
            --select the items
            reveal the added_items
        end tell
    end if
end try

结束将文件夹项目添加到

< ---使用的代码结束

第2期

使用此应用程序约10次后,我开始运行时出错。错误显示“您没有权限保存文件”文件夹中的任何文件“无论文件夹”。“解决此问题的唯一方法是重新启动系统。有没有更好的方法来解决这个特定问题?

Automator应用程序的工作流程运行“获取指定的Finder项目”,“复制查找项目”,然后运行“弹出磁盘”。

提前感谢能够帮助我解决此问题的任何人。我迫切需要这个工作,因为我必须将文件复制并粘贴到1k USB驱动器进行会议。

1 个答案:

答案 0 :(得分:0)

尝试移动

do shell script "open -a Conference_Copy_Paste"

到内:

on adding folder items to this_folder after receiving added_items
相关问题