# "Saving As" from within an external application

**URL:** <https://forum.xojo.com/t/saving-as-from-within-an-external-application/70658>\
**Category:** macOS\
**Created:** [June 9, 2022, 10:05am UTC](https://forum.xojo.com/t/saving-as-from-within-an-external-application/70658 "2022-06-09T10:05:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Luc\_ARNAUD](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-luc_arnaud/32/15186_2.png) [@Jean-Luc\_ARNAUD](https://forum.xojo.com/u/Jean-Luc_ARNAUD)\
**Post date:** [June 9, 2022, 10:05am UTC](https://forum.xojo.com/t/saving-as-from-within-an-external-application/70658/1 "2022-06-09T10:05:36Z")

</div>

Hi all,

Working on a “delayed Shutdown/sleep” project for Mac, I’m encountering this problem:

When sending “Term” signal via a Shell command, some apps automatically save modified documents, some do not. I’d like to “Save as” all opened documents in launched applications, without using Apple Events nor Applescript script, because of the NSAppleEventsUsageDescription needed in recent OS versions.

Questions:

- Is there a way, using Xojo code, MBS plugins or Framework calls, to do this?
- Is it possible to know what app will “autosaves” its document(s), what app will not ?

At the moment, I’m able to get active apps list, their process name and PID.

TIA for any suggestion or help.

Jean-Luc

---

<div class="post-metadata">

**Author:** ![Arnaud\_N](https://forum.xojo.com/user_avatar/forum.xojo.com/arnaud_n/32/21824_2.png) [@Arnaud\_N](https://forum.xojo.com/u/Arnaud_N)\
**Post date:** [June 9, 2022, 10:44am UTC](https://forum.xojo.com/t/saving-as-from-within-an-external-application/70658/2 "2022-06-09T10:44:30Z")

</div>

Hi Jean-Luc,

I’m afraid AppleEvents is the only way. Even ProcesMBS.Quit sends one behind the hood. I hope to be wrong, but I’m not aware I am, here.

The apps which save automatically are those who implement the restore feature included in Mac OS 11 (IIRC). Most Apple apps do and others are encouraged by Apple to do so. They are the ones which also won’t ask you whether to save changes when you quit the app (because they automatically save).

Why is using the NSAppleEventsUsageDescription a problem in your case?

HTH

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [June 9, 2022, 10:46am UTC](https://forum.xojo.com/t/saving-as-from-within-an-external-application/70658/3 "2022-06-09T10:46:25Z")

</div>

> [@Arnaud\_N](#):
>
> Why is using the NSAppleEventsUsageDescription a problem in your case?

Because he would have to show the §$%& dialog for every app he wants to quit.

---

<div class="post-metadata">

**Author:** ![Arnaud\_N](https://forum.xojo.com/user_avatar/forum.xojo.com/arnaud_n/32/21824_2.png) [@Arnaud\_N](https://forum.xojo.com/u/Arnaud_N)\
**Post date:** [June 9, 2022, 10:50am UTC](https://forum.xojo.com/t/saving-as-from-within-an-external-application/70658/4 "2022-06-09T10:50:08Z")

</div>

Yes, I agree that this is an unwanted behaviour. However, I don’t expect you can do everything the same way you used to do in earlier versions of the OS with always avoiding those annoying dialogs/“security measures”, sadly.

---

<div class="post-metadata">

**Author:** ![Jean-Luc\_ARNAUD](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-luc_arnaud/32/15186_2.png) [@Jean-Luc\_ARNAUD](https://forum.xojo.com/u/Jean-Luc_ARNAUD)\
**Post date:** [June 10, 2022, 2:32pm UTC](https://forum.xojo.com/t/saving-as-from-within-an-external-application/70658/5 "2022-06-10T14:32:00Z")

</div>

As Beatrix wrote, I would have to validate the dialog, whereas my goal is to put the Mac down or in sleeping mode in the middle of the night, after a long calculation, while I am sleeping!  
Thanks for your reply.

---

<div class="post-metadata">

**Author:** ![Jean-Luc\_ARNAUD](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-luc_arnaud/32/15186_2.png) [@Jean-Luc\_ARNAUD](https://forum.xojo.com/u/Jean-Luc_ARNAUD)\
**Post date:** [June 10, 2022, 2:32pm UTC](https://forum.xojo.com/t/saving-as-from-within-an-external-application/70658/6 "2022-06-10T14:32:56Z")

</div>

You’re absolutely right!  
Thanks for your reply.

---

<div class="post-metadata">

**Author:** ![Arnaud\_N](https://forum.xojo.com/user_avatar/forum.xojo.com/arnaud_n/32/21824_2.png) [@Arnaud\_N](https://forum.xojo.com/u/Arnaud_N)\
**Post date:** [June 10, 2022, 4:54pm UTC](https://forum.xojo.com/t/saving-as-from-within-an-external-application/70658/7 "2022-06-10T16:54:59Z")

</div>

The first time, yes. But once the OS knows your app has the rights, it normally won’t ask again.  
So you can instruct the OS to trust your app (e.g. by calling a dummy script) and then use the real script in the night.
