osascript script to get answer and buttons of display dialog
1
vote
1
answer
912
views
I'm creating a cool script to bother me by asking to close some distracting apps that I open without realising. For that, I do this:
MINUTES_UNTIL_ASK_TO_CLOSE=
osascript -e 'set T to text returned of (display dialog "Do you really want to use this app?" default answer "1" with icon caution buttons {"Close to better Focus or Relax", "Remember again after minutes..."} default button "Remember again after minutes...")'
It gets the text entered in the input (the number of minutes till remember again to close). The problem is that I'm not being able to find how to **get the button that has been pressed**.
I found the following beautiful code in another answer in this platform :
set theResultReturned to (display dialog "hallo" buttons {"h", "a"} default button "a" default answer "")
set theTextReturned to the text returned of theResultReturned
set theButtonReturned to the button returned of theResultReturned
But I'm failing to get the variable to know which button has been pressed:
BUTTON_PRESSED=`osascript -e '... ??
Asked by chelder
(227 rep)
Apr 5, 2023, 05:37 PM
Last activity: Apr 6, 2023, 11:00 AM
Last activity: Apr 6, 2023, 11:00 AM