If you can think of something that a language would normally have applescript does not have it
— mc²than (@parrotgeek1) February 23, 2020
できると思うんだけどなー、と思って30分ぐらいでできました。全部同じtitleのボタンを複数作って、押されたボタンを左側から1はじまりでIDで返すAppleScriptです。
できたところで誰が褒めてくれるわけでもありませんが、できるものをできないというのは、、、、。
そもそも、同じtitleのボタンを複数出すのはGUI的にナンセンスな上に、Xcode上でAppleScriptアプリケーション作れば普通に作れるわけで、、、、
AppleScript名:display dialogで押されたボタンをIDで返す(1はじまり).scptd |
— – Created by: Takaaki Naganoya – Created on: 2020/02/23 — – Copyright © 2020 Piyomaru Software, All Rights Reserved — use AppleScript version "2.4" — Yosemite (10.10) or later use framework "Foundation" use framework "AppKit" use scripting additions property NSAlert : a reference to current application’s NSAlert property NSRunningApplication : a reference to current application’s NSRunningApplication property theResult : 0 property returnCode : 0 property theDataSource : {} display dialog "TEST" buttons {"OK", "OK", "OK", "OK", "OK", "OK", "OK"} on display dialog aString as string buttons buttonList as list set paramObj to {myMessage:aString, myButtonList:buttonList} –my dispAlert:paramObj –for debug my performSelectorOnMainThread:"dispAlert:" withObject:(paramObj) waitUntilDone:true return {button returned:my theResult} end display dialog on dispAlert:paramObj set aMainMes to (myMessage of paramObj) as string set bList to (myButtonList of paramObj) as list set bLen to length of bList — set up alert set theAlert to NSAlert’s alloc()’s init() tell theAlert its setMessageText:aMainMes repeat with i in bList (its addButtonWithTitle:i) end repeat end tell — show alert in modal loop NSRunningApplication’s currentApplication()’s activateWithOptions:0 my performSelectorOnMainThread:"doModal:" withObject:(theAlert) waitUntilDone:true set aBID to bLen – ((my returnCode) – 1000 + 1) + 1 set my theResult to aBID end dispAlert: on doModal:aParam set (my returnCode) to aParam’s runModal() end doModal: |
More from my site
(Visited 188 times, 2 visits today)