예제 #1
0
 public override void excute()
 {
     try
     {
         /*
          * 1.获取网盘窗口句柄
          * 2.前置,并最大化
          * 3.计算暂停位置,和开启位置
          * 4.先点击暂停,休眠5s,后点击启动
          *
          */
         IntPtr intPtr = WindowFormAPI.FindWindow(null, "PanDownload");
         WindowFormAPI.SetForegroundWindow(intPtr);
         WindowFormAPI.ShowWindow(intPtr, 1);
         Rect rect;
         WindowFormAPI.GetWindowRect(intPtr, out rect);
         int width  = rect.Right - rect.Left;
         int height = rect.Bottom - rect.Top;
         WindowFormAPI.MoveWindow(intPtr, 0, 0, width, height, false);
         int startX = 500, startY = 100;
         int stopX = 600, stopY = 100;
         WindowFormAPI.ClickByLocation(stopX, stopY);
         WindowFormAPI.ClickByLocation(stopX, stopY);
         Thread.Sleep(5000);
         WindowFormAPI.ClickByLocation(startX, startY);
         WindowFormAPI.ClickByLocation(startX, startY);
     }
     catch (Exception ex)
     {
     }
 }
예제 #2
0
파일: Form1.cs 프로젝트: coderli7/WinForm
        private void button2_Click(object sender, EventArgs e)
        {
            //WindowFormAPI.CloseFormByTitle("发起会话");

            //WindowFormAPI.MinOrMaxWindowFormByTitle(new string[] { "发起会话" }, 2);

            WindowFormAPI.MinOrMaxWindowFormByTitle(new string[] { "TeamViewer Panel", "发起会话" }, 2);
        }
예제 #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            AutomationElement calWindow = null;



            //2362396
            int parent = 787508;
            int id     = WindowFormAPI.GetDlgCtrlID(new IntPtr(parent));

            var res = WindowFormAPI.GetChildWindows(parent);

            List <int> childs = WindowFormAPI.GetChildWindows(id);
        }
예제 #4
0
파일: Program.cs 프로젝트: coderli7/WinForm
        static void Main(string[] args)
        {
            IntPtr tipsForm = WindowFormAPI.FindWindow(null, "提示信息");

            if (tipsForm.ToInt32() > 0)
            {
                IntPtr sureBtn = WindowFormAPI.GetDlgItem(tipsForm, 2);
                IntPtr tipInfo = WindowFormAPI.GetDlgItem(tipsForm, 65535);



                StringBuilder s = new StringBuilder(512);
                int           i = WindowFormAPI.GetWindowTextW(tipInfo, s, s.Capacity);


                if (sureBtn.ToInt32() > 0)
                {
                    WindowFormAPI.ClickByIntPtr(sureBtn);
                }
            }
        }
예제 #5
0
파일: Form1.cs 프로젝트: coderli7/WinForm
        private void button1_Click(object sender, EventArgs e)
        {
            #region 1.获取到微信窗口,最大化,前置
            IntPtr weChatForm = WindowFormAPI.FindWindow("WeChatMainWndForPC", null);
            //注意,最大化,要在设置前置之前
            WindowFormAPI.ShowWindow(weChatForm, 3);
            WindowFormAPI.SetForegroundWindow(weChatForm);
            #endregion

            #region 2.点击搜索栏,粘贴搜索内容,点击最新的一条结果
            MouseFlag.MouseLefClickEvent(150, 35, 0);
            SetClipBordText(this.richTextBox1.Text);
            ControlKeyBoardClick(Keys.V);
            MouseFlag.MouseLefClickEvent(150, 100, 0);
            #endregion

            #region 3.点击内容框,ctrl+v,回车发送
            WindowFormAPI.ClickByLocation(700, 800);
            SetClipBordText("您的报价是,总计1000元!");
            ControlKeyBoardClick(Keys.V);
            WindowFormAPI.PostMessage(Keys.Enter, 0, 0, 0);
            WindowFormAPI.PostMessage(Keys.Enter, 0, WindowFormAPI.KEYEVENTF_KEYUP, 0);
            #endregion
        }
예제 #6
0
파일: Form1.cs 프로젝트: coderli7/WinForm
 /// <summary>
 /// 触发Ctrl键盘+某个键盘字符,(如ctrl+c 或者 ctrl+v)
 /// </summary>
 /// <param name="key"></param>
 private void ControlKeyBoardClick(Keys key)
 {
     WindowFormAPI.PostMessage(Keys.ControlKey, 0, 0, 0);
     WindowFormAPI.PostMessage(key, 0, 0, 0);
     WindowFormAPI.PostMessage(Keys.ControlKey, 0, WindowFormAPI.KEYEVENTF_KEYUP, 0);
 }