Tom*_*iba 6 macos scripting command-line applescript osascript
我需要 AppleScript,当从命令行运行时,它会返回三件事:
例子:
我知道还有一些类似的问题。stackoverflow 上的答案在这里,但我无法将它们组合在一起以完成所有这些工作。非常感谢您的帮助。
我想制作一个在后台运行的脚本,以便我可以更好地跟踪我的时间。这是我想出的:
tell application "System Events"
    set frontmostProcess to first process where it is frontmost
    set appName to name of frontmostProcess
end tell
tell application appName
    set windowName to the name of the front window
end tell
if appName is equal to "Safari" then
    tell application "Safari"
        set theURL to the URL of the current tab of the front window
    end tell
else if appName is equal to "Google Chrome" then
    tell application "Google Chrome"
        set theURL to the URL of the active tab of the front window
    end tell
else
    set theURL to ""
end if
return (appName, windowName, theURL)
感谢https://apple.stackexchange.com/a/171738让我走上了正确的道路。