您可以从 Swift 应用程序执行 Applescript 脚本吗 [英] Can you execute an Applescript script from a Swift Application

查看:32
本文介绍了您可以从 Swift 应用程序执行 Applescript 脚本吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个发送电子邮件的简单 AppleScript.如何从 Swift 应用程序中调用它?

I have a simple AppleScript that sends an email. How can I call it from within a Swift application?

(我无法通过 Google 找到答案.)

(I wasn't able to find the answer via Google.)

推荐答案

已测试:可以这样做(添加了任意脚本路径):

Tested: one can do something like this (arbitrary script path added):

import Foundation
 
let task = Process()
task.launchPath = "/usr/bin/osascript"
task.arguments = ["~/Desktop/testscript.scpt"]
 
task.launch()

这篇关于您可以从 Swift 应用程序执行 Applescript 脚本吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