Subject:Exiting SoundForge
Posted by: clmn
Date:1/4/2006 12:48:29 PM
Is is possible to have your script close out soundforge completly when its done executing or when they press a exit button ? Thanks |
Subject:RE: Exiting SoundForge
Reply by: _TJ
Date:1/4/2006 9:35:06 PM
Sorry, No. This is one of those seemingly simple things that is very hard to support in practice, so it just didn't make it in to this version of Sound Forge. tj |
Subject:RE: Exiting SoundForge
Reply by: clmn
Date:2/9/2006 1:49:33 PM
I just got Sound Forge to close itself after running a script, by adding the code below to the end of my script code: Process[ ] arrProcesses = Process.GetProcessesByName("Forge80"); if (arrProcesses.Length > 0) arrProcesses[0].Kill(); |
Subject:RE: Exiting SoundForge
Reply by: _TJ
Date:2/10/2006 12:01:00 PM
DO NOT DO THIS!!!!! This is very very bad!! Kill is a system level command used only to stop a process that is hung. After a Killing a process, the system is very likely to be in an unstable state. - Drivers left open, files partially written, etc. The process itself never gets a chance to shutdown and close things out. This is essentially the same thing as forcing the process to a crash. Use ProcessKill is only in situations where you intend to immediatelly turn off the computer and/or reboot. tj |
Subject:RE: Exiting SoundForge
Reply by: clmn
Date:2/22/2006 12:40:20 PM
How about if I use CloseMainWindow(); instead of the .kill() ? |
Subject:RE: Exiting SoundForge
Reply by: _TJ
Date:2/23/2006 4:50:38 PM
That's ok. Process.CloseMainWindow() will do an orderly shutdown. however, it will also stop and ask the user if they are sure if there are any unsaved files open, or processing operations in progress. I hadn't kown that this existed, and I hadn't expected this to work, but it seems to work just fine. Run this script, and it will shutdown Sound Forge without asking IF there are no unsaved files. If there are unsaved files, then Sound Forge will put up a dialog asking if you want to save. using System; using System.IO; using System.Windows.Forms; using SoundForge; using System.Diagnostics; public class EntryPoint { public void Begin(IScriptableApp app) { Process curr = Process.GetCurrentProcess(); curr.CloseMainWindow(); } public void FromSoundForge(IScriptableApp app) { ForgeApp = app; //execution begins here app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name)); Begin(app); app.SetStatusText(String.Format("Script '{0}' is done.", Script.Name)); } public static IScriptableApp ForgeApp = null; public static void DPF(string sz) { ForgeApp.OutputText(sz); } public static void DPF(string fmt, object o) { ForgeApp.OutputText(String.Format(fmt,o)); } public static void DPF(string fmt, object o, object o2) { ForgeApp.OutputText(String.Format(fmt,o,o2)); } public static void DPF(string fmt, object o, object o2, object o3) { ForgeApp.OutputText(String.Format(fmt,o,o2,o3)); } } //EntryPoint Thanks for bringing this to my attention! tj Message last edited on2/23/2006 4:51:31 PM by_TJ. |