我尝试做什么:
当我在我的一个文本编辑器(TextEdit,Byword,FoldingText)中时,我希望AppleScript显示文件路径.
我想要求最前面的窗口应用程序让我的应用程序名称很好,很容易,然后我可以在下一步请求POSIX路径.
问题:
脚本已经99%了,但我遗漏了一些东西.当我尝试使用activeApp它的变量不起作用,我得到这个错误:
Error Number:System Events got an error: Can’t get application {"TextEdit"}.
-1728
Run Code Online (Sandbox Code Playgroud)
这是脚本:
tell application "System Events"
set activeApp to name of application processes whose frontmost is true
--This doesn't work either:
--do shell script "php -r 'echo urldecode(\"" & activeApp & "\");'"
tell application activeApp
set myPath to POSIX path of (get file of front document)
end tell
display dialog myPath
end tell
Run Code Online (Sandbox Code Playgroud)
如果我activeApp与"TextEdit"一切工作交换.帮助将不胜感激.
也许这里有一些帮助:使用Applescript从应用程序名称获取进程名称,反之亦然
我想隐藏最前面的应用程序.我知道你可以使用语法隐藏进程:
tell application "System Events"
set visible of process "..." to false
end tell
Run Code Online (Sandbox Code Playgroud)
我知道如何获得最前面的应用程序:
(path to frontmost application as string)
Run Code Online (Sandbox Code Playgroud)
但是,如何将两个命令连接在一起?
这不起作用:
tell application "System Events"
set visible of process (path to frontmost application as string) to false
end tell
Run Code Online (Sandbox Code Playgroud)