Ejemplo n.º 1
0
        /// <summary>
        /// 通过窗体句柄获取标题值
        /// </summary>
        /// <param name="hWnd"></param>
        /// <returns></returns>
        public static string GetTitleValueByIntPtr(IntPtr hWnd)
        {
            string        titleVal   = "";
            StringBuilder titleValSb = new StringBuilder(1024);

            WindowFormAPI.GetWindowTextW(hWnd, titleValSb, titleValSb.Capacity);
            titleVal = titleValSb.ToString();
            return(titleVal);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 弹窗提示,自动操作,如弹出硬件特征码校验,自动点击提交申请。
        /// </summary>
        private void TipsCheck()
        {
            IntPtr tipsForm = WindowFormAPI.FindWindow(null, "提示信息");

            if (tipsForm.ToInt32() > 0)
            {
                IntPtr sureBtn = WindowFormAPI.GetDlgItem(tipsForm, 2);
                IntPtr tipInfo = WindowFormAPI.GetDlgItem(tipsForm, 65535);
                if (tipInfo.ToInt32() > 0)
                {
                    StringBuilder s = new StringBuilder(512);
                    int           i = WindowFormAPI.GetWindowTextW(tipInfo, s, s.Capacity);
                    if (s.ToString().Contains("密码错误"))
                    {
                        passwordError = true;
                        SetText("用户名密码错误");
                    }
                }
                if (sureBtn.ToInt32() > 0)
                {
                    WindowFormAPI.ClickByIntPtr(sureBtn);
                }
            }

            IntPtr hardwareTipsForm = WindowFormAPI.FindWindow(null, "EasyConnect");

            if (hardwareTipsForm.ToInt32() > 0)
            {
                //硬件特征码校验
                IntPtr yingjianBtn = WindowFormAPI.GetDlgItem(hardwareTipsForm, 1201);
                //提交申请ID
                IntPtr submitBtn = WindowFormAPI.GetDlgItem(hardwareTipsForm, 1274);
                if (yingjianBtn.ToInt32() > 0 && submitBtn.ToInt32() > 0)
                {
                    WindowFormAPI.ClickByIntPtr(submitBtn);
                }
            }

            IntPtr jsTips = WindowFormAPI.FindWindow(null, "脚本错误");

            if (jsTips.ToInt32() > 0)
            {
                int tmp = 0;
                WindowFormAPI.SendMessage(jsTips.ToInt32(), WindowFormAPI.WM_CLOSE, 0, ref tmp);
            }
        }