如何在Apple Script上创建链接按钮? [英] How do I create a link button on Apple Script?

查看:105
本文介绍了如何在Apple Script上创建链接按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个脚本,该脚本将打开一个带有按钮列表的对话框,当我单击它们时,它们具有不同的链接.有人知道applescript是否具有该功能吗?如果不是,那么我能对可能发生的事情有任何见解吗?

I wanted to create a script that would open up a dialog box with a list of buttons, that have different links when I click on them. Does anyone know if applescript has that capability? If not then can I get any insights on something that would?

一个例子是这样的:
打开脚本
Button1-> Google.com
Button2-> Aol.com
Button3-> Yahoo.com

An example is sort of like this:
Open up script
Button1 -> Google.com
Button2 -> Aol.com
Button3 -> Yahoo.com

推荐答案

是的,有choose from list命令.尝试以下脚本,只需确保两个列表中的链接和标签的顺序一致即可:

Yes, there is the choose from list command. Try following script, just make sure the links and labels in the two lists are in corresponding order:

set listWithLinks to {"google.com", "aol.com", "yahoo.com"}
set listWithLabels to {"Google", "AOL", "Yahoo"}

set dialogTitle to "Select & Go…"
set buttonOK to "Go"
set buttonCancel to "Cancel"

set choosedLabels to choose from list (listWithLabels as list) with title dialogTitle OK button name buttonOK cancel button name buttonCancel with multiple selections allowed
if false is choosedLabels then return

repeat with i from 1 to number of items in choosedLabels
    set choosedLabel to item i of choosedLabels

    repeat with i from 1 to number of items in listWithLabels
        set lookupLabel to item i of listWithLabels
        if choosedLabel is lookupLabel then
            set link to item i of listWithLinks
            open location "http://www." & link
        end if
    end repeat

end repeat

这篇关于如何在Apple Script上创建链接按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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