【问题标题】:Applescript color code from choose colorApplescript 颜色代码从选择颜色
【发布时间】:2016-11-28 19:11:50
【问题描述】:
set colorcode to (choose color)
set password1 to text returned of (display dialog "Write the colorcode " & colorcode & " down below" default answer "" buttons {"continue", "cancel"} default button 1 cancel button 2)
if colorcode is password1 then
    display dialog "correct" buttons {"1", "2"}
else
    display dialog "false" buttons {"1", "2"}
end if
end

您可能会看到我尝试将“颜色代码”设置为“选择颜色”返回的颜色代码,然后您必须输入您选择的颜色的正确颜色代码,如果您这样做了正确地它会进入正确的对话框,否则它会进入错误的对话框,但它并没有真正工作xD。如您所见,我不是英语,所以请原谅我的任何语法错误。 已经提前谢谢了,Jort。

【问题讨论】:

    标签: colors applescript color-codes


    【解决方案1】:

    首先:choose color 处理程序返回一个 列表,其中包含从 0 到 65535 的三个整数值。这三个列表项分别代表红色、绿色和蓝色值。

    第二:来自display dialog的text returned是一种字符串。

    您需要将列表强制转换为字符串以将其与返回的文本进行比较:

    set colorcode to (choose color)
    set password1 to text returned of (display dialog "Write the colorcode " & colorcode & " down below" default answer "" buttons {"continue", "cancel"} default button 1 cancel button 2)
    if (colorcode as text) is password1 then
        display dialog "correct" buttons {"1", "2"}
    else
        display dialog "false" buttons {"1", "2"}
    end if
    

    祝你有美好的一天!迈克尔/汉堡

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-12
      • 1970-01-01
      • 2015-08-15
      • 2013-05-24
      • 2011-12-29
      相关资源
      最近更新 更多