Code Monkey home page Code Monkey logo

consolecontrol's People

Contributors

archangelwtf avatar dwmkerr avatar guardrails[bot] avatar iddesigns avatar joergpichler avatar justalemon avatar kriosym avatar webmaster442 avatar xuntar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

consolecontrol's Issues

Parse ANSI Color Codes

The app doesn't show ASCII colored text correctly, but it also doesn't remove the code resulting in unreadable text.

console_bug

Attach an existing process output to console control

Hi,

I'm developing a WPF application, and I would like to know If I can attach the console output of that application to the Console control.

For example I would like to open a new windo with a button and show in that window the consolecontrol with the Nlog output of the main application.

Regards

Franco

Input on incorrect position will crash the program.

string input = richTextBoxConsole.Text.Substring(inputStart, (richTextBoxConsole.SelectionStart) - inputStart);

Hi ,
This is a very good control tool. Thanks.
When I debugged it in winform.
If the cursor was not at the end of the consolecontrol, then any input would crash the program.
Maybe : (richTextBoxConsole.SelectionStart) - inputStart , should be checked firstly. the result should be larger than zero.

How to port your repo to be used in .NET 6 winforms or even .NET 7?

Hello:
I found your repo, it seems to be very good design when I used it with .NET 5 winforms, however, since .NET 5 is already out of support, it is better to migrate to .NET 6, or even .NET 7, I believe Microsoft may release .NET 7 soon, within a few days or even a few hours.
However, when I tried to port your code to .NET 6, I got very strange issue:

If I tried the following command to install NUGET package:
PM> Install-Package ConsoleControl -Version 1.3.0
I got warning like:
Warning NU1701 Package 'ConsoleControl 1.3.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.

If I just add reference to consolecontrol.dll in one C# WinForms project, when I open Forms Designer, and tried to add a new tab in toolbox, and choose items for toolbox, I can see the following message:
The following controls were successfully added to the toolbox but are not enabled in the active designer.
Even it seems not an error, but the result is: I can't see such item (custom control: consolecontrol) appear in toolbox, therefore, I can NOT drag and drop one onto Form1.

Let me know if you can change your repo, to make a new NUGET target .NET 6 or even .NET 7?
My IDE: Visual Studio 2022 (Version: 17.3.6), OS: Windows 10 Pro (21H2)
Thanks,

New nuget package?

Hi,
I can see you have updated this repo to target .NET 6 & 7, it is good.
However, in the readme file, I see you sugget to use nuget package:
NuGet\Install-Package ConsoleControl -Version 1.3.0
But I found that the package version 1.3.0 was released more than 3 years ago.
Is it possible to realsed a new version, like: 1.4.0?
Thanks,

Console is hang when many output message received async

i am using the consoleControl to get the file from the TortoiseSVN.

i ran "svn checkout $svnPath $workingFolder". there are more than 2k files. The ConsoleControl are freeze and does not display the output message but the actual action(svn checkout) are running in background.
i had tried if just few file eg:10 file , there are no issue.

Auto scroll not working after control loses focus

I am using this console for an output log but after clicking another control auto-scroll stops working as intended also Console.WriteOutput will insert anywhere the mouse is clicked. Not sure if this is intended but I would like to disable.

Thanks,
cazdev

Error in ConsoleControl.WPF + fix

Hello, I really appreciate your work and used it in WinForms for a few months. After I switched to WPF, i had the problem that if I used StartProcess(filename, arguments) my application always crashed. So I reviewed your code last night and found the problem in the class ConsoleControl.WPF/ConsoleControl.xaml.cs.

Inside your method public void StartProcess(ProcessStartInfo processStartInfo) you have the statement processInterface.StartProcess(processStartInfo);.

I had to change this statement to:
processInterface.StartProcess(processStartInfo.FileName, processStartInfo.Arguments);

After this change ConsoleControl run's fine in my WPF project without any errors.
So if anyone is still searching for a solution - here it is.

Best regards

ftp not working properly

Console ftp processor (ftp.exe) not working properly inside this control. There is no "ftp>" prompt shown and first submitted command react with "invalid command".

example

Is it possible to open Ubuntu subsystem?

Hey, same as in the title, do you know the way to open the Ubuntu subsystem, if it's been installed on my PC? I cannot find the proper process to type in Console.StartProcess and parameters.
Thanks for any help :)

Handling carriage return for programs that print updates in same place.

I have an app that runs FFMpeg to convert video/audio, FFMpeg prints status updates on top of themselves in cmd.exe (like "frame 9000" will be overwritten with "frame 9100" in the same place without a new line). When I send the output from the FFMpeg process to the consolecontrol it prints them after each other, so you get "frame 9000 frame 9100" etc. I tried scanning the output from FFMpeg for char(13) [carriage return] but it was not there, is there a way to accomplish the same output for this as a cmd.exe window?

How to use this control in my own IDE developed in vb.net

