Community Forums Archive

Go Back

Subject: Stop annoying window change?
Posted by: Kit
Date: 6/29/2014 4:38:43 AM

The following code works but every other time Sound Forge (version 10) decides to cascade the current window rather than leaving it as it is (maximized). Is there anything in the code to cause this behaviour and is there a way to stop it? Thanks.

using System;
using System.Windows.Forms;
using System.IO;
using SoundForge;

public class EntryPoint {
public void Begin(IScriptableApp app) {

ISfFileHost openFile = app.CurrentFile;

if (app.CurrentFile == null)
MessageBox.Show("Open a file to paste into","Paste Aborted!");

//create undo wrapper: just one undo for whole operation
string szUndo = "Import Files From List";
int idUndo = openFile.BeginUndo(szUndo);

ISfDataWnd wnd = app.ActiveWindow;
long currentPos = wnd.Cursor;
long startingPos = wnd.Cursor;

string Path = @"D:\Sony Sound Forge\importList.txt";
if (File.Exists(Path))
string line;

// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader(Path);
while((line = file.ReadLine()) != null)
string strPaste = line;
//MessageBox.Show(strPaste,"File Names");
ISfFileHost fileToPasteFrom = app.OpenFile(strPaste, false, false);

long mPos = fileToPasteFrom.Length;
openFile.ReplaceAudio(new SfAudioSelection(currentPos, 0), fileToPasteFrom, new SfAudioSelection(fileToPasteFrom));
currentPos = currentPos + mPos;

wnd.SetCursorAndScroll(startingPos, DataWndScrollTo.Center);

MessageBox.Show("No File Selected","Paste Aborted!");

//close undo wrapper and keep changes
openFile.EndUndo(idUndo, false);


public void FromSoundForge(IScriptableApp app) {

ForgeApp = app; //execution begins here
app.SetStatusText(String.Format("Script '{0}' is running.", Script.Name));
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)); }

} //EntryPoint

Go Back