public MainWindow()
        {
            InitializeComponent();

            //Console.Title = "Client";
            //var path = "winter2.jpg";

            //var aTimer = new System.Timers.Timer();
            //aTimer.Interval = 5000;
            //aTimer.Elapsed += OnTimedEvent;



            var path = "screen3.png";

            System.Drawing.Image im = ScreenCapture.CaptureDesktop();
            byte[] image_data       = ImageToByteArray(im);
            var    client           = new UdpClient();

            SendHeaders(path, client, image_data);
            client.Close();

            //Console.ReadLine();


            // ScreenCapture sc = new ScreenCapture();
            // // capture entire screen, and save it to a file
            // System.Drawing.Image img = sc.C
            // // display image in a Picture control named imageDisplay
            //// this.imageDisplay.Image = img;
            // // capture this window, and save it
            // sc.CaptureWindowToFile(this.Handle, "C:\\temp2.gif", ImageFormat.Gif);
        }
Esempio n. 2
0
 public void CaptureDesktop()
 {
     using (Image img = ScreenCapture.CaptureDesktop())
     {
         RenderImage(img, "Desktop.png");
     }
 }
 private byte[] FullScreenData()
 {
     Console.WriteLine("Full screen request");
     using (var ms = new MemoryStream())
     {
         ScreenCapture.CaptureDesktop().Save(ms, ImageFormat.Jpeg);
         var imgData    = ms.ToArray();
         var compressed = ZlibStream.CompressBuffer(imgData);
         //write the image
         return(compressed);
     }
 }
Esempio n. 4
0
        private void CaptureFullScreen()
        {
            Image image = ScreenCapture.CaptureDesktop();

            if (image != null)
            {
                var captureFileName = GetCaptureFileName(true);
                _logger.Debug($"Saving full screen into: {captureFileName}");
                UpdateFileStatus(captureFileName);
                image.Save(captureFileName, ImageFormat.Png);
            }
        }
Esempio n. 5
0
    public void SaveScreenshotOnFailure()
    {
        if (TestContext.CurrentTestOutcome == UnitTestOutcome.Passed)
        {
            return;
        }

        var filename = Path.GetRandomFileName() + ".png";

        using (var screenshot = ScreenCapture.CaptureDesktop())
            screenshot.Save(filename, ImageFormat.Png);

        TestContext.AddResultFile(filename);
    }
        private void HandleMessage(Message.MESSAGE_ID msgType, byte[] msgData)
        {
            switch (msgType)
            {
            case Message.MESSAGE_ID.BUTTON:
                Debug.WriteLine(string.Format("BTN " + BitConverter.ToInt32(msgData, 0)));
                Win32Natives.keybd_event((byte)BitConverter.ToInt32(msgData, 0), 0, (int)Win32Natives.KeyActionState.Down, 0);
                Win32Natives.keybd_event((byte)BitConverter.ToInt32(msgData, 0), 0, (int)Win32Natives.KeyActionState.Up, 0);
                _socket.SendBytes(Message.Create(Message.MESSAGE_ID.OK, 0));
                break;

            case Message.MESSAGE_ID.MOUSE:
                int x = BitConverter.ToInt32(msgData, 0);
                int y = BitConverter.ToInt32(msgData, 4);
                break;

            case Message.MESSAGE_ID.NONE:
                break;

            case Message.MESSAGE_ID.GET_STATUS:
                break;

            case Message.MESSAGE_ID.STATUS:
                break;

            case Message.MESSAGE_ID.GET_SCREEN:
                lock (ObjScreenLock)
                {
                    try
                    {
                        Bitmap bmpScreem = (Bitmap)ScreenCapture.CaptureDesktop();                                // NativeMethods.CaptureScreen(new Rectangle(0, 0, 272, 480));
                        SendScreenBitmap(BitmapToByteArray(bmpScreem));

                        //bmpScreem.Save(BMP_FILENAME, ImageFormat.Jpeg);
                        //// send screen bitmap
                        //SendScreenBitmap(BMP_FILENAME);
                    }
                    catch (Exception exception)
                    {
                        _socket.SendBytes(Message.Create(Message.MESSAGE_ID.NONE, 0));
                        _logger.Log(string.Format("HandleMessage {0} {1}", msgType, exception));
                    }
                }
                break;

            case Message.MESSAGE_ID.SCREEN:
                break;
            }
        }
        private void TimerTick()
        {
            MessageBox.Show((count++) + " minutes", "Info", MessageBoxButton.OK, MessageBoxImage.Information);

            var path = "screen" + count + ".png";

            System.Drawing.Image im = ScreenCapture.CaptureDesktop(); // робимо скрін
            byte[] image_data       = ImageToByteArray(im);

            // надсилаємо
            var client = new UdpClient();

            SendHeaders(path, client, image_data);
            client.Close();
        }
Esempio n. 8
0
        public void SearchItem(int min, int max, int j)
        {
            Point k;
            int   i = min;

            //var image = (Bitmap)ScreenCapture.CaptureDesktop(new Point(37, 140));
            //Bitmap image2 = (Bitmap)grayscale(image);
            do
            {
                var    image  = (Bitmap)ScreenCapture.CaptureDesktop(new Point(18, 93));
                Bitmap image2 = (Bitmap)grayscale(image);
                pictureBox1.Image = image2;
                var ocr  = new TesseractEngine("./tessdata", "eng", EngineMode.TesseractAndCube);
                var page = ocr.Process(image2);
                buylist.AppendText(page.GetText());
                pictureBox1.Image = image2;
            } while (false);
        }