Hi,
I am using this ConsoleControl to make an IDE in vb.net. So far so good. But i can't start process with this control.
I am making IDE for a scripting language named AutoIt. this is the code for running script with autoit interpreter.
Hide Copy Code
Shell(Autoit_InterPreter_Path & """" & FilenamePath & """")
This is working ok. But in consolecontrol, How can i use ConsoleControl in my project.
I need the user to run the script in my IDE and can see the result and exit code in this console.

BackgroundWorker is busy even after IsProcessRunning is false

Hello,

So basically i'm looping over some array and for each item I want to start a new process and when it ends, carry on with the next one...

Here is the code (I'm calling this from another thread) the view.console object is ConsoleControl.WPF

foreach (string word in words)
{
	bool isRunning = view.console.Dispatcher.Invoke(() => view.console.IsProcessRunning);

	while (isRunning)
	{
		//Wait and query again after 250ms
		//Thread.Sleep(250);
		isRunning = view.console.Dispatcher.Invoke(() => view.console.IsProcessRunning);
	}

	view.console.Dispatcher.Invoke(new Action<string, string>(view.console.StartProcess), executablePath, cliArguments + word);
}

The only way I could get it to work is with that Thread.Sleep() in the while loop.

Am I doing something wrong, or is this a bug?
Btw, when I run the code in step-by-step in VS it works fine.

WPF control causes exception when process exits

When the processInterface_OnProcessExit event handler is called, it is not running on the UI thread, so accessing ShowDiagnostics fails. That block needs to be wrapped in a RunOnUIDispatcher() call.

WPF console app does not work

Great project! The WinForms version works fine, but the WPF version does not work (at least on Windows Server, which is where I am running it on). I am unable to type characters into the window / no input is accepted after starting the console connection.

Thoughts?

Unable to get ProcessId / or use WaitForExit()

I would like to start a new process directly after the first process completes, but I get an error "This BackgroundWorker is currently busy and cannot run multiple tasks concurrently"

I assume it is due to the first process still being active, but I have no means to check if it is active or wait for the process to complete.

Please assist :)

Support Scroll to Bottom

(NB Thanks VisualG at CodeProject, see http://www.codeproject.com/Articles/335909/Embedding-a-Console-in-a-C-Application?msg=4642047#xx4642047xx)

This responce is a little late i know, but there are probably more people that want to know how to do this.

if u want the richtextbox to auto scroll down when text is appended u can use this code

[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr window, int message, int wparam, int lparam);

private const int SbBottom = 0x7;
private const int WmVscroll = 0x115;


//call this in a method after appending text in the richtextbox
//dont forget to change richtextbox1 with youre richtextboxcontrol

SendMessage(richtextbox1.Handle, WmVscroll, SbBottom, 0x0);

WPF Console Sample Does Not Work

CommandConsole

The WinForms sample works as intended, however, the WPF sample does not work (Windows 10 Pro 1909). I am able to type into the console window, and upon pressing the start command console button, the output of the command prompt does show up in the application, however, after that, entering commands does not work (after clicking enter, it just goes to a new line) and no new output shows up.

Unable to render UTF-8 characters

UTF-8 characters are not recognized.

Reproduce issue:

  • Navigate using ConsoleControl to a folder with files, which their names contain UTF-8 (other than english characters, e.g. Russian, Greek, etc) and execute a dir command.
  • Do the same under the regular CMD.exe

ConsoleControl:
cc1

CMD.exe:
cc2

WPF Sample doesn't work

Excellent Windows Forms Sample, but WPF Sample doesn't work on my computer Win7 SP1 x64.

Best Regards

"Could not load file or assembly 'ConsoleControlAPI, Version=1.2.0.0" in WinForms App.

I get this error message, both trying to add to form using the designer and while creating and adding the control using code.

"Could not load file or assembly 'ConsoleControlAPI, Version=1.2.0.0, Culture=neutral, PublicKeyToken=7c86b8a36b9c33e2' or one of its dependencies. The system cannot find the file specified."

ConsoleControl.dll and .xml sits right beside the .exe in the /bin/debug folder.

Loading it dynamically and doing a assembly.GetTypes() works. Doing Activator.CreateInstance on the type fails with the same exception however.

Need help

Hello
How to use it properly in windows form?
i want set the command in textbox, click a run button and get everything happen in external cmd window

private void btnExecute_Click(object sender, EventArgs e)
{
    string command = textBox1.Text;

    ProcessStartInfo psi = new ProcessStartInfo();
    psi.FileName = "cmd.exe";
    psi.RedirectStandardInput = true;
    psi.RedirectStandardOutput = true;
    psi.RedirectStandardError = true;
    psi.UseShellExecute = false;
    psi.StandardOutputEncoding = Encoding.Default;

    consoleControl1.StartProcess(psi);
    consoleControl1.OnConsoleOutput += (s, args) =>
    {
        consoleControl1.WriteOutput(args.Content, Color.White);
    };
}

private void btnQuit_Click(object sender, EventArgs e)
{
    consoleControl1.StopProcess();
}

private void cleanoutput_Click(object sender, EventArgs e)
{
    consoleControl1.ClearOutput();
}

Working Directory

I'm using this control to launch some console applications and allow the user to review output. It works great! However, I'm running into a bit of a problem where I would like to be able to specify the working directory when launching start process via the console control. Would it be possible for you to add that real quick? It would be very helpful.

Set process priority

Is it possible to add a priority enum to set the executing command from within consolecontrol?

Example:
// Use the values that the OS provides for setting priority values
enum Priority
{
BelowNormal,
Normal,
AboveNormal,
High,
RealTime
}
this.consoleControl.StartProcess ( consoleApp, Priority.High, parameterString );

Infinite buffer size

Hi,

First of all, thanks and congratulations for this excellent work!

I just found your CodeProject article about this control, and it turns out it's exactly what I was looking for (I arrived to it by googling "winforms embed console").

I'd like to use your control to run a console application that will run for a very long time (probably weeks of more if nothing wrong happens). This console application logs a lot of information, so before starting the integration I created a toy app to test your control memory usage.

The console app simply enters an infinite loop writing a line of text in each iteration.

When I run it from inside the ConsoleControl, the memory usage reported by VisualStudio started to increase rapidly (it reached 1GB in around 30 seconds).

Would you consider adding a property to limit the buffer size? I googled "richtextbox buffer size" and found an article that might be usefull for this: https://www.codeproject.com/Articles/34056/Controlling-the-Length-of-a-RichTextBox-in-C

If you're interested in adding this feature but don't have the time to do it, please let me know and I could try to fix it myself and send you a pull request.

I'm using the latest version as of this writing (1.2.1 added to my toy project using Nuget).

image

Best regards,
Santiago

Multiple processes

This control's API assumes that only one process will run at a time. But this seems like an unnecessary restriction. In a normal console session, any number of processes might be running at any given time. StartProcess should return a process ID or Process object that can later be used to terminate that specific process, while other ConsoleControl child processes continue to run.

Backspace deletes last readonly character

Steps to reproduct:
Start new "ConsoleControlSample.WPF" process.
Click "Run command" starts new command shell
Hit backspace on input area
Last character on output, probable a ">" character is removed.

Fix proposal:
on "richTextBoxConsole_PreviewKeyDown" method, change

var caretPosition = richTextBoxConsole.GetCaretPosition();
var delta = caretPosition - inputStartPos;
var inReadOnlyZone = delta < 0;

with this

var caretPosition = richTextBoxConsole.GetCaretPosition();
var delta = caretPosition - inputStartPos;
var inReadOnlyZone = delta <= 0;

ConsoleControl not in Toolbox

Hi,
I created new WPF application, added it via Manage Nuget Packages (choosing WPF version) but it is not in the Toolbox. What am I doing wrong?

Can't Launch Node

I am working on a web IDE that has node functionality, sadly can't open node

WPF line spacing is too large

The rich text box in ConsoleControl.xaml uses double line spacing, so it does not look like a proper console. Adding the following to the <RichTextBox> element fixes it to single line spacing.

<RichTextBox.Resources>
    <Style TargetType="{x:Type Paragraph}">
        <Setter Property="Margin" Value="0" />
    </Style>
</RichTextBox.Resources>

Stopping process throws error

calling consoleControl.StopProcess(); from a wpf button or stopping the process from within the process causes an error in the following function.

<ConsoleControl.xaml.cs>
public bool ShowDiagnostics
{
get { return (bool)GetValue(ShowDiagnosticsProperty); }
set { SetValue(ShowDiagnosticsProperty, value); }
}

An unhandled exception of type 'System.InvalidOperationException' occurred in WindowsBase.dll

Additional information: The calling thread cannot access this object because a different thread owns it."

Unable to launch Python in console

I am looking for a console application that will support Python. Your code looks great, but fails to work with Python.exe (v2.7.8). There is no output produced from Python, and an "Argument out of range" exception is generated when entering a command (which is echoed correctly) and then pressing return (which causes the exception).
Is there some limitation on what exe's can be run using a C# console? I cannot find any consoles written in C# that will run Python.
Thanks, Andrew

Support Ctrl+C

Ctrl-C
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683155(v=vs.85).aspx

Also:

There has been quite some discussion in the messages about the complexity of sending a command like 'Control C' to a cmd process in the console window. Just so that others can find the solution until something formal is actually published, VisualG seems to have a good solution which you can find here:

http://www.codeproject.com/Articles/335909/Embedding-a-Console-in-a-C-Application?msg=4320232#xx4320232xx

Multiple Console Windows

I am writing an app using your control (thank you so much for such an amazing control btw), but I cannot seem to use more than one instance of the control on a single form. When I execute the function StartProcess("cmd",null) on each instance, only one instance loads command prompt.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.