小编Shr*_*ngh的帖子

尝试将苹果脚本集成到 Swift mac os 应用程序中以获取 macOS 上应用程序的 gui 元素

尝试在 Swift mac os 应用程序中集成 Apple 脚本并收到以下错误 NSAppleScriptErrorBriefMessage =“未授权将 Apple 事件发送到系统事件。”;

以下是脚本

        activate application "Calendar"
        delay 0.1
        tell application "System Events"
            tell front window of application process "Calendar"
                set uiElems to entire contents
            end tell
        end tell
"""
Run Code Online (Sandbox Code Playgroud)

以下是整个代码

import Cocoa
import SwiftUI

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    var window: NSWindow!


    func applicationDidFinishLaunching(_ aNotification: Notification) {
        // Create the SwiftUI view that provides the window contents.
        let contentView = ContentView()

        // Create the window and set the content view. …
Run Code Online (Sandbox Code Playgroud)

macos xcode applescript swift

0
推荐指数
1
解决办法
1323
查看次数

标签 统计

applescript ×1

macos ×1

swift ×1

xcode ×1