![]() ![]() this will work just fine.Īnother issue you might run into is that osascript may throw an exception if your script is launched as root. To avoid the permission request, just use tell me to display alert. Not only this annoys the user with a new permission request, but it also looks kinda dumb since the dialogue is asking the user to allow "MyApp" to control "MyApp" and if the user denies it, your script will fail. you will be promoting the user to give your app permissions to control itself, at least starting since Catalina. Notably, if you run your script with tell application "MyApp" to display alert. However, things have changed a bit on Mac OS since. May or may not solve this answer is a perfect solution when your script is controlled by another application. However, if I do what I described above - have my script do all its stuff, but have it tell the app in question to display the alert (and only that as described above), then the alert has the icon of the app in question, but the script still does its stuff independently of the app outside of that alert. If I tell System Events or the script itself to do all that then it can quit and reopen the app independently of the app, but the alert has the generic icon of itself or the System Events icon. In my case, ideally the icon of the alert would be the icon of the app I'm restarting, but I can't tell the app itself to display the alert and then restart because the script loses connection with the app when it quits and it kills the running of the script. In my case I want alert because I want that extra message parameter (but this works for notification as well). display notification - no custom icon but has other features as desired by this question's poster. display alert - no custom icon but has other desired features, in my case the message parameter which adds extra smaller explanatory text below the primary text.ģ. display dialog - has the option to provide a custom icon but lacks features of the other two options.Ģ. However, let's say I just wanted to provide a notification as per this question.ġ. I'm writing a script that quits and re-opens another application after confirmation from the user. My specific case in detail if interested (but doesn't particularly add to the solution above, just covers how I got there): Admittedly that's a bit of a kludge, but depending on how badly you want this, it's an option - though not one I'll expand on here. If your icon isn't the icon for an app, then I believe there are ways to create an empty app with whatever icon you like, which can behave this way. The notification will have My App's icon, the result of the notification if any will be returned to the rest of the script and then your script will continue on inside whatever other tell statement or context its in. In the middle of all of that you can have a single line that says: tell application "MyApp" to display notification. Your script can do whatever it needs to do to whatever other apps, or System Events, or itself (if your script is saved as its own application), or whatever else. If the icon in question belongs to an app, you can tell that app to display the notification, regardless of whatever else your script is doing. ![]() ![]() It may or may not be a solution to this question. ![]() Needless to say, this question and answer, inspired my solution - a "duh" moment for me once I realized it. I don't really understand why that is when it would be simple to make them consistent. It seems odd that only the first has the option to add a custom icon. notification but the problem is the same because display alert doesn't have a custom icon option.Īs noted in the other answer here, AppleScript has at least three interactive message type commands: display dialog, display alert, display notification, and probably others. Noted this question was three years ago, but I stumbled across this looking for a solution to a similar problem. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |