private void ExecuteLegacy(string asWhere, string asMacro) { try { if (m_ConEmuHandle == IntPtr.Zero) { return; } string cmdLine = " -GuiMacro"; if (string.IsNullOrEmpty(asWhere) == false) { cmdLine += ":" + asWhere; } else { cmdLine += " " + asMacro; } Environment.SetEnvironmentVariable("ConEmuMacroResult", null); m_fnConsoleMain3.Invoke(3, cmdLine); } catch (Exception error) { ExceptionMessageBox box = new ExceptionMessageBox(); box.SetException(error); box.ShowDialog(); } }
protected string ExecuteLegacy(string asWhere, string asMacro) { if (ConEmuCD == IntPtr.Zero) { throw new GuiMacroException("ConEmuCD was not loaded"); } if (fnConsoleMain3 == null) { throw new GuiMacroException("ConsoleMain3 function was not found"); } string cmdLine = " -GuiMacro"; if (!String.IsNullOrEmpty(asWhere)) { cmdLine += ":" + asWhere; } cmdLine += " " + asMacro; Environment.SetEnvironmentVariable("ConEmuMacroResult", null); string result; int iRc = fnConsoleMain3.Invoke(3, cmdLine); switch (iRc) { case 200: // CERR_CMDLINEEMPTY case 201: // CERR_CMDLINE throw new GuiMacroException("Bad command line was passed to ConEmuCD"); case 0: // This is expected case 133: // CERR_GUIMACRO_SUCCEEDED: not expected, but... result = Environment.GetEnvironmentVariable("ConEmuMacroResult"); if (result == null) { throw new GuiMacroException("ConEmuMacroResult was not set"); } break; case 134: // CERR_GUIMACRO_FAILED throw new GuiMacroException("GuiMacro execution failed"); default: throw new GuiMacroException(string.Format("Internal ConEmuCD error: {0}", iRc)); } return(result); }