我是AppleScript的新手,我想为许多AppleScripts创建一个UI选择器。
示例,我有testA.scpt,testB.scpt,testC.scpt,我想通过从窗口(UI)中的选项列表中选择来运行其中一个脚本。
有可能吗?
所以,有可能,你能帮助我并举个例子!?
我认为这是一个非常相似的代码,但我不确定:
set theName to (choose from list {"testA", "testB", "testC"})
if theName is false then
display dialog "You clicked cancel to exit." with icon stop buttons {"Exit"} default button {"Exit"}
else
set theName to (item 1 of theName)
display dialog theName with icon note buttons {"Info"} default button {"Info"}
end if
答案 0 :(得分:1)
试一试。它基于您的脚本与此脚本位于同一目录中。
set theName to (choose from list {"testA", "testB", "testC"})
if theName is false then
display dialog "You clicked cancel to exit." with icon stop buttons {"Exit"} default button {"Exit"}
else
set theName to (item 1 of theName)
tell application "Finder"
set the_script_path to ((container of the (path to me)) as text) & theName & ".scpt"
set the_script to load script alias the_script_path
end tell
run script the_script
end if