Created
March 23, 2015 18:58
-
-
Save hasokeric/e9230a53a8a9b280b465 to your computer and use it in GitHub Desktop.
EpiConsole shows a Command Prompt Window for Debugging purposes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static class EpiConsole | |
{ | |
public static void Start() | |
{ | |
IntPtr hw = GetConsoleWindow(); | |
if (hw == IntPtr.Zero) AllocConsole(); | |
Console.Clear(); | |
ShowWindow(hw, 8); | |
Debug.Listeners.Clear(); | |
TextWriterTraceListener writer = new TextWriterTraceListener(System.Console.Out); | |
Debug.Listeners.Add(writer); | |
} | |
public static void Close() | |
{ | |
IntPtr hw = GetConsoleWindow(); | |
if (hw != IntPtr.Zero) ShowWindow(hw, 0); | |
} | |
[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)] | |
internal static extern int AllocConsole(); | |
[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)] | |
internal static extern int FreeConsole(); | |
[System.Runtime.InteropServices.DllImport("kernel32.dll")] | |
private static extern IntPtr GetConsoleWindow(); | |
[System.Runtime.InteropServices.DllImport("user32.dll")] | |
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @tdcbm you should be able just to call EpiConsole.Start(); and put the class above your class Script {}