Пример #1
0
        public void MyMouseClick(Dictionary <String, int> clickDic, string clickType)
        {
            int X = clickDic["X"];
            int Y = clickDic["Y"];

            LogInfo(string.Format("鼠标点击({2})坐标:{0},{1}", X, Y, clickType));
            if (clickType == "L")
            {
                MouseFlag.MouseLefClickEvent(X, Y, 0);
            }
            else if (clickType == "R")
            {
                MouseFlag.MouseRightClickEvent(X, Y, 0);
            }
        }
Пример #2
0
 /// <summary>
 /// 点击某个位置
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public static void ClickByLocation(int x, int y)
 {
     MouseFlag.MouseLefClickEvent(x, y, 0);
 }
Пример #3
0
        /// <summary>
        /// 操作微信,并获取动态验证码
        /// </summary>
        /// <returns></returns>
        private string GetQrCode()
        {
            String qrCode = "";

            try
            {
                if (!String.IsNullOrEmpty(Config.FixedQrCode))
                {
                    return(Config.FixedQrCode);
                }

                if (DateTime.Now.Hour >= 21 || DateTime.Now.Hour < 7)
                {
                    qrCode = "夜间不允许自动获取验证码";
                    return(qrCode);
                }

                //IntPtr intptr1 = WindowFormAPI.FindWindow("WeWorkWindow", null);
                //IntPtr intptr2 = WindowFormAPI.FindWindow("WeChatLogin", null);
                //if (intptr1 == null || intptr1.ToInt32() == 0)
                //{
                //    qrCode = "当前企业微信未登录";
                //    return qrCode;
                //}

                if (GetWeChatQrCodeCount > 20)
                {
                    qrCode = "当前获取验证码次数已用完";
                    return(qrCode);
                }


                //1.获取句柄并最大化,并前置,避免最小化等原因造成无法点击
                weChatForm = WindowHanler.WindowFormAPI.FindWindow(null, "企业微信");
                LogInfo("===========开始获取验证码===========");
                SetWeChatFormBefore();

                //2.点击消息菜单,切花到动态验证码,注意次步骤一定要设置动态验证码为置顶状态
                LogInfo("后台获取微信验证码");
                ClickMsgWidthHeight("L");
                Thread.Sleep(1000);
                LogInfo("点击微信消息菜单");
                ClickMenuWidthHeight("L");
                Thread.Sleep(1000);
                LogInfo("点击右面空白处");
                ClickNullSpaceClickWidthHeight("L");

                //3.点击重新获取验证码,并将获取页面关闭-OLD
                //ClickGenQrCodeWidthHeight("L");
                LogInfo("主动发送微信验证码");

                //2018.10.17 新增同步获取验证码方法
                String qrCodeNew = GetQrCodeSync();
                if (!string.IsNullOrEmpty(qrCodeNew))
                {
                    return(qrCodeNew);
                }

                CommonUse.PostHtml(Config.WX_URL, string.Format("{0}={1}", "userid_weixin", Config.Userid_Weixin));
                GetWeChatQrCodeCount++;

                Thread.Sleep(3000);
                WindowFormAPI.CloseFormByTitle("动态密码认证");

                //3.1如果使用微信登陆,则先按照截图方式解析一次,如果不行,再行复制粘贴
                if (Config.USE_BD_API)
                {
                    LogInfo("API解析验证码-开始");
                    qrCode = GetQrCodeByImage();
                    LogInfo("API解析验证码-完成");
                    LogInfo("API解析验证码-结果:" + qrCode);
                }
                if (string.IsNullOrEmpty(qrCode))
                {
                    SetWeChatFormBefore();
                    //4.如果经过图片解析,仍然不能成功的,用用賦值粘貼
                    LogInfo("API未获取到验证码");
                    LogInfo("开始点击右键");
                    ClickQrCodeLeftClickWidthHeight("R");
                    Thread.Sleep(1000);
                    //鼠标移动到空白处
                    LogInfo("移动鼠标到空白处");
                    MouseFlag.SetCursorPos(Config.NullSpaceClickWidthHeight["X"], Config.NullSpaceClickWidthHeight["Y"]);
                    Thread.Sleep(1000);
                    LogInfo("移动鼠标到复制处");
                    MouseFlag.SetCursorPos(Config.QrCodeRightCopyClickWidthHeight["X"], Config.QrCodeRightCopyClickWidthHeight["Y"]);
                    Thread.Sleep(1000);
                    LogInfo("点击复制");
                    ClickQrCodeRightCopyClickWidthHeight("L");
                    Thread.Sleep(1000);
                    //5.获取剪切板验证码并粘贴
                    qrCode = getClipBrdStr();
                    if (!string.IsNullOrEmpty(qrCode))
                    {
                        if (Regex.IsMatch(qrCode, @"\d{6}"))
                        {
                            qrCode = Regex.Match(qrCode, @"\d{6}").Value;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogInfo(ex.Message + ex.StackTrace);
            }
            LogInfo("===========结束获取验证码===========");
            return(qrCode);
        }