bool ShuiKongInterface.SendRecipt(CheRequest req)
 {
     if (anch_wnd_handle != IntPtr.Zero)
     {
         Win32Locator.SetForeGWindow(anch_wnd_handle);
         if (this.first_editor_wnd_str != null)
         {
             IntPtr f_e = Win32Locator.locateWindow(this.first_editor_wnd_str, GetWndClassPostFix());
             if (f_e != IntPtr.Zero)
             {
                 Win32Locator.SetForeGWindow(f_e);
                 //SetFocus(f_e); the method doesn't work
             }
             else
             {
                 Trace.WriteLineIf(Program.trace_sw.TraceError, "did not find the window");
             }
         }
         for (int i = 0; i < this.max_send_ops; i++)
         {
             String str = actions[i].getValue(req);
             SendKeys.Send(str);
         }
         return(true);
     }
     return(false);
 }
        public bool DetectShuiKong()
        {
            IntPtr tmp = Win32Locator.locateWindow(anch_wnd_str, null);

            if (tmp != anch_wnd_handle)
            {
                anch_wnd_handle = tmp;
                AnchWndChangeEvt(tmp);
            }
            return(tmp != IntPtr.Zero);
        }
        bool ShuiKongInterface.DetectShuiKong()
        {
            IntPtr tmp = anch_wnd_handle;

            anch_wnd_handle = Win32Locator.locateWindow(anch_wnd_str, null);
            if (tmp != anch_wnd_handle)
            {
                Trace.WriteLineIf(Program.trace_sw.TraceVerbose, String.Format("locate {0:s} at {1:X00000}", anch_wnd_str, anch_wnd_handle));
                AnchWndChangeEvt(anch_wnd_handle);
            }
            //Trace.WriteLineIf(Program.trace_sw.TraceInfo, String.Format("locate {0:s} at {1:X00000}", anch_wnd_str, anch_wnd_handle));
            return(anch_wnd_handle != IntPtr.Zero);
        }
        public String TestLocationFunction()
        {
            String res = "Test:\n Detect " + anch_wnd_str + "\n";

            ((ShuiKongInterface)this).DetectShuiKong();
            res += Win32Locator.Dump() + Environment.NewLine;
            foreach (String wnd_str in mFieldMap.Keys)
            {
                String fix = GetWndClassPostFix() != null?GetWndClassPostFix() : "";

                res += "Find " + wnd_str + " with postfix " + fix + Environment.NewLine;
                Win32Locator.locateWindow(wnd_str, GetWndClassPostFix());
                res += Win32Locator.Dump();
            }
            return(res);
        }
        String ShuiKongInterface.TestLocationFunction()
        {
            String res = "Test:\n Detect " + anch_wnd_str + "\n";

            ((ShuiKongInterface)this).DetectShuiKong();
            res += Win32Locator.Dump() + Environment.NewLine;
            if (this.first_editor_wnd_str != null)
            {
                String fix = GetWndClassPostFix() != null?GetWndClassPostFix() : "";

                res += "find 1st Editor " + this.first_editor_wnd_str + "with postfix " + fix + Environment.NewLine;
                Win32Locator.locateWindow(this.first_editor_wnd_str, GetWndClassPostFix());
                res += Win32Locator.Dump();
            }
            return(res);
        }
        public bool SendRecipt(CheRequest req)
        {
            Boolean res = false;
            IntPtr  wnd_ptr;

            if (anch_wnd_handle != null)
            {
                Win32Locator.SetForeGWindow(anch_wnd_handle);
            }
            else
            {
                return(false);
            }
            foreach (String wnd_str in mFieldMap.Keys)
            {
                res = false;
                if (wnd_str != null)
                {
                    wnd_ptr = Win32Locator.locateWindow(wnd_str, GetWndClassPostFix());
                    if (wnd_ptr == null)
                    {
                        break;
                    }
                    String text = mFieldMap[wnd_str].GetValue(req, null).ToString();
                    try
                    {
                        SendMessage(wnd_ptr, WM_SETTEXT, IntPtr.Zero, text);
                        int r = Marshal.GetLastWin32Error();
                        if (r != 0)
                        {
                            Trace.WriteLineIf(Program.trace_sw.TraceError, String.Format("sendmessage with error code:{0:d}", res), "error");
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLineIf(Program.trace_sw.TraceError, "Send Text Failed with " + e.ToString(), "error");
                        break;
                    }
                }
                res = true;
            }
            return(res);
        }
Exemplo n.º 7
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"));
     }
 }
Exemplo n.º 8
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);
        }