Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Add option to right click menu of stay open applescript

I have a stay open applescript application and it calls my idle handler correctly. If I right-click the running application in the dock it shows the standard options (eg. Hide, Quit, etc.). Is there a way to add my own options to this menu?


Thanks

MacBook Pro with Retina display, OS X Mavericks (10.9.5)

Posted on Sep 23, 2014 5:49 AM

Reply
3 replies

Mar 4, 2015 9:50 AM in response to tfili

I have scoured the internet to figure this out and had now luck. I have found a workaround by using the quit handler. This makes it so when you try and quit the "on idle" app you get a menu that can lead you to other options instead of quitting.


**** This is my first post, and I don't know how to post script. If someone tells me I'll make this show correctly.*****




on quit

display dialog "Do you want to delay instead?" buttons {"Yes", "No"} default button {"No"} giving up after 10

if result = {button returned:"Yes", gave up:false} then


GoToDelay()

else

continue quit

end if

end quit



on GoToDelay()

display dialog "How long do you want to delay for?" buttons {"5 Minutes", "10 Minutes", "15 Minutes"} giving up after 7 with title "VPN Application Delay Options."

if result = {button returned:"5 Minutes", gave up:false} then

set delay_time to 5 * 60

else if result = {button returned:"10 Minutes", gave up:false} then

set delay_time to 10 * 60

else

display dialog "Delay Canceled" giving up after 7 buttons {"Ok"} with title "VPN Application Delay Options"

set delay_time to 10

end if

end GoToDelay

Mar 4, 2015 1:27 PM in response to Trail-Traveler

Before you post code, click on the blue text Use advanced editor in the upper right corner of this editor. Your AppleScript will be skewed off the page as yours has done above. Select all of this code, and then from the Style menu, choose paragraph. The code, however unstructured, will now be entirely visible in your post.


The >> symbol next to the Smiley in the toolbar, also offers alternate ways to post code without the truncation problem. There is no prebuilt style for AppleScript though.

Mar 4, 2015 10:30 PM in response to tfili

tfili wrote:


I have a stay open applescript application and it calls my idle handler correctly. If I right-click the running application in the dock it shows the standard options (eg. Hide, Quit, etc.). Is there a way to add my own options to this menu?


Thanks





I have scoured the internet to figure this out and had now luck. I have found a workaround by using the quit handler. This makes it so when you try and quit the "on idle" app you get a menu that can lead you to other options instead of quitting.



on quit

display dialog "Do you want to delay instead?" buttons {"Yes", "No"} default button {"No"} giving up after 10

if result = {button returned:"Yes", gave up:false} then


GoToDelay()

else

continue quit

end if

end quit



on GoToDelay()

display dialog "How long do you want to delay for?" buttons {"5 Minutes", "10 Minutes", "15 Minutes"} giving up after 7 with title "VPN Application Delay Options."

if result = {button returned:"5 Minutes", gave up:false} then

set delay_time to 5 * 60

else if result = {button returned:"10 Minutes", gave up:false} then

set delay_time to 10 * 60

else

display dialog "Delay Canceled" giving up after 7 buttons {"Ok"} with title "VPN Application Delay Options"

set delay_time to 10

end if

end GoToDelay

Add option to right click menu of stay open applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.