Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Asu

macrumors member
Original poster
Apr 28, 2006
69
7
I have another question regarding these dialogs: Is there a way to display the countdown of seconds in the dialog display?

Thanks

Asu
 

Red Menace

macrumors 6502a
May 29, 2011
583
230
Colorado, USA
To do any kind of custom UI stuff, you would need to use something like AppleScriptObjC to access the Cocoa API - regular AppleScript doesn't have any dialog customizations available, although you could perform a hack such as repeatedly showing a dialog that times out, for example:

Code:
set countdown to 20
set interval to 2

repeat with timer from countdown to 1 by -interval
    if timer ≤ interval then set interval to timer
    set theResult to display dialog "Should I do something?" & return & timer & " seconds left" buttons ¬
        {"Yes", "No", "Maybe"} default button "Yes" with icon caution giving up after interval
    if (button returned of theResult) is "Yes" then
        say "Yes"
        exit repeat
    else if (button returned of theResult) is "Maybe" then
        say "Maybe"
    else if timer ≤ interval or (button returned of theResult) is "No" then
        say "No"
        exit repeat
    end if
end repeat
 

Asu

macrumors member
Original poster
Apr 28, 2006
69
7
To do any kind of custom UI stuff, you would need to use something like AppleScriptObjC to access the Cocoa API - regular AppleScript doesn't have any dialog customizations available, although you could perform a hack such as repeatedly showing a dialog that times out, for example:

Code:
set countdown to 20
set interval to 2

repeat with timer from countdown to 1 by -interval
    if timer ≤ interval then set interval to timer
    set theResult to display dialog "Should I do something?" & return & timer & " seconds left" buttons ¬
        {"Yes", "No", "Maybe"} default button "Yes" with icon caution giving up after interval
    if (button returned of theResult) is "Yes" then
        say "Yes"
        exit repeat
    else if (button returned of theResult) is "Maybe" then
        say "Maybe"
    else if timer ≤ interval or (button returned of theResult) is "No" then
        say "No"
        exit repeat
    end if
end repeat
[doublepost=1479013747][/doublepost]Wow this is really clever, thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.