Esempio n. 1
0
        private void test_sceen_Click(object sender, EventArgs e)
        {
            Bitmap bmp = ScreenHelpers.CaptureWindow(pWndTab);

            bmp.Save("测试截图.bmp");
            MessageBox.Show("测试截图文件已被保存");
        }
Esempio n. 2
0
        public static Point GetScreenPoint(String key, IntPtr pWnd)
        {
            Point point = getPointFromConfig(key);

            Rectangle wndRect = ScreenHelpers.getClientRect(pWnd);

            return(new Point(point.X + wndRect.X, point.Y + wndRect.Y));
        }
Esempio n. 3
0
        public static Rectangle GetScreenRect(String key, IntPtr pWnd)
        {
            Rectangle rect  = getRectangleFromConfig(key);
            Point     point = new Point(0, 0);

            ScreenHelpers.ClientToScreen(pWnd, ref point);
            rect.X += point.X;
            rect.Y += point.Y;
            return(rect);
        }
Esempio n. 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            // 画图
            Graphics dc   = e.Graphics;
            Pen      pen  = new Pen(Color.Red, 1);
            Font     font = new Font("Tahoma", 8);

            Brush brush = (Brush)Brushes.Red;

            Rectangle rectIE = ScreenHelpers.getClientRect(pWnd);
            Point     point;
            Rectangle rect;

            dc.DrawRectangle(pen, rectIE);

            // 价格
            rect = Configuration.GetScreenRect(Configuration.CONFIG_PRICE_RECT, pWnd);
            dc.DrawRectangle(pen, rect);

            // 时间
            rect = Configuration.GetScreenRect(Configuration.CONFIG_TIME_RECT, pWnd);
            dc.DrawRectangle(pen, rect);

            // 加价
            point = Configuration.GetScreenPoint(Configuration.CONFIG_INC_IN_POINT, pWnd);
            dc.FillRectangle(brush, point.X, point.Y, 5, 5);

            // 加价确认
            point = Configuration.GetScreenPoint(Configuration.CONFIG_INC_BTN_POINT, pWnd);
            dc.FillRectangle(brush, point.X, point.Y, 5, 5);

            // 出价
            point = Configuration.GetScreenPoint(Configuration.CONFIG_SUBMIT_BTN_POINT, pWnd);
            dc.DrawString("出价", font, brush, new Rectangle(point.X, point.Y, 40, 15));


            // 确认
            point = Configuration.GetScreenPoint(Configuration.CONFIG_CONFIRM_BTN_POINT, pWnd);
            dc.DrawString("确认", font, brush, new Rectangle(point.X, point.Y, 40, 15));



            // 取消
            point = Configuration.GetScreenPoint(Configuration.CONFIG_CANCEL_BTN_POINT, pWnd);
            dc.DrawString("取消", font, brush, new Rectangle(point.X, point.Y, 40, 15));
        }
Esempio n. 5
0
 private String ocrText(IntPtr pWndIE, Rectangle rect)
 {
     try
     {
         Bitmap bmp = ScreenHelpers.CaptureWindow(pWndIE, rect);
         using (var page = engine.Process(bmp, PageSegMode.SingleLine))
         {
             var text = page.GetText();
             if (text != "")
             {
                 return(text.Replace(" ", ""));
             }
             else
             {
                 return("unrecorded");
             }
         }
     }
     catch (Exception)
     {
         return("unrecorded");
     }
 }
Esempio n. 6
0
        private void setIEWnd()
        {
            pWndIE = FindWindow("IEFrame", null);
            while (pWndIE == IntPtr.Zero)
            {
                Thread.Sleep(1000);
                pWndIE = FindWindow("IEFrame", null);
            }

            this.pWndTab = FindWindowEx(pWndIE, IntPtr.Zero, "Frame Tab", null);
            this.pWndTab = FindWindowEx(pWndTab, IntPtr.Zero, "TabWindowClass", null);
            this.pWndTab = FindWindowEx(pWndTab, IntPtr.Zero, "Shell DocObject View", null);
            this.pWndTab = FindWindowEx(pWndTab, IntPtr.Zero, "Internet Explorer_Server", null);

            if (pWndTab == IntPtr.Zero)
            {
                //获得窗口title
                MessageBox.Show("关联IE窗口失败,请重试");
            }
            else
            {
                MessageBox.Show("关联IE窗口成功 title = " + ScreenHelpers.GetWindowTitle(pWndIE));
            }
        }