HomeAppleterminal - osascript script to get reply and buttons of show dialog

terminal – osascript script to get reply and buttons of show dialog


You could wish to attempt one thing like this primary command in Terminal

DIALOG_RESULTS=`osascript -e 'set {T,B} to {textual content returned, button returned} of (show dialog "Do you actually wish to use this app?" default reply "1" with icon warning buttons {"Shut to higher Focus or Calm down", "Keep in mind once more after minutes..."} default button 2)'` ;BUTTON_RETURNED="$(echo "$DIALOG_RESULTS" |minimize -d "," -f2 |minimize -c 2-)" ;MINUTES_UNTIL_ASK_TO_CLOSE="$(echo "$DIALOG_RESULTS" |minimize -d "," -f1)"

Then

echo "$MINUTES_UNTIL_ASK_TO_CLOSE" …Returns the minutes

echo "$BUTTON_RETURNED" …Returns the button


SIDE-NOTE: This following code will return each textual content and buttons returned, on the identical line.

osascript -e '(show dialog "Do you actually wish to use this app?" default reply "1" with icon warning buttons {"Shut to higher Focus or Calm down", "Keep in mind once more after minutes..."} default button 2)'

OR: This following code will return each textual content and buttons returned, to the variable DIALOG_RESULTS .

DIALOG_RESULTS="$(osascript -e 'set {T,B} to {textual content returned, button returned} of (show dialog "Do you actually wish to use this app?" default reply "1" with icon warning buttons {"Shut to higher Focus or Calm down", "Keep in mind once more after minutes..."} default button 2)' -e 'return T & "t" & B')"

Then this shops the minutes to the variable MINUTES_UNTIL_ASK_TO_CLOSE

MINUTES_UNTIL_ASK_TO_CLOSE="$(echo "$DIALOG_RESULTS" |minimize -f 1)"

Then this shops the button returned to the variable BUTTON_RETURNED

BUTTON_RETURNED="$(echo "$DIALOG_RESULTS" |minimize -f 2)"

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments