Exemple #1
0
        /// <summary>
        /// 截图-自选矩形区域
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonRectangeArea_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)  // 单击鼠标左键
            {
                this.Visible = false;
                System.Threading.Thread.Sleep(DELAY_TIME);  //等待
                TransparentForm transparentForm = new TransparentForm(true);
                transparentForm.ShowDialog();
                if (transparentForm.DialogResult == DialogResult.OK)
                {
                    //截图
                    //Bitmap bmp = captureBitmap(transparentForm.AreaX, transparentForm.AreaY, transparentForm.AreaWidth, transparentForm.AreaHeight);
                    Bitmap bmp = transparentForm.CaptureBitmap;
                    afterCapture(bmp);
                }
                else if (transparentForm.DialogResult == DialogResult.Cancel)
                {
                    // 没有截图
                }

                transparentForm.Close();
            }
        }
Exemple #2
0
        /// <summary>
        /// 截图-滚动图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonRollScreen_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)  // 单击鼠标左键
            {
                //this.WindowState = FormWindowState.Minimized;
                this.Visible = false;
                //选中区域默认为屏幕范围,不包括任务栏
                Rectangle selectRect = Screen.GetWorkingArea(this);

                System.Threading.Thread.Sleep(DELAY_TIME);  //等待
                // 区域选择
                TransparentForm transparentForm = new TransparentForm(false);
                transparentForm.ShowDialog();
                if (transparentForm.DialogResult == DialogResult.OK)
                {
                    //截图区域
                    selectRect = transparentForm.GetSelectRectangle();
                }
                else if (transparentForm.DialogResult == DialogResult.Cancel)
                {
                    // 全屏幕范围
                }
                transparentForm.Close();
                MainForm.TxtWrite("roll.txt", "start **********\r\n");

                System.Threading.Thread.Sleep(DELAY_TIME);
                hWnd = User32.GetForegroundWindow();
                int           length     = User32.GetWindowTextLength(hWnd);
                StringBuilder windowName = new StringBuilder(length + 1);
                User32.GetWindowText(hWnd, windowName, windowName.Capacity);
                TxtWrite("roll.txt", "+" + windowName.ToString() + foreHwnd.ToString() + "\r\n");
                Bitmap bitmap = captureLongBitmap(selectRect);
                afterCapture(bitmap);
                MainForm.TxtWrite("roll.txt", "结束 **********\r\n");
                this.Visible = true;
            }
        }