示例#1
0
 private void btLocateWnd_Click(object sender, EventArgs e)
 {
     if (cbMainWnd.Text.Trim().Length > 0)
     {
         IntPtr wnd = Win32Locator.locateWindow(String.Format("S({0:S})[0]", cbMainWnd.Text.Trim()), null);
         if (wnd == IntPtr.Zero)
         {
             main_wnd_str = null;
             MessageBox.Show(String.Format("定位窗口 {0:s} 失败", cbMainWnd.Text.Trim()));
             lbLayout.Text = "...";
             return;
         }
         main_wnd_str = cbMainWnd.Text.Trim();
         Win32Locator.SetForeGWindow(wnd);
         main_wnd_rect = Win32Locator.centerWindow(wnd);
         lbLayout.Text = String.Format("屏幕:{0:d}X{1:d},窗口({2:d},{3:d},{4:d},{5:d})", Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height,
                                       main_wnd_rect.Left, main_wnd_rect.Top, main_wnd_rect.Right, main_wnd_rect.Bottom);
         Trace.WriteLine(String.Format("Locate the Wnd at center"));
     }
 }
示例#2
0
        private Boolean collectWndEnv(string v)
        {
            IntPtr wnd = Win32Locator.locateWindow(String.Format("S({0:S})[0]", v), null);

            if (wnd == IntPtr.Zero)
            {
                MessageBox.Show(String.Format("定位窗口 {0:s} 失败", v));
                return(false);
            }
            try
            {
                String fn = "shuikong-screen.jpg";
                Win32Locator.SetForeGWindow(wnd);
                Win32Locator.centerWindow(wnd);
                Bitmap       pic     = Win32Locator.CaptureScreen();
                MemoryStream mStream = new MemoryStream();
                pic.Save(mStream, ImageFormat.Jpeg);
                WebClient w_cli = new WebClient();
                String    url   = string.Format("{0:s}log?client_id={1:s}&name={2:d}", ConfigurationManager.AppSettings["service_url"], Program.mAppCode, fn);
                w_cli.UploadData(new Uri(url), mStream.ToArray());
                MessageBox.Show("上载文件成功,请联系技术支持生成配置文件");
            }
            catch (IOException e)
            {
                MessageBox.Show("写文件错误,请检查磁盘空间");
                return(false);
            }
            catch (WebException e)
            {
                MessageBox.Show("上载文件失败,请联系技术支持");
                return(false);
            }
            catch (Exception e) {
                MessageBox.Show("系统异常");
                return(false);
            }
            return(true);
        }