示例#1
0
        void keyboardHook_KeyDown(object sender, KeyEventArgs e)
        {
            if (capture_status == false)
            {
                this.recordStartButton.Enabled = true;
                return;
            }
            if (e.Control && e.KeyCode == Keys.F)
            {
                this.recordStartButton.Enabled = true;
                String position = String.Format("{0:d},{1:d}", cur_mouse_x, cur_mouse_y);
                this.lvFIelds.Items.Add(createListItem(cbContent.Text, position));
                capture_status = false;
                keyboardHook.Stop();
                mouseHook.Stop();
                Win32Locator.SetForeGWindow(this.Handle);
            }

            /*events.Add(
             *  new MacroEvent(
             *      MacroEventType.KeyDown,
             *      e,
             *      Environment.TickCount - lastTimeRecorded
             *  ));
             *
             * lastTimeRecorded = Environment.TickCount;*/
        }
 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 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);
        }
示例#4
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"));
     }
 }
示例#5
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);
        }