AppleScript:如何返回上一个对话框/列表? [英] AppleScript: How to return to previous dialog/list?

查看:171
本文介绍了AppleScript:如何返回上一个对话框/列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个相当基本的问题,但是我没有AppleScript经验.

A fairly basic problem here, but I have no AppleScript experience.

制作一个包含多个选择以及if/then条件的列表.选择一个显示带有一个按钮的对话框,该对话框会将您带回到列表.我知道AppleScript中没有上线"功能,那么做到这一点的最佳方法是什么?

Made a list with multiple selections and if/then conditions. Made a selection to display a dialog with one button that takes you back to the list. I know theres no "go to line" in AppleScript, so what would be the best way to do this?

我想要的本质:

set A to "smb://XXX"
set B to "smb://XXX"
set servers to {"A", "B"}

set chosen to (choose from list servers with title "Servers" with prompt "Connect to:" OK button name "Connect" cancel button name "Abort" with multiple selections allowed) as text

try
if (text of chosen) is "A" then
    mount volume (A as string)
end if

if (text of chosen) is "B" then
        beep
        display dialog "Not available yet" as text with icon stop with title "Error" buttons {"Back"} default button 1

如何返回此处的列表? 我无法重写从列表中选择".有

How do I go back to the list here? I cant rewrite the "choose from list". Is there a

if result = {button returned:"Back"} then

这样做的方式?

推荐答案

我相信这是您所追求的.我尝试不对您的原始代码进行太多修改,但是我认为您可以在其中进行一些改进.例如,您允许多个选择,但是如果他们同时选择A和A,则无法进行任何处理. B.

I believe this is what you're after. I tried not to modify your original code much, but I think there are some things you could improve in it. For example you're allowing multiple selections, but you don't have a way of handling if they select both A & B.

on run
    chooseServer()
end run

on chooseServer()
    set A to "smb://XXX"
    set B to "smb://XXX"
    set servers to {"A", "B"}

    set chosen to (choose from list servers with title "Servers" with prompt "Connect to:" OK button name "Connect" cancel button name "Abort" with multiple selections allowed) as text

    if (text of chosen) is "A" then
        try
            mount volume (A as string)
        on error e
            display dialog e giving up after 5
        end try
    else if (text of chosen) is "B" then
        beep
        if button returned of (display dialog "Not available yet" as text with icon stop with title "Error" buttons {"Back"} default button 1) = "Back" then
            chooseServer() -- recursive call
        end if
    end if
end chooseServer

这篇关于AppleScript:如何返回上一个对话框/列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