C# 클래스 ConEmu.WinForms.ConEmuSession

A single session of the console emulator running a console process. Each console process execution in the control spawns a new console emulator and a new session.

When the console emulator starts, a console view appears in the control. The console process starts running in it immediately. When the console process terminates, the console emulator might or might not be closed, depending on the settings. After the console emulator closes, the control stops viewing the console, and this session ends.

파일 보기 프로젝트 열기: Maximus5/conemu-inside 1 사용 예제들

Private Properties

프로퍼티 타입 설명
BeginGuiMacro GuiMacroBuilder
Init_AnsiLog AnsiLog
Init_ConsoleProcessMonitoring void
Init_MakeConEmuCommandLine Microsoft.Build.Utilities.CommandLineBuilder
Init_MakeConEmuCommandLine_EmitConfigFile string
Init_MakeConEmuCommandLine_EmitConfigFile_EscapeEchoText string
Init_PayloadProcessMonitoring_WaitForExitCodeAsync Task
Init_StartConEmu System.Diagnostics.Process
Init_TempWorkingFolder System.IO.DirectoryInfo
Init_WireEvents void
KillConsoleProcessAsync Task
TerminateLifetime void
TryFireConsoleProcessExited void
WaitForConsoleEmulatorCloseAsync Task
WaitForConsoleProcessExitAsync Task

공개 메소드들

메소드 설명
Close ( ) : void

An alias for CloseConsoleEmulator.

CloseConsoleEmulator ( ) : void

Closes the console emulator window, and kills the console process if it's still running.

This also closes the running session, the control goes blank and ready for running a new session.

To just kill the console process, use KillConsoleProcessAsync. If ConEmuStartInfo.WhenConsoleProcessExits allows, the console emulator window might stay open after that.

