static void Main(string[] args)
        {
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
            Trace.AutoFlush = true;
            Trace.Indent();

            if (args.Length == 0)
            {
                Console.WriteLine("USAGE: StreamerMain <process name> <target host> <target port> <fps>");
                Console.WriteLine("\nRunning processes:");
                foreach (string s in ScreenCapturer.listAllD3DProcesses())
                {
                    Console.WriteLine(s);
                }

                return;
            }

            string processName = args[0];
            string ffmpegHost  = args[1];
            int    ffmpegPort  = int.Parse(args[2]);
            float  fps         = float.Parse(args[3]);

            ScreenCapturer screenCap = new ScreenCapturer(processShot);

            ScreenshotManager.OnScreenshotMessage += onMsg;
            screenCap.hook(processName);
            screenCap.sendRequest(new StreamRequest(new Rectangle(0, 0, 0, 0), ffmpegHost, ffmpegPort, fps));

            char k;

            while ((k = Console.ReadKey().KeyChar) != 'q')
            {
                if (k == 'p')
                {
                    Trace.TraceInformation("Pausing capturing");
                    screenCap.sendRequest(new PauseRequest());
                }
                else if (k == 'r')
                {
                    Trace.TraceInformation("Pausing capturing");
                    screenCap.sendRequest(new ResumeRequest());
                }
            }
            Trace.TraceInformation("Stopping screen caputring...");
            screenCap.sendRequest(new StopRequest());
            Thread.Sleep(1000);
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
            Trace.AutoFlush = true;
            Trace.Indent();

            if (args.Length == 0)
            {
                Console.WriteLine("USAGE: StreamerMain <process name> <target host> <target port> <fps>");
                Console.WriteLine("\nRunning processes:");
                foreach (string s in ScreenCapturer.listAllD3DProcesses())
                {
                    Console.WriteLine(s);
                }

                return;
            }

            string processName = args[0];
            string ffmpegHost = args[1];
            int ffmpegPort = int.Parse(args[2]);
            float fps = float.Parse(args[3]);

            ScreenCapturer screenCap = new ScreenCapturer(processShot);
            ScreenshotManager.OnScreenshotMessage += onMsg;
            screenCap.hook(processName);
            screenCap.sendRequest(new StreamRequest(new Rectangle(0, 0, 0, 0), ffmpegHost, ffmpegPort, fps));

            char k;
            while ((k = Console.ReadKey().KeyChar) != 'q')
            {
                if (k == 'p')
                {
                    Trace.TraceInformation("Pausing capturing");
                    screenCap.sendRequest(new PauseRequest());
                }
                else if (k == 'r')
                {
                    Trace.TraceInformation("Pausing capturing");
                    screenCap.sendRequest(new ResumeRequest());
                }

            }
            Trace.TraceInformation("Stopping screen caputring...");
            screenCap.sendRequest(new StopRequest());
            Thread.Sleep(1000);
            Console.ReadKey();
        }