0

I' trying to get mouse coords from Python event in C#. I call my python script from C#, it open a python window, i click on my thumbnails on python window and need to get mouse pos from thumbnails and use it in C# program. This solution works only after i close Python window.I get all the values at this moment...but i need to get these values each time after a click on thumbnails in Python window. I had tried a lot of solutions, but i think the StreamReader read only after Python window is closed.

Here's my python code:

class myClass(object):
    def mouse_click(self, event):
        xs, ys = event.xdata, event.ydata
        print('%s, %s' % (xs, ys))

Here's my C# code :

private void btOK_Click(object sender, EventArgs e)
    {
        start = new ProcessStartInfo();
        start.FileName = "C:\\Python27\\python.exe";
        start.Arguments = "C:\\myfolder\\myfile.py";
        start.UseShellExecute = false;
        start.RedirectStandardOutput = true;

        using (Process process = Process.Start(start))
        {                
            using (StreamReader reader = process.StandardOutput)
            {
                string result = reader.ReadToEnd();
                Console.Write(result);
            }
        }
    }
Bronck
  • 1
  • 2
  • 1
    Possible duplicate of [Capturing console output from a .NET application (C#)](http://stackoverflow.com/questions/186822/capturing-console-output-from-a-net-application-c) – Clint Jan 16 '17 at 14:27
  • 1
    I think it may be because Python is buffering the output - adding CRLF to the output may flush the buffer on each print or Python may allow you to manually flush the buffer after each print : see http://stackoverflow.com/questions/230751/how-to-flush-output-of-python-print – PaulF Jan 16 '17 at 14:40

0 Answers0