ConEmuSession ( [ startinfo, [ hostcontext ) : System

Starts the session. Opens the emulator view in the control (HWND given in hostcontext) by starting the ConEmu child process and giving it that HWND; ConEmu then starts the child Console Process for the commandline given in startinfo and makes it run in the console emulator window.

ExecuteGuiMacroTextAsync ( [ macrotext ) : Task

Executes a ConEmu GUI Macro on the active console, see http://conemu.github.io/en/GuiMacro.html .

This function takes for formatted text of a GUI Macro; to format parameters correctly, better use the BeginGuiMacro and the macro builder.

ExecuteGuiMacroTextSync ( [ macrotext ) : GuiMacroResult

Executes a ConEmu GUI Macro on the active console, see http://conemu.github.io/en/GuiMacro.html , synchronously.

This function takes for formatted text of a GUI Macro; to format parameters correctly, better use the BeginGuiMacro and the macro builder.

GetConsoleProcessExitCode ( ) : int

Gets the exit code of the console process, if it has already exited. Throws an exception if it has not.

This state only changes on the main thread.

SendControlBreakAsync ( ) : Task

Sends the Control+Break signal to the console process, which will most likely abort it.

Unlike KillConsoleProcessAsync, this is a soft signal which might be processed by the console process for a graceful shutdown, or ignored altogether.

SendControlCAsync ( ) : Task

Sends the Control+C signal to the payload console process, which will most likely abort it.

Unlike KillConsoleProcessAsync, this is a soft signal which might be processed by the console process for a graceful shutdown, or ignored altogether.

WriteInputText ( [ text ) : Task

Writes text to the console input, as if it's been typed by user on the keyboard.

Whether this will be visible (=echoed) on screen is up to the running console process.

WriteOutputText ( [ text ) : Task

Writes text to the console output, as if the current running console process has written it to stdout.

Use with caution, as this might interfere with console process output in an unpredictable manner.

비공개 메소드들

메소드 설명
BeginGuiMacro ( [ sMacroName ) : GuiMacroBuilder
Init_AnsiLog ( [ startinfo ) : AnsiLog
Init_ConsoleProcessMonitoring ( ) : void

Watches for the status of the payload console process to fetch its exitcode when done and notify user of that.

Init_MakeConEmuCommandLine ( [ startinfo, [ hostcontext, [ ansilog, [ dirLocalTempRoot ) : CommandLineBuilder
Init_MakeConEmuCommandLine_EmitConfigFile ( [ dirForConfigFile, [ startinfo, [ hostcontext ) : string
Init_MakeConEmuCommandLine_EmitConfigFile_EscapeEchoText ( [ text ) : string

Applies escaping so that (1) it went as a single argument into the ConEmu's NextArg function; (2) its special chars were escaped according to the ConEmu's DoOutput function which implements this echo.

Init_PayloadProcessMonitoring_WaitForExitCodeAsync ( ) : Task

Async-loop retries for getting the root payload process to await its exit.

Init_StartConEmu ( [ startinfo, [ cmdl ) : Process
Init_TempWorkingFolder ( ) : DirectoryInfo
Init_WireEvents ( [ startinfo ) : void
KillConsoleProcessAsync ( ) : Task
TerminateLifetime ( ) : void
TryFireConsoleProcessExited ( int nConsoleProcessExitCode ) : void

Fires the payload exited event if it has not been fired yet.

WaitForConsoleEmulatorCloseAsync ( ) : Task
WaitForConsoleProcessExitAsync ( ) : Task

메소드 상세

Close() 공개 메소드

An alias for CloseConsoleEmulator.
public Close ( ) : void
리턴 void

CloseConsoleEmulator() 공개 메소드

Closes the console emulator window, and kills the console process if it's still running.

This also closes the running session, the control goes blank and ready for running a new session.

To just kill the console process, use KillConsoleProcessAsync. If ConEmuStartInfo.WhenConsoleProcessExits allows, the console emulator window might stay open after that.

public CloseConsoleEmulator ( ) : void
리턴 void

ConEmuSession() 공개 메소드

Starts the session. Opens the emulator view in the control (HWND given in hostcontext) by starting the ConEmu child process and giving it that HWND; ConEmu then starts the child Console Process for the commandline given in startinfo and makes it run in the console emulator window.
public ConEmuSession ( [ startinfo, [ hostcontext ) : System
startinfo [ User-defined startup parameters for the console process.
hostcontext [ Control-related parameters.
리턴 System

ExecuteGuiMacroTextAsync() 공개 메소드

Executes a ConEmu GUI Macro on the active console, see http://conemu.github.io/en/GuiMacro.html .

This function takes for formatted text of a GUI Macro; to format parameters correctly, better use the BeginGuiMacro and the macro builder.

public ExecuteGuiMacroTextAsync ( [ macrotext ) : Task
macrotext [ The full macro command, see http://conemu.github.io/en/GuiMacro.html .
리턴 Task

ExecuteGuiMacroTextSync() 공개 메소드

Executes a ConEmu GUI Macro on the active console, see http://conemu.github.io/en/GuiMacro.html , synchronously.

This function takes for formatted text of a GUI Macro; to format parameters correctly, better use the BeginGuiMacro and the macro builder.

public ExecuteGuiMacroTextSync ( [ macrotext ) : GuiMacroResult
macrotext [ The full macro command, see http://conemu.github.io/en/GuiMacro.html .
리턴 GuiMacroResult

GetConsoleProcessExitCode() 공개 메소드

Gets the exit code of the console process, if it has already exited. Throws an exception if it has not.

This state only changes on the main thread.

public GetConsoleProcessExitCode ( ) : int
리턴 int

SendControlBreakAsync() 공개 메소드

Sends the Control+Break signal to the console process, which will most likely abort it.

Unlike KillConsoleProcessAsync, this is a soft signal which might be processed by the console process for a graceful shutdown, or ignored altogether.

public SendControlBreakAsync ( ) : Task
리턴 Task

SendControlCAsync() 공개 메소드

Sends the Control+C signal to the payload console process, which will most likely abort it.

Unlike KillConsoleProcessAsync, this is a soft signal which might be processed by the console process for a graceful shutdown, or ignored altogether.

public SendControlCAsync ( ) : Task
리턴 Task

WriteInputText() 공개 메소드

Writes text to the console input, as if it's been typed by user on the keyboard.

Whether this will be visible (=echoed) on screen is up to the running console process.

public WriteInputText ( [ text ) : Task
text [
리턴 Task

WriteOutputText() 공개 메소드

Writes text to the console output, as if the current running console process has written it to stdout.

Use with caution, as this might interfere with console process output in an unpredictable manner.

public WriteOutputText ( [ text ) : Task
text [
리턴 Task