普通彈出框
形式:display dialog 標(biāo)題名 buttons 按鈕標(biāo)題列表 default button 按鈕或序號
點(diǎn)擊按鈕后,返回值是record類型,格式如:{"button returned":"xxxx"}
獲取返回值 :get the result
獲取返回值中的字符串:the button returned of the result
彈出框會阻塞程序運(yùn)行,可根據(jù)返回值決定下一步操作
舉例:
set titleStr to "測試dialog"
set btns to {"按鈕1", "按鈕2", "按鈕3"}
display dialog titleStr buttons btns default button 1 --默認(rèn)選擇第1個按鈕(按return時就會讓彈出框消失)
get the button returned of the result -- 彈出框
帶文本輸入的彈出框
形式:
display dialog 標(biāo)題名 buttons 按鈕標(biāo)題列表 default button 按鈕或序號 default answer 默認(rèn)文本
返回值也是record類型,格式:{button returned:"xxx", text returned:"xxx"}
舉例
set titleStr to "測試文本輸入框"
set btns to {"button1", "button2", "button3"}
display dialog titleStr buttons btns default button 1 default answer "這是默認(rèn)文本"
set returnRecord to the result --獲取返回的record類型的值
get the text returned of returnRecord -- 獲取輸入的文本