Пример #1
0
        public LPath CapturePrimaryScreen()
        {
            var s    = System.Windows.Forms.Screen.PrimaryScreen;
            var file = screenCapture.Capture(s, GetDestinationFilename(DateTime.Now, s.DeviceName));

            return(CopyToClipboard(file));
        }
Пример #2
0
        private void Screen1()
        {
            Task.Factory.StartNew(() =>
            {
                TimerTool tt = new TimerTool();
                Bitmap b     = null;
                while (true)
                {
                    tt.Begin();
                    Graphics pictureG = pictureBox1.CreateGraphics();
                    b = ScreenCapture.Capture();

                    Graphics cursorG = Graphics.FromImage(b);
                    ScreenCapture.DrawCursorImageToScreenImage(ref cursorG);

                    pictureG.DrawImage(b, 0, 0, pictureBox1.Width, pictureBox1.Height);

                    b?.Dispose();
                    BeginInvoke(new Action(() =>
                    {
                        label1.Text = string.Format("{0} × {1}  time: {2} ms",
                                                    pictureBox1.Width, pictureBox1.Height, tt.ms);
                    }));

                    cursorG.Dispose();
                    pictureG.Dispose();
                    Thread.Sleep(10);
                }
            });
        }
Пример #3
0
    // For Save
    IEnumerator CaptureScreen()
    {
        yield return(new WaitForEndOfFrame());

        uploadImage = ScreenCapture.Capture();
        LoadTextureFromImagePicker.SaveAsJpgToPhotoLibrary(uploadImage, gameObject.name, "OnFinishedSaveImage");
    }
Пример #4
0
        public void Test3()
        {
            // –ÚŽ‹Šm”F—p
            Bitmap bmp = ScreenCapture.Capture(0, 0, 1920, 1080, true);

            bmp.Save("UnitTestResult.bmp");
        }
Пример #5
0
    // For Save
    IEnumerator CaptureScreen()
    {
        yield return(new WaitForEndOfFrame());

        //Get another copy to show on share screen
        Texture2D screenshot = ScreenCapture.Capture();

        Color32[] pix = screenshot.GetPixels32();
        Destroy(screenShotCopy);
        screenShotCopy = new Texture2D(screenshot.width, screenshot.height);
        screenShotCopy.SetPixels32(pix);
        screenShotCopy.Apply();

        Debug.Log("Capture one frame");
        #if UNITY_IPHONE
        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            LoadTextureFromImagePicker.SaveAsJpgToPhotoLibrary(screenshot, gameObject.name, "OnFinishedSaveImage");
        }
        #endif

        if (Application.platform == RuntimePlatform.Android)
        {
            SaveImageToLibraryAndriod(screenshot);
        }

        //FOR TEST
        //OnFinishedSaveImage("");
    }
Пример #6
0
    // For Save
    IEnumerator CaptureScreen()
    {
        yield return(new WaitForEndOfFrame());

        // Save to PhotoLibrary
        Texture2D screenShot = ScreenCapture.Capture();

        if (saveAsPng)
        {
            bool withTransparency = false;
            if (withTransparency)
            {
                // PNG with transparency
                LoadTextureFromImagePicker.SaveAsPngWithTransparencyToPhotoLibrary(screenShot, gameObject.name, "OnFinishedSaveImage");
            }
            else
            {
                // PNG
                LoadTextureFromImagePicker.SaveAsPngToPhotoLibrary(screenShot, gameObject.name, "OnFinishedSaveImage");
            }
        }
        else
        {
            // JPG
            LoadTextureFromImagePicker.SaveAsJpgToPhotoLibrary(screenShot, gameObject.name, "OnFinishedSaveImage");
        }
    }
Пример #7
0
        public void Test1()
        {
            var r1 = ScreenCapture.Capture(100, 100, 100, 200);

            Assert.Equal(100, r1.Width);
            Assert.Equal(200, r1.Height);

            var r2 = ScreenCapture.Capture(50, 50, 50, 60, true);

            Assert.Equal(50, r2.Width);
            Assert.Equal(60, r2.Height);

            Rectangle rect1 = new Rectangle(10, 20, 30, 40);
            Rectangle rect2 = new Rectangle(50, 60, 70, 80);

            var r3 = ScreenCapture.Capture(rect1);

            Assert.Equal(30, r3.Width);
            Assert.Equal(40, r3.Height);

            var r4 = ScreenCapture.Capture(rect2, true);

            Assert.Equal(70, r4.Width);
            Assert.Equal(80, r4.Height);
        }
Пример #8
0
        private void CaptureBitmap()
        {
            var    location = (Point)this.Invoke(new GetCaptureLocationCallback(GetCaptureLocation));
            Bitmap bmp      = ScreenCapture.Capture(new Rectangle(location, captureSize), CaptureCursor.Checked, HighlightCursor.Checked);

            frames.Add(bmp);
            this.Invoke(new UpdateFrameTextCallback(UpdateFrameText), new object[] { string.Format("{0}", frames.Count) });
        }
Пример #9
0
    // For Save
    IEnumerator CaptureScreen()
    {
        yield return(new WaitForEndOfFrame());

        // Save to PhotoLibrary
        Texture2D texScreenShot = ScreenCapture.Capture();

        LoadTextureFromImagePicker.SaveAsPngToPhotoLibrary(texScreenShot, this.name, "OnFinishedSaveImage");
    }
Пример #10
0
        static public Bitmap GetWindowBitmap(IntPtr hWnd)
        {
            _ = Win32.DwmGetWindowAttribute(hWnd, Win32.DWMWA_EXTENDED_FRAME_BOUNDS, out Win32.Rect rect, Marshal.SizeOf(typeof(Win32.Rect)));
            if (rect.Width == 0 || rect.Height == 0)
            {
                return(null);
            }

            return(ScreenCapture.Capture(rect.Left, rect.Top, rect.Width, rect.Height, true));
        }
Пример #11
0
 public void SaveToPNG(bool split)
 {
     if (Application.isMobilePlatform)
     {
         Message.Instance.Show("Не поддерживается на мобильных платформах");
     }
     else
     {
         screenCapture.Capture(split);
     }
 }
Пример #12
0
        public void OnMKey()
        {
            if (!VerifyFileNameNotEmpty())
            {
                Activate();
                return;
            }

            ScreenCapture screenshot      = new ScreenCapture();
            var           takenScreenshot = screenshot.Capture();

            OnKeyCommon(takenScreenshot);
        }
Пример #13
0
        public void GetResult()
        {
            var status = TestContext.CurrentContext.Result.Outcome.Status;

            //ScreenCapture screen = new ScreenCapture();
            string ScreenshotPath = ScreenCapture.Capture(driver, "ScreenShot" + status);
            var    stackTrace     = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>";
            var    errorMessage   = TestContext.CurrentContext.Result.Message;

            if (status == TestStatus.Passed)
            {
                var test = extent.CreateTest("TestMethod", "This Test Case gets Passed");
                test.Log(Status.Pass, stackTrace + errorMessage);
                test.Log(Status.Info, "Step 1: Test Case starts.");
                test.AddScreenCaptureFromPath(ScreenshotPath);
                extent.AttachReporter(htmlReporter);
            }

            else if (status == TestStatus.Failed)
            {
                var test = extent.CreateTest("TestMethod", "This Test Case gets Failed");
                test.Log(Status.Info, "Step 1: Test Case starts.");
                test.Log(Status.Fail, stackTrace + errorMessage);
                //test.Log(Status.Fail, "Step 2: Test Case Failed.");
                test.AddScreenCaptureFromPath(ScreenshotPath);
                extent.AttachReporter(htmlReporter);
            }
            else if (status == TestStatus.Skipped)
            {
                var test = extent.CreateTest("TestMethod", "This Test Case gets Skipped");
                test.Log(Status.Info, "Step 1: Test Case starts.");
                test.Log(Status.Skip, stackTrace + errorMessage);
                //test.Log(Status.Skip, "Step 2: Test Case Skipped.");
                test.AddScreenCaptureFromPath(ScreenshotPath);
                extent.AttachReporter(htmlReporter);
            }
            else if (status == TestStatus.Warning)
            {
                var test = extent.CreateTest("TestMethod", "This Test Case gets Warning");
                test.Log(Status.Info, "Step 1: Test Case starts.");
                test.Log(Status.Warning, stackTrace + errorMessage);
                //test.Log(Status.Warning, "Step 2: Test Case warning.");
                test.AddScreenCaptureFromPath(ScreenshotPath);
                extent.AttachReporter(htmlReporter);
            }
            extent.Flush();
            driver.Close();
        }
Пример #14
0
        /// <summary>
        /// 截取屏幕并发送
        /// </summary>
        private void SendScreen()
        {
            SendScreenCode code = new SendScreenCode();

            code.ScreenImage = ScreenCapture.Capture();
            if (code.ScreenImage == null)
            {//不能发送屏幕
                BaseCode failcode = new BaseCode();
                failcode.Head = CodeHead.FAIL;
                base.SendCode(failcode);
            }
            else
            {
                base.SendCode(code);
            }
        }
Пример #15
0
        private void 保存屏幕ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bitmap screen = null;

            try
            {
                string file = DirTool.Combine(R.Paths.App, DateTimeConvert.CompactString(DateTime.Now) + ".jpg");
                screen = ScreenCapture.Capture();
                screen.Save(file, System.Drawing.Imaging.ImageFormat.Jpeg);
                ToastForm.Display("保存", "保存屏幕成功:" + Path.GetFileName(file), ToastForm.ToastType.info);
            }
            catch { ToastForm.Display("保存", "保存屏幕失败", ToastForm.ToastType.error); }
            finally
            {
                screen?.Dispose();
            }
        }
Пример #16
0
        public async void GetDesktopCapture(string username, long width, long height, string imageFormat)
        {
            Image img = ScreenCapture.Capture();

            if (width > 0 && height > 0)
            {
                img = img.ResizeImage((int)width, (int)height);
            }

            if (img != null)
            {
                var format = (ImageFormat)(typeof(ImageFormat).GetProperty(imageFormat).GetValue(null));

                string img64 = img.ToBase64String(format);
                await CallClientAsync(username, "OnFetchImage", img64, Username);
            }
        }
Пример #17
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (form != null)
     {
         try
         {
             ImageFormatHandler handlers = new ImageFormatHandler();
             ScreenCapture      capture  = new ScreenCapture(handlers);
             pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
             pictureBox1.Image    = capture.Capture(form, @"XunitFormsCapture\");
             CompareControlCaptureAction action = new CompareControlCaptureAction(capture.LastCapture, null);
             writer.AddAction(action);
             textBox.Text = writer.Test;
         }
         catch (ObjectDisposedException)
         {
             MessageBox.Show("Please re-open your form.");
         }
     }
 }
Пример #18
0
        /// <summary>
        ///     Captures a screenshot of the UO window
        /// </summary>
        public void Capture()
        {
            var img = ScreenCapture.Capture();

            if (img == null)
            {
                Pandora.Log.WriteEntry("Screenshot attempt failed");
                return;
            }

            var file = Path.Combine(BaseFolder, NextScreenshotName);

            try
            {
                img.Save(file, ImageFormat.Jpeg);
            }
            catch (Exception err)
            {
                Pandora.Log.WriteError(err, "Couldn't save a screenshot to disk");
            }

            img.Dispose();
        }
Пример #19
0
    // endof IHoldHandler Event Handler


    // IInputClickHandler 는 OnInputClicked에 대한 메소드 구현이 필요하다.
    public virtual void OnInputClicked(InputClickedEventData eventData)
    {
        Debug.Log("tap");
        if (LightSceneMenuManager.menuSelecting)
        {
            RaycastHit hit;
            if (Physics.Raycast(Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)), out hit, float.MaxValue))
            {
                if (hit.collider.gameObject.name == "ProceedButton")
                {
                    Debug.Log("Menu selected");
                    lightSceneMenuManagerObject.DeActivateMenu();
                    StartCoroutine(ButtonDownToLoadNewScene());
                    LightSceneMenuManager.menuSelecting = false;
                }
                else
                {
                    Debug.Log("Menu not selected");
                    lightSceneMenuManagerObject.DeActivateWithoutSelectingMenu();
                    LightSceneMenuManager.menuSelecting = false;
                }
            }
            else
            {
                Debug.Log("Menu not selected");
                lightSceneMenuManagerObject.DeActivateWithoutSelectingMenu();
                LightSceneMenuManager.menuSelecting = false;
            }
        }
        else
        {
            if (!ScreenCapture.Capturing)
            {
                ScreenCapture.Capture();
            }
        }
    }
Пример #20
0
        private void Processing()
        {
            // Prevent Zoom Tolerance
            float Zoom = setting.Zoom;

            // ViewSize
            Size vSize = new Size(100, 100);

            // View Half Size
            Size vhSize = new Size(vSize.Width / 2, vSize.Height / 2);

            // Capture Size
            Size scSize = new Size(SelectOdd(vSize.Width / Zoom), SelectOdd(vSize.Height / Zoom));

            // ZoomBuffer Size
            Size zbSize = new Size((int)(scSize.Width * Zoom), (int)(scSize.Height * Zoom));

            // Remain Size
            Size rmSize = zbSize - vSize;

            // Capture Area
            Point mPt = Mouse.Position;

            if (IsActivated && IntersectWith(this.Bounds, mPt))
            {
                if (mInWorkArea)
                {
                    return;
                }
                else
                {
                    mInWorkArea = true;
                }

                mPt = this.Location;
            }
            else
            {
                mInWorkArea = false;
            }

            Rectangle area = new Rectangle(mPt.X - scSize.Width / 2, mPt.Y - scSize.Height / 2, scSize.Width, scSize.Height);

            // Capture
            Bitmap buffer = ScreenCapture.Capture(area);

            // Picked Color
            Color pColor = buffer.GetPixel(area.Width / 2, area.Height / 2);

            // ViewBox Processing
            Bitmap view = new Bitmap(vSize.Width, vSize.Height);

            using (Graphics g = Graphics.FromImage(view))
            {
                Point dPos = new Point(-rmSize.Width / 2, -rmSize.Height / 2);

                g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                g.InterpolationMode = InterpolationMode.NearestNeighbor;

                g.DrawImage(buffer, new Rectangle(dPos, zbSize));

                // Grid Processing
                if (setting.ShowGrid && Zoom >= 2f)
                {
                    using (SolidBrush sb = new SolidBrush(Color.FromArgb(100, Color.White)))
                    {
                        using (Pen p = new Pen(sb))
                        {
                            int z = (int)Zoom;

                            for (int x = dPos.X; x <= vSize.Width; x += z)
                            {
                                if (x >= 0)
                                {
                                    g.DrawLine(p, new PointF(x, 0), new PointF(x, vSize.Height));
                                }
                            }

                            for (int y = dPos.Y; y <= vSize.Height; y += z)
                            {
                                if (y >= 0)
                                {
                                    g.DrawLine(p, new PointF(0, y), new PointF(vSize.Width, y));
                                }
                            }
                        }
                    }
                }

                // CrossLine Processing
                for (int x = 0; x < vSize.Width; x++)
                {
                    Color px = view.GetPixel(x, vhSize.Height);

                    view.SetPixel(x, vhSize.Height, ColorUtils.Invert(px));
                }

                for (int y = 0; y < vSize.Height; y++)
                {
                    Color px = view.GetPixel(vhSize.Width, y);

                    view.SetPixel(vhSize.Width, y, ColorUtils.Invert(px));
                }
            }

            buffer.Dispose();

            SetPickedColor(pColor);

            CrossThreading.UIInvoke(() =>
            {
                ldcPlate.BaseColor = pColor;

                viewBox.Image?.Dispose();
                viewBox.Image = view;
            });
        }
Пример #21
0
 public static Bitmap CaptureAllScreens(this ScreenCapture screenCapture)
 {
     return(screenCapture.Capture(new Rectangle((int)SystemParameters.VirtualScreenLeft, (int)SystemParameters.VirtualScreenTop,
                                                (int)SystemParameters.VirtualScreenWidth, (int)SystemParameters.VirtualScreenHeight)));
 }
Пример #22
0
        //-------------------------------------------------------------------------
        // 無料延長チェック
        //-------------------------------------------------------------------------
        public int CheckExtend( Rectangle iRc, int iX, int iY )
        {
            const int padding = 10;
            const int padding2 = 10;

            Point ending_offs = new Point(220, 106);     // 残り時間のオフセット
            Point encho_offs  = new Point(565, 104);     // 延長タブのオフセット
            Point free_offs   = new Point(510, 172);     // 購入ボタン
            Point _500_offs   = new Point(542, 138);     // 500円延長ボタンのオフセット

            Point yes_offs = new Point(394, 208);     // はいボタンのオフセット
            Point ok3_offs = new Point(463, 206);     // OK3ボタンのオフセット
            Point fail_offs = new Point(457, 164);     // 延長失敗OKボタンのオフセット
            Point err_offs = new Point(459, 167);     // 予期せぬOKボタンのオフセット

            using( ScreenCapture scr = new ScreenCapture() ) {
                Bitmap bmp = scr.Capture(iRc);

                Point outPos = new Point();
                const int thres = 10;

                // 残り3分
                if (ContainBitmap(mEnchoBmp, bmp, encho_offs.X - padding, encho_offs.Y - padding, encho_offs.X + padding, encho_offs.Y + padding, ref outPos, 10))      // 時間延長タブが選択されていない
                {
                    // 時間延長タブを選択する
                    MouseClick(iX + outPos.X + 10, iY + outPos.Y + 8);
                }
                else
                {
                    if (ContainBitmap(mFreeBmp, bmp, free_offs.X - padding, free_offs.Y - padding, free_offs.X + padding, free_offs.Y + padding, ref outPos,5))          // 無料延長チェック
                    {
                        // 購入ボタンクリック
                        MouseClick(iX + 712, iY + outPos.Y + 7);
                        bmp.Dispose();
                        bmp = null;
                        return 1;
                    }
                    else if (ContainBitmap(m500Bmp, bmp, _500_offs.X - padding, _500_offs.Y - padding, _500_offs.X + padding, _500_offs.Y + padding, ref outPos, 5) ||
                            ContainBitmap(m5002Bmp, bmp, _500_offs.X - padding, _500_offs.Y - padding, _500_offs.X + padding, _500_offs.Y + padding, ref outPos, 5))
                    {
                        // 500円延長時は更新ボタンをクリックする
                        MouseClick(iX + outPos.X + 45, iY + outPos.Y + 12);
                    }
                }

                // 延長失敗OKボタンをクリック
                if (ContainBitmap(mErrBmp, bmp, err_offs.X - padding2, err_offs.Y - padding, err_offs.X + padding2, err_offs.Y + padding, ref outPos, 5))
                {
                    MouseClick(iX + outPos.X + 19, iY + outPos.Y + 41);
                }
                else // 延長失敗OKボタンをクリック
                if (ContainBitmap(mExtFailBmp, bmp, fail_offs.X - padding2, fail_offs.Y - padding, fail_offs.X + padding2, fail_offs.Y + padding, ref outPos, 5))
                {
                    MouseClick(iX + outPos.X + 21, iY + outPos.Y + 52);
                }
                else // OKボタンをクリック
                if (ContainBitmap(mOk3Bmp, bmp, ok3_offs.X - padding2, ok3_offs.Y - padding, ok3_offs.X + padding2, ok3_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 17, iY + outPos.Y + 8);
                    bmp.Dispose();
                    bmp = null;
                    return 2;
                }

                // はいボタンをクリック
                if (ContainBitmap(mYesBmp, bmp, yes_offs.X - padding2, yes_offs.Y - padding, yes_offs.X + padding2, yes_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 5, iY + outPos.Y + 8);
                }
                bmp.Dispose();
                bmp = null;
            }

            return 0;
        }
Пример #23
0
        //-------------------------------------------------------------------------
        // 自動放送開始チェック
        //-------------------------------------------------------------------------
        public int AutoStart( Rectangle iRc, int iX, int iY )
        {
            const int padding = 10;
            const int padding2 = 10;
            const int thres = 10;

            Point start_offs = new Point(829, 115);    		// 放送開始ボタンのオフセット
            Point ok_offs    = new Point(424, 169);     	// 放送開始後のはいボタン
            Point prechat_offs = new Point(776, 108);

            using (ScreenCapture scr = new ScreenCapture())
            {
                Point outPos = new Point();
                Bitmap bmp = scr.Capture(iRc);

                if (ContainBitmap(mPreChat, bmp, prechat_offs.X - padding2, prechat_offs.Y - padding, prechat_offs.X + padding2, prechat_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 12, iY + outPos.Y + 11);
                    bmp.Dispose();
                    bmp = null;
                    return 0;
                }

                if (ContainBitmap(mStartBmp, bmp, start_offs.X - padding, start_offs.Y - padding, start_offs.X + padding, start_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 50, iY + outPos.Y + 30);
                    bmp.Dispose();
                    bmp = null;
                    return 1;
                }
                if (ContainBitmap(mBroOkBmp, bmp, ok_offs.X - padding2, ok_offs.Y - padding, ok_offs.X + padding2, ok_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 20, iY + outPos.Y + 40);
                    bmp.Dispose();
                    bmp = null;
                    return 2;
                }
                if (ContainBitmap(mBroOk2Bmp, bmp, ok_offs.X - padding2, ok_offs.Y - padding, ok_offs.X + padding2, ok_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 20, iY + outPos.Y + 40);
                    bmp.Dispose();
                    bmp = null;
                    return 2;
                }
                if (ContainBitmap(mOpenChat, bmp, prechat_offs.X - padding2, prechat_offs.Y - padding, prechat_offs.X + padding2, prechat_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 12, iY + outPos.Y + 11);
                    bmp.Dispose();
                    bmp = null;
                    return 0;
                }
                bmp.Dispose();
                bmp = null;
            }
            return 0;
        }
Пример #24
0
        //-------------------------------------------------------------------------
        // 自動放送開始チェック
        //-------------------------------------------------------------------------
        public int AutoFME(Rectangle iRc, int iX, int iY)
        {
            const int padding = 10;
            const int padding2 = 10;
            const int thres = 10;

            Point fme_offs = new Point(665, 104);
            Point start_offs = new Point(451, 213);
            Point stop_offs = new Point(450, 185);

            using (ScreenCapture scr = new ScreenCapture())
            {
                Bitmap bmp = scr.Capture(iRc);
                Point outPos = new Point();

                if (ContainBitmap(mFME, bmp, fme_offs.X - padding2, fme_offs.Y - padding, fme_offs.X + padding2, fme_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 12, iY + outPos.Y + 8);
                    bmp.Dispose();
                    bmp = null;
                    return 0;
                }
                if (ContainBitmap(mStopFME, bmp, stop_offs.X - padding2, stop_offs.Y - padding, stop_offs.X + padding2, stop_offs.Y + padding, ref outPos, thres))
                {
                    bmp.Dispose();
                    bmp = null;
                    return 1;
                }
                if (ContainBitmap(mStartFME, bmp, start_offs.X - padding2, start_offs.Y - padding, start_offs.X + padding2, start_offs.Y + padding, ref outPos, thres))
                {
                    MouseClick(iX + outPos.X + 12, iY + outPos.Y + 11);
                    bmp.Dispose();
                    bmp = null;
                    return 0;
                }
                bmp.Dispose();
                bmp = null;
                return 0;
            }
        }
Пример #25
0
 public void ScreenCapture_Capture()
 {
     ScreenCapture.Capture();
 }
Пример #26
0
        //-------------------------------------------
        // PushStart
        //-------------------------------------------
        public static bool PushStart()
        {
            const int padding  = 10;
            const int padding2 = 10;

            mFMEStarted = false;

            // プロセスが確保されていなければ、リターン
            if (mFMEprocess == null)
            {
                return(false);
            }

            // プロセスが存在しても、終了していれば、リターン
            if (mFMEprocess.HasExited)
            {
                return(false);
            }

            // ウインドウのサイズをあわせる
            FitWindowSize();

            RECT clientrect = new RECT();


            // クライアント領域のスクリーンをキャプチャする
            Bitmap bmp = null;


            bool bStartPushed   = false;
            bool bStartComplete = false;

            using (ScreenCapture scr = new ScreenCapture())
            {
                int   i;
                Point outPos = new Point();

                Point start_offs = new Point(417, 512);
                Point stop_offs  = new Point(556, 512);
                Point ng_offs    = new Point(489, 357);


                // スタートボタンを探して押す
                for (i = 0; i < 60; i++)
                {
                    // ウインドウをフォアグラウンドに
                    SetForegroundWindow(m_fme_hwnd);  // アクティブにする

                    // クライアント領域のサイズを取得
                    GetClientRect(m_fme_hwnd, ref clientrect);
                    POINT p1, p2;
                    p1.x = clientrect.left;
                    p1.y = clientrect.top;
                    p2.x = clientrect.right;
                    p2.y = clientrect.bottom;

                    //クライアント領域座標をスクリーン座標に変換
                    ClientToScreen(m_fme_hwnd, ref p1);
                    ClientToScreen(m_fme_hwnd, ref p2);

                    // クライアント領域のレクトアングルを設定
                    Rectangle iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                    bmp = scr.Capture(iRect);
                    if (ContainBitmap(mStartBmp, bmp, start_offs.X - padding2, start_offs.Y - padding, start_offs.X + padding2, start_offs.Y + padding, ref outPos, 5))
                    {
                        MouseClick(p1.x + outPos.X + 18, p1.y + outPos.Y + 14);
                        bStartPushed = true;
                        // 立ち上がるのを待つ
                        using (Bouyomi bm = new Bouyomi())
                        {
                            bm.Talk("スタートボタン、プッシュ");
                        }
                        break;
                    }

                    bmp.Dispose();
                    bmp = null;
                    FitWindowSize();
                    // 0.5[s] wait
                    System.Threading.Thread.Sleep(500);
                }

                // スタートボタンが押せなかった場合
                if (!bStartPushed)
                {
                    if (bmp != null)
                    {
                        bmp.Dispose();
                        bmp = null;
                    }
                    // 立ち上がるのを待つ
                    using (Bouyomi bm = new Bouyomi())
                    {
                        bm.Talk("スタートボタンを代わりに押してください");
                    }
                }

                // スタートできたかのチェック
                for (i = 0; i < 40; i++)
                {
                    // ウインドウをフォアグラウンドに
                    SetForegroundWindow(m_fme_hwnd);  // アクティブにする

                    GetClientRect(m_fme_hwnd, ref clientrect);
                    POINT p1, p2;
                    p1.x = clientrect.left;
                    p1.y = clientrect.top;
                    p2.x = clientrect.right;
                    p2.y = clientrect.bottom;

                    //クライアント領域座標をスクリーン座標に変換
                    ClientToScreen(m_fme_hwnd, ref p1);
                    ClientToScreen(m_fme_hwnd, ref p2);

                    Rectangle iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                    bmp = scr.Capture(iRect);

                    // Stop が押せるようになれば、とりあえず成功判定
                    if (ContainBitmap(mStopBmp, bmp, stop_offs.X - padding2, stop_offs.Y - padding, stop_offs.X + padding2, stop_offs.Y + padding, ref outPos, 5))
                    {
                        // 立ち上がるのを待つ
                        using (Bouyomi bm = new Bouyomi())
                        {
                            bm.Talk("ストップボタン、点灯確認");
                        }
                        bStartComplete = true;
                        mFMEStarted    = true;
                        bmp.Dispose();
                        bmp = null;
                        break;
                    }

                    // NGダイアログが出てきたら、NG判定
                    if (ContainBitmap(mNgBmp, bmp, ng_offs.X - padding2, ng_offs.Y - padding, ng_offs.X + padding2, ng_offs.Y + padding, ref outPos, 5))
                    {
                        MouseClick(p1.x + outPos.X + 10, p1.y + outPos.Y + 10);
                        if (bmp != null)
                        {
                            bmp.Dispose();
                            bmp = null;
                        }

                        // NG ダイアログが消えるのを待つ
                        int j;
                        for (j = 0; j < 10; j++)
                        {
                            GetClientRect(m_fme_hwnd, ref clientrect);

                            p1.x = clientrect.left;
                            p1.y = clientrect.top;
                            p2.x = clientrect.right;
                            p2.y = clientrect.bottom;

                            //クライアント領域座標をスクリーン座標に変換
                            ClientToScreen(m_fme_hwnd, ref p1);
                            ClientToScreen(m_fme_hwnd, ref p2);

                            iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                            bmp = scr.Capture(iRect);
                            if (!ContainBitmap(mNgBmp, bmp, ng_offs.X - padding2, ng_offs.Y - padding, ng_offs.X + padding2, ng_offs.Y + padding, ref outPos, 5))
                            {
                                if (bmp != null)
                                {
                                    bmp.Dispose();
                                    bmp = null;
                                }
                                break;
                            }
                            // 0.5[s] wait
                            System.Threading.Thread.Sleep(500);
                        }
                        break;
                    }
                    if (bmp != null)
                    {
                        bmp.Dispose();
                        bmp = null;
                    }

                    // 0.5[s] wait
                    FitWindowSize();
                    System.Threading.Thread.Sleep(500);
                }
            }

            //// Start領域
            //iRect = new Rectangle(p1.x+417, p1.y+512, 36, 28);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEstart.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //// Stop領域
            //iRect = new Rectangle(p1.x + 556, p1.y + 512, 34, 28);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEstop.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //// NG領域
            //iRect = new Rectangle(p1.x + 489, p1.y + 357, 21, 19);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEng.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //filePath = @"F:\screen.bmp";
            //Process.Start(filePath);

            //一秒間(1000ミリ秒)停止する
            System.Threading.Thread.Sleep(2000);

            if (bStartComplete)
            {
                using (Bouyomi bm = new Bouyomi())
                {
                    bm.Talk("えふえむいー配信を開始しました");
                }
            }
            else
            {
                using (Bouyomi bm = new Bouyomi())
                {
                    bm.Talk("えふえむいー起動失敗しました");
                }
                FMEGUI.Kill();
            }

            // ウインドウを最小化する
            ShowWindow(m_fme_hwnd, SW_MINIMIZE);
            return(bStartComplete);
        }
Пример #27
0
 public static Bitmap CaptureAllScreens(this ScreenCapture screenCapture)
 {
     return(screenCapture.Capture(SystemInformation.VirtualScreen));
 }
Пример #28
0
 public static Bitmap CapturePrimaryScreen(this ScreenCapture screenCapture)
 {
     return(screenCapture.Capture(Screen.PrimaryScreen.Bounds));
 }
Пример #29
0
 public static Bitmap Capture(this NativeComponent component, bool clientArea = false)
 {
     return(ScreenCapture.Capture(component.Handle, clientArea));
 }
Пример #30
0
        public static void StartNicoLive(Form mainForm)
        {
            Clipboard.Clear();

            const int padding  = 3;
            const int padding2 = 3;

            FindXSplitMainWindow();

            IntPtr hAfterWnd = IntPtr.Zero;

            // ウインドウが最小化状態だったか否か
            bool original_iconic = IsIconic(hXSplitWnd);

            if (!original_iconic)
            {
                hAfterWnd = GetWindow(hXSplitWnd, (uint)GetWindow_Cmd.GW_HWNDPREV);
                while (hAfterWnd != IntPtr.Zero && !IsWindowVisible(hAfterWnd))
                {
                    hAfterWnd = GetWindow(hAfterWnd, (uint)GetWindow_Cmd.GW_HWNDPREV);
                }
            }

            // クライアント領域のスクリーンをキャプチャする
            Bitmap bmp = null;

            //// ウィンドウを元に戻す
            ShowWindow(hXSplitWnd, SW_RESTORE);
            System.Threading.Thread.Sleep(500);

            //// ウインドウをフォアグラウンドに
            SetForegroundWindow(hXSplitWnd);  // アクティブにする
            System.Threading.Thread.Sleep(500);

            //// ウインドウが表示されるまで待つ
            WINDOWPLACEMENT wndplace = new WINDOWPLACEMENT();

            do
            {
                System.Threading.Thread.Sleep(500);
                GetWindowPlacement(hXSplitWnd, ref wndplace);
            } while ((wndplace.showCmd != SW_SHOWNORMAL));


            bool bStartPushed = false;

            using (ScreenCapture scr = new ScreenCapture())
            {
                // クライアント領域のサイズを取得
                RECT      clientrect = new RECT();
                POINT     p1, p2;
                Rectangle iRect;

                // クライアント領域の取得
                GetClientRect(hXSplitWnd, ref clientrect);

                p1.x = clientrect.left;
                p1.y = clientrect.top;
                p2.x = clientrect.right;
                p2.y = clientrect.bottom;

                //クライアント領域座標をスクリーン座標に変換
                ClientToScreen(hXSplitWnd, ref p1);
                ClientToScreen(hXSplitWnd, ref p2);

                //取り込む座標を矩形領域に設定
                iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                Point outPos       = new Point();
                Point haishin_offs = new Point(100, 0);
                Point nico_offs    = new Point(120, 20);

                int i;
                // 配信メニューを押す
                for (i = 0; i < 60; i++)
                {
                    bmp = scr.Capture(iRect);
                    //bmp.Save("C:\\start_wait.png");
                    if (ContainBitmap(mHaishinBmp, bmp, haishin_offs.X, haishin_offs.Y, haishin_offs.X + 50, haishin_offs.Y + 30, ref outPos, 5))
                    {
                        using (Bouyomi bm = new Bouyomi())
                        {
                            bm.Talk("配信メニュー選択");
                        }
                        System.Threading.Thread.Sleep(500);
                        //MouseClick(p1.x + 139, p1.y + 13);
                        bStartPushed = true;
                        // 立ち上がるのを待つ
                        break;
                    }
                    bmp.Dispose();
                    bmp = null;
                    //// ウィンドウを元に戻す
                    ShowWindow(hXSplitWnd, SW_RESTORE);
                    // アクティブにする
                    SetForegroundWindow(hXSplitWnd);

                    // ウエイト
                    System.Threading.Thread.Sleep(500);

                    // クライアント領域を再取得
                    GetClientRect(hXSplitWnd, ref clientrect);

                    p1.x = clientrect.left;
                    p1.y = clientrect.top;
                    p2.x = clientrect.right;
                    p2.y = clientrect.bottom;

                    //クライアント領域座標をスクリーン座標に変換
                    ClientToScreen(hXSplitWnd, ref p1);
                    ClientToScreen(hXSplitWnd, ref p2);

                    //取り込む座標を矩形領域に設定
                    iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);
                }

                //// ニコ生を押す
                if (bStartPushed)
                {
                    for (i = 0; i < 60; i++)
                    {
                        // ここでマウスクリック
                        MouseClick(p1.x + 110, p1.y + 10);

                        System.Threading.Thread.Sleep(500);
                        // もはや、座標は変えられない
                        bmp = scr.Capture(iRect);
                        //bmp.Save("C:\\nico_wait.png");
                        if (ContainBitmap(mNicoBmp, bmp, nico_offs.X - padding2, nico_offs.Y - padding, nico_offs.X + padding2, nico_offs.Y + 64 + padding, ref outPos, 10))
                        {
                            using (Bouyomi bm = new Bouyomi())
                            {
                                bm.Talk("ニコ生プッシュ");
                            }
                            MouseClick(p1.x + outPos.X + 8, p1.y + outPos.Y + 14);
                            //                            MouseClick(p1.x + 151, p1.y + 38);

                            break;  // 押し下げ成功
                        }
                        bmp.Dispose();
                        bmp = null;

                        //// ウィンドウを元に戻す
                        ShowWindow(hXSplitWnd, SW_RESTORE);
                        // アクティブにする
                        SetForegroundWindow(hXSplitWnd);

                        System.Threading.Thread.Sleep(500);

                        // クライアント領域を再取得
                        GetClientRect(hXSplitWnd, ref clientrect);

                        p1.x = clientrect.left;
                        p1.y = clientrect.top;
                        p2.x = clientrect.right;
                        p2.y = clientrect.bottom;

                        //クライアント領域座標をスクリーン座標に変換
                        ClientToScreen(hXSplitWnd, ref p1);
                        ClientToScreen(hXSplitWnd, ref p2);

                        //取り込む座標を矩形領域に設定
                        iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);
                    }
                }
            }

            System.Threading.Thread.Sleep(2000);

            // ウインドウを最小化する
            if (original_iconic)
            {
                ShowWindow(hXSplitWnd, SW_MINIMIZE);
            }
            else
            {
                Thread th = new Thread(delegate()
                {
                    Thread.Sleep(5000);
                    mainForm.Invoke((Action) delegate()
                    {
                        mainForm.Activate();
                    });

                    //if (hAfterWnd != null && hAfterWnd != (IntPtr)(-1) && hAfterWnd != (IntPtr)(-2))
                    //{
                    //    SetWindowPos(hXSplitWnd, hAfterWnd, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);
                    //}
                });
                th.Name = "NivoLive.Xsplit.StartNicoLive()";
                th.Start();
            }
        }
Пример #31
0
 public void Test2()
 {
     Assert.ThrowsAny <ArgumentException>(() => ScreenCapture.Capture(0, 0, 0, 0));
     Assert.ThrowsAny <ArgumentException>(() => ScreenCapture.Capture(100, 100, 0, 100));
     Assert.ThrowsAny <ArgumentException>(() => ScreenCapture.Capture(100, 100, 100, 0));
 }
Пример #32
0
        //-------------------------------------------
        // PushStart
        //-------------------------------------------
        public static bool PushStart()
        {
            const int padding = 10;
            const int padding2 = 10;

            mFMEStarted = false;

            // プロセスが確保されていなければ、リターン
            if (mFMEprocess == null)
            {
                return false;
            }

            // プロセスが存在しても、終了していれば、リターン
            if (mFMEprocess.HasExited)
            {
                return false;
            }

            // ウインドウのサイズをあわせる
            FitWindowSize();

            RECT clientrect = new RECT();

            // クライアント領域のスクリーンをキャプチャする
            Bitmap bmp=null;

            bool bStartPushed = false;
            bool bStartComplete = false;
            using (ScreenCapture scr = new ScreenCapture())
            {
                int i;
                Point outPos = new Point();

                Point start_offs = new Point(417, 512);
                Point stop_offs = new Point(556, 512);
                Point ng_offs = new Point(489, 357);

                // スタートボタンを探して押す
                for (i = 0; i < 60; i++)
                {
                    // ウインドウをフォアグラウンドに
                    SetForegroundWindow(m_fme_hwnd);  // アクティブにする

                    // クライアント領域のサイズを取得
                    GetClientRect(m_fme_hwnd, ref clientrect);
                    POINT p1, p2;
                    p1.x = clientrect.left;
                    p1.y = clientrect.top;
                    p2.x = clientrect.right;
                    p2.y = clientrect.bottom;

                    //クライアント領域座標をスクリーン座標に変換
                    ClientToScreen(m_fme_hwnd, ref p1);
                    ClientToScreen(m_fme_hwnd, ref p2);

                    // クライアント領域のレクトアングルを設定
                    Rectangle iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                    bmp = scr.Capture(iRect);
                    if (ContainBitmap(mStartBmp, bmp, start_offs.X - padding2, start_offs.Y - padding, start_offs.X + padding2, start_offs.Y + padding, ref outPos, 5))
                    {
                        MouseClick(p1.x + outPos.X + 18, p1.y + outPos.Y + 14);
                        bStartPushed = true;
                        // 立ち上がるのを待つ
                        using (Bouyomi bm = new Bouyomi())
                        {
                            bm.Talk("スタートボタン、プッシュ");
                        }
                        break;
                    }

                    bmp.Dispose();
                    bmp = null;
                    FitWindowSize();
                    // 0.5[s] wait
                    System.Threading.Thread.Sleep(500);
                }

                // スタートボタンが押せなかった場合
                if (!bStartPushed)
                {
                    if (bmp != null)
                    {
                        bmp.Dispose();
                        bmp = null;
                    }
                    // 立ち上がるのを待つ
                    using (Bouyomi bm = new Bouyomi())
                    {
                        bm.Talk("スタートボタンを代わりに押してください");
                    }
                }

                // スタートできたかのチェック
                for (i = 0; i < 40; i++)
                {
                    // ウインドウをフォアグラウンドに
                    SetForegroundWindow(m_fme_hwnd);  // アクティブにする

                    GetClientRect(m_fme_hwnd, ref clientrect);
                    POINT p1, p2;
                    p1.x = clientrect.left;
                    p1.y = clientrect.top;
                    p2.x = clientrect.right;
                    p2.y = clientrect.bottom;

                    //クライアント領域座標をスクリーン座標に変換
                    ClientToScreen(m_fme_hwnd, ref p1);
                    ClientToScreen(m_fme_hwnd, ref p2);

                    Rectangle iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                    bmp = scr.Capture(iRect);

                    // Stop が押せるようになれば、とりあえず成功判定
                    if (ContainBitmap(mStopBmp, bmp, stop_offs.X - padding2, stop_offs.Y - padding, stop_offs.X + padding2, stop_offs.Y + padding, ref outPos, 5))
                    {
                        // 立ち上がるのを待つ
                        using (Bouyomi bm = new Bouyomi())
                        {
                            bm.Talk("ストップボタン、点灯確認");
                        }
                        bStartComplete = true;
                        mFMEStarted = true;
                        bmp.Dispose();
                        bmp = null;
                        break;
                    }

                    // NGダイアログが出てきたら、NG判定
                    if (ContainBitmap(mNgBmp, bmp, ng_offs.X - padding2, ng_offs.Y - padding, ng_offs.X + padding2, ng_offs.Y + padding, ref outPos, 5))
                    {
                        MouseClick(p1.x + outPos.X + 10, p1.y + outPos.Y + 10);
                        if (bmp != null)
                        {
                            bmp.Dispose();
                            bmp = null;
                        }

                        // NG ダイアログが消えるのを待つ
                        int j;
                        for (j = 0; j < 10; j++)
                        {
                            GetClientRect(m_fme_hwnd, ref clientrect);

                            p1.x = clientrect.left;
                            p1.y = clientrect.top;
                            p2.x = clientrect.right;
                            p2.y = clientrect.bottom;

                            //クライアント領域座標をスクリーン座標に変換
                            ClientToScreen(m_fme_hwnd, ref p1);
                            ClientToScreen(m_fme_hwnd, ref p2);

                            iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                            bmp = scr.Capture(iRect);
                            if (!ContainBitmap(mNgBmp, bmp, ng_offs.X - padding2, ng_offs.Y - padding, ng_offs.X + padding2, ng_offs.Y + padding, ref outPos, 5))
                            {
                                if (bmp != null)
                                {
                                    bmp.Dispose();
                                    bmp = null;
                                }
                                break;
                            }
                            // 0.5[s] wait
                            System.Threading.Thread.Sleep(500);
                        }
                        break;
                    }
                    if (bmp != null)
                    {
                        bmp.Dispose();
                        bmp = null;
                    }

                    // 0.5[s] wait
                    FitWindowSize();
                    System.Threading.Thread.Sleep(500);
                }
            }

            //// Start領域
            //iRect = new Rectangle(p1.x+417, p1.y+512, 36, 28);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEstart.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //// Stop領域
            //iRect = new Rectangle(p1.x + 556, p1.y + 512, 34, 28);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEstop.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //// NG領域
            //iRect = new Rectangle(p1.x + 489, p1.y + 357, 21, 19);
            //bmp = scr.Capture(iRect);
            //filePath = @"F:\FMEng.bmp";
            //bmp.Save(filePath, ImageFormat.Bmp);

            //filePath = @"F:\screen.bmp";
            //Process.Start(filePath);

            //一秒間(1000ミリ秒)停止する
            System.Threading.Thread.Sleep(2000);

            if (bStartComplete)
            {
                using (Bouyomi bm = new Bouyomi())
                {
                    bm.Talk("えふえむいー配信を開始しました");
                }
            }
            else
            {
                using (Bouyomi bm = new Bouyomi())
                {
                    bm.Talk("えふえむいー起動失敗しました");
                }
                FMEGUI.Kill();
            }

            // ウインドウを最小化する
            ShowWindow(m_fme_hwnd, SW_MINIMIZE);
            return bStartComplete;
        }
Пример #33
0
        public static void StartNicoLive(Form mainForm)
        {
            Clipboard.Clear();

            const int padding = 3;
            const int padding2 = 3;

            FindXSplitMainWindow();

            IntPtr hAfterWnd = IntPtr.Zero;

            // ウインドウが最小化状態だったか否か
            bool original_iconic = IsIconic(hXSplitWnd);

            if (!original_iconic)
            {
                hAfterWnd = GetWindow(hXSplitWnd, (uint)GetWindow_Cmd.GW_HWNDPREV);
                while (hAfterWnd != IntPtr.Zero && !IsWindowVisible(hAfterWnd))
                {
                    hAfterWnd = GetWindow(hAfterWnd, (uint)GetWindow_Cmd.GW_HWNDPREV);
                }
            }

            // クライアント領域のスクリーンをキャプチャする
            Bitmap bmp = null;

            //// ウィンドウを元に戻す
            ShowWindow(hXSplitWnd, SW_RESTORE);
            System.Threading.Thread.Sleep(500);

            //// ウインドウをフォアグラウンドに
            SetForegroundWindow(hXSplitWnd);  // アクティブにする
            System.Threading.Thread.Sleep(500);

            //// ウインドウが表示されるまで待つ
            WINDOWPLACEMENT wndplace = new WINDOWPLACEMENT();
            do
            {
                System.Threading.Thread.Sleep(500);
                GetWindowPlacement(hXSplitWnd, ref wndplace);
            } while ((wndplace.showCmd != SW_SHOWNORMAL));

            bool bStartPushed = false;

            using (ScreenCapture scr = new ScreenCapture())
            {
                // クライアント領域のサイズを取得
                RECT clientrect = new RECT();
                POINT p1, p2;
                Rectangle iRect;

                // クライアント領域の取得
                GetClientRect(hXSplitWnd, ref clientrect);

                p1.x = clientrect.left;
                p1.y = clientrect.top;
                p2.x = clientrect.right;
                p2.y = clientrect.bottom;

                //クライアント領域座標をスクリーン座標に変換
                ClientToScreen(hXSplitWnd, ref p1);
                ClientToScreen(hXSplitWnd, ref p2);

                //取り込む座標を矩形領域に設定
                iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);

                Point outPos = new Point();
                Point haishin_offs = new Point(125, 3);
                Point nico_offs = new Point(143, 25);

                int i;
                // 配信メニューを押す
                for (i = 0; i < 60; i++)
                {
                    bmp = scr.Capture(iRect);
                    //bmp.Save("D:\\start_wait.png");
                    if (ContainBitmap(mHaishinBmp, bmp, haishin_offs.X - padding2, haishin_offs.Y - padding, haishin_offs.X + padding2, haishin_offs.Y + padding, ref outPos, 5))
                    {
                        using (Bouyomi bm = new Bouyomi())
                        {
                            bm.Talk("配信メニュー選択");
                        }
                        System.Threading.Thread.Sleep(500);
            //                        MouseClick(p1.x + 139, p1.y + 13);
                        bStartPushed = true;
                        // 立ち上がるのを待つ
                        break;
                    }
                    bmp.Dispose();
                    bmp = null;
                    //// ウィンドウを元に戻す
                    ShowWindow(hXSplitWnd, SW_RESTORE);
                    // アクティブにする
                    SetForegroundWindow(hXSplitWnd);

                    // ウエイト
                    System.Threading.Thread.Sleep(500);

                    // クライアント領域を再取得
                    GetClientRect(hXSplitWnd, ref clientrect);

                    p1.x = clientrect.left;
                    p1.y = clientrect.top;
                    p2.x = clientrect.right;
                    p2.y = clientrect.bottom;

                    //クライアント領域座標をスクリーン座標に変換
                    ClientToScreen(hXSplitWnd, ref p1);
                    ClientToScreen(hXSplitWnd, ref p2);

                    //取り込む座標を矩形領域に設定
                    iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);
                }

                //// ニコ生を押す
                if (bStartPushed)
                {

                    for (i = 0; i < 60; i++)
                    {
                        // ここでマウスクリック
                        MouseClick(p1.x + 139, p1.y + 13);

                        System.Threading.Thread.Sleep(500);
                        // もはや、座標は変えられない
                        bmp = scr.Capture(iRect);
                        //bmp.Save("D:\\nico_wait.png");
                        if (ContainBitmap(mNicoBmp, bmp, nico_offs.X - padding2, nico_offs.Y - padding, nico_offs.X + padding2, nico_offs.Y + 64 + padding, ref outPos, 5))
                        {
                            using (Bouyomi bm = new Bouyomi())
                            {
                                bm.Talk("ニコ生プッシュ");
                            }
                            MouseClick(p1.x + outPos.X + 8, p1.y + outPos.Y + 14);
            //                            MouseClick(p1.x + 151, p1.y + 38);

                            break; // 押し下げ成功
                        }
                        bmp.Dispose();
                        bmp = null;

                        //// ウィンドウを元に戻す
                        ShowWindow(hXSplitWnd, SW_RESTORE);
                        // アクティブにする
                        SetForegroundWindow(hXSplitWnd);

                        System.Threading.Thread.Sleep(500);

                        // クライアント領域を再取得
                        GetClientRect(hXSplitWnd, ref clientrect);

                        p1.x = clientrect.left;
                        p1.y = clientrect.top;
                        p2.x = clientrect.right;
                        p2.y = clientrect.bottom;

                        //クライアント領域座標をスクリーン座標に変換
                        ClientToScreen(hXSplitWnd, ref p1);
                        ClientToScreen(hXSplitWnd, ref p2);

                        //取り込む座標を矩形領域に設定
                        iRect = new Rectangle(p1.x, p1.y, p2.x - p1.x + 1, p2.y - p1.y + 1);
                    }
                }
            }

            System.Threading.Thread.Sleep(2000);

            // ウインドウを最小化する
            if (original_iconic)
            {
                ShowWindow(hXSplitWnd, SW_MINIMIZE);
            }
            else
            {
                Thread th = new Thread(delegate()
                {
                    Thread.Sleep(5000);
                    mainForm.Invoke((Action)delegate()
                    {
                        mainForm.Activate();
                    });

                    //if (hAfterWnd != null && hAfterWnd != (IntPtr)(-1) && hAfterWnd != (IntPtr)(-2))
                    //{
                    //    SetWindowPos(hXSplitWnd, hAfterWnd, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);
                    //}
                });
                th.Start();
            }
        }
Пример #34
0
 public static Bitmap CapturePrimaryScreen(this ScreenCapture screenCapture)
 {
     return(screenCapture.Capture(new Rectangle(0, 0,
                                                (int)SystemParameters.PrimaryScreenWidth, (int)SystemParameters.PrimaryScreenHeight)));
 }
Пример #35
0
        static void Main(string[] args)
        {
            String filePath = "";
            String fileName = "SRMTools.jpg";

            ArgsParser.Options("-p|--path,-f|--fullscreen,-t|--thumbnail,-r|--resize,-wr|resizebywidth,-hr|resizebyheight");
            ArgsParser.Parse(args);
            if (!ArgsParser.HasValidArgs())
            {
                ShowHelp(ArgsParser.GetArgArray());
                return;
            }

            String filePathArgs = ArgsParser.GetValueString("-p");

            if (filePathArgs.Length > 0)
            {
                filePath = filePathArgs;
                if (!filePath.EndsWith("\\"))
                {
                    filePath += "\\";
                }
            }

            String fileNameArgs = ArgsParser.GetValueString("-f");

            if (fileNameArgs.Length > 0)
            {
                fileName = fileNameArgs;
                if (filePath.Length > 0)
                {
                    ScreenCapture.Capture(filePath, fileName);
                }
                else
                {
                    ScreenCapture.Capture(fileName);
                }
            }

            String thumbFileNameArgs = ArgsParser.GetValueString("-t");

            if (thumbFileNameArgs.Length > 0)
            {
                fileName = thumbFileNameArgs;
                if (filePath.Length > 0)
                {
                    ScreenCapture.CaptureThumbnail(filePath, fileName);
                }
                else
                {
                    ScreenCapture.CaptureThumbnail(fileName);
                }
            }

            String resizeArgs = ArgsParser.GetValueString("-r");

            if (resizeArgs.Length > 0)
            {
                String[] newSize = resizeArgs.ToUpper().Split('X');
                if (newSize.Length > 0)
                {
                    var screen = ScreenCapture.Resize(filePath + fileName, int.Parse(newSize[0]), int.Parse(newSize[1]));
                    if (File.Exists(filePath + fileName))
                    {
                        File.Delete(filePath + fileName);
                    }
                    screen.Save(filePath + fileName, ImageFormat.Jpeg);
                }
            }

            String resizeWidthArgs = ArgsParser.GetValueString("-wr");

            if (resizeWidthArgs.Length > 0)
            {
                var screen = ScreenCapture.ResizeByWidth(filePath + fileName, int.Parse(resizeWidthArgs));
                if (File.Exists(filePath + fileName))
                {
                    File.Delete(filePath + fileName);
                }
                screen.Save(filePath + fileName, ImageFormat.Jpeg);
            }

            String resizeHeightArgs = ArgsParser.GetValueString("-hr");

            if (resizeHeightArgs.Length > 0)
            {
                var screen = ScreenCapture.ResizeByHeight(filePath + fileName, int.Parse(resizeHeightArgs));
                if (File.Exists(filePath + fileName))
                {
                    File.Delete(filePath + fileName);
                }
                screen.Save(filePath + fileName, ImageFormat.Jpeg);
            }
        }