Beispiel #1
0
        public override void Execute(ExecutionContext context)
        {
            string target = m_ParamList[0].ValueAsString();

            CmdOpenApp.ProcessOutputDirective(ref target, context);
            string ID    = m_ParamList[1].ValueAsString();
            int    state = 0;          // 1 if THIS item is alternate

            try
            {
                RegistryKey alternation = Registry.CurrentUser.CreateSubKey(@"Software\SAW\Alternation");
                state = (int)alternation.GetValue(ID, 0);
                alternation.SetValue(ID, 1 - state);                 // store other state for next time
            }
            catch (Exception e)
            {
                context.View.OnError(Strings.Item("Script_Fail_Alternation").Replace("%0", e.Message));
            }
            Debug.Assert(state == 0 || state == 1);
            string param = m_ParamList[2 + state].ValueAsString();

            try
            {
                Process.Start(target, param);
            }
            catch (Exception e)
            { context.View.OnError(e.Message); }
        }
Beispiel #2
0
        public override void Execute(ExecutionContext context)
        {
            string target = m_ParamList[0].ValueAsString();

            CmdOpenApp.ProcessOutputDirective(ref target, context);
            string param = m_ParamList[1].ValueAsString();

            try
            {
                Process.Start(target, param);
            }
            catch (Exception e)
            { context.View.OnError(e.Message); }
        }
Beispiel #3
0
 public override void Execute(ExecutionContext context)
 {
     try
     {
         string file = m_ParamList[0].ValueAsString();
         CmdOpenApp.ProcessOutputDirective(ref file, context);
         Desktop desktop = Desktop.LoadFrom(file);
         desktop.OpenApplications();
     }
     catch (Exception e)
     {
         context.View.OnError(Strings.Item("Script_Fail_Desktop").Replace("%0", e.Message));
     }
 }
Beispiel #4
0
        public override void Execute(ExecutionContext context)
        {
            context.View.PreviousSelectionSet = Globals.Root.CurrentDocument.Filename;                     // doesn't matter if not defined - PreviousSelectionSet null or empty just means that previous cannot work
            string target = m_ParamList[0].ValueAsString();

            CmdOpenApp.ProcessOutputDirective(ref target, context);
            TidyFilename(ref target, new[] { Document.StandardExtension, Document.SAW6Extension });
            if (!System.IO.File.Exists(target))
            {
                context.View.OnFail("open selection set file not found: " + target);
            }
            else
            {
                context.Terminate = true;
                Globals.QueueDelayedAction(() => Globals.Root.OpenFile(target, true, true));
            }
        }
Beispiel #5
0
        public override void Execute(ExecutionContext context)
        {
            string application = m_ParamList[0].ValueAsString().ToLower();

            CmdOpenApp.ProcessOutputDirective(ref application, context);

            int    processID = Desktop.GetProcessID(application);
            string errorMessage;
            IntPtr hwnd = Desktop.FindWindowForProcess(new IntPtr(processID), out errorMessage);

            if (!hwnd.IsZero())
            {
                Windows.SetWindowPos(hwnd, 0, GetParamAsInt(1), GetParamAsInt(2), 0, 0, Windows.SWP_NOSIZE | Windows.SWP_NOZORDER | Windows.SWP_ASYNCWINDOWPOS);
            }
            else if (!string.IsNullOrEmpty(errorMessage))
            {
                context.View.OnError(errorMessage);
            }
        }
Beispiel #6
0
        public override void Execute(ExecutionContext context)
        {
            string application = m_ParamList[0].ValueAsString().ToLower();

            CmdOpenApp.ProcessOutputDirective(ref application, context);
            // it looks like this should work, without all the P/Invoke stuff.  But it doesn't seem to
            // (it doesn't access some processes.  And the SetForegroundWindow seems to do nothing on the rest
            //foreach (var process in Process.GetProcesses())
            //{
            //	try
            //	{
            //		string filename = process.MainModule.FileName;
            //		Debug.WriteLine("Checking: " + filename);
            //		if (filename.ToLower().Contains(application))
            //		{
            //			SetForegroundWindow(process.MainWindowHandle);
            //			Debug.WriteLine("found");
            //			return;
            //		}
            //	}
            //	catch  // there will be errors for processes we cannot access
            //	{ }

            //}
            //Debug.WriteLine("Process not found for " + application);

            int    processID = Desktop.GetProcessID(application);
            string errorMessage;
            IntPtr hwnd = Desktop.FindWindowForProcess(new IntPtr(processID), out errorMessage);

            if (!hwnd.IsZero())
            {
                Windows.SetForegroundWindow(hwnd);
            }
            else if (!string.IsNullOrEmpty(errorMessage))
            {
                context.View.OnError(errorMessage);
            }
        }