AppleScript在每次运行脚本时运行Atom文本编辑器,而不是在if语句为true时运行
我是AppleScript新手,我正在尝试制作一个简单的AppleScript,它会弹出一个对话框,询问用户输入,并根据输入打开一个或另一个应用程序。为此,我使用了:AppleScript在每次运行脚本时运行Atom文本编辑器,而不是在if语句为true时运行,applescript,automator,Applescript,Automator,我是AppleScript新手,我正在尝试制作一个简单的AppleScript,它会弹出一个对话框,询问用户输入,并根据输入打开一个或另一个应用程序。为此,我使用了: tell application "atom" activate end tell 其中一个应用程序存储在名为Tardis的外部硬盘上。下面代码的问题是,每次我同时运行脚本和对话框窗口时,它都会自动打开Atom。我只希望它在输入a时打开Atom。谢谢你的帮助!代码如下: on run {input, parameters}
tell application "atom"
activate
end tell
其中一个应用程序存储在名为Tardis的外部硬盘上。下面代码的问题是,每次我同时运行脚本和对话框窗口时,它都会自动打开Atom。我只希望它在输入a时打开Atom。谢谢你的帮助!代码如下:
on run {input, parameters}
set inputText to text returned of (display dialog "Options: p - a - j" default answer "")
set p to "p"
set a to "a"
set j to "j"
if (inputText = p) then
tell application "Terminal"
if it is running then
do script "cd Python_Workspace; source ~/tensorflow/bin/activate"
end if
activate
end tell
tell application "Finder" to open POSIX file "/Volumes/Tardis/EXTRA Applications/Sublime Text.app"
end if
if (inputText = a) then
tell application "Atom"
activate
end tell
tell application "Terminal"
if it is running then
do script ""
end if
activate
end tell
end if
if (inputText = j) then
tell application "Terminal"
if it is running then
do script "cd /Java_Workspace"
end if
activate
end tell
tell application "IntelliJ IDEA CE"
activate
end tell
end if
return input
end run
因此,一些支持Applescript的应用程序需要启动应用程序来编译Applescript(如果我没记错的话,这些应用程序对Applescript的支持很差,我打赌是Atom) 这可能不是实际发生的情况,特别是如果您正在启动编译后的Applescript,但可能正在运行.Applescript(文本)文件 我要做的不是
告诉应用程序“Atom”激活
(您拥有的一行版本),而是:激活应用程序“Atom”
如果这对您有效,activate
vstell
下面是发生的事情:
激活
激活应用程序
您没有尝试执行任何特定于Atom的操作。。。只需激活一个应用程序。不需要查字典
(同样值得注意的是,我已经这样做了很长时间。实际上,我可以引用你的信息,这些信息已经过时十年或更长时间了,或者在10.4中是“新的”——不是10.14,而是10.4)