コード例 #1
0
        bool FindApp()
        {
            // 我的outlook没有激活, 会弹窗, 要先关闭弹窗
            if (app_ == null)
            {
                // TODO -- kill outlook
                Process process = Process.Start("Outlook");
                UIA.WaitProcess(process.Id);
                app_ = AutomationElement.FromHandle(process.MainWindowHandle);
            }

            /*
             * StringBuilder sb2 = new StringBuilder();
             * AutomationElementCollection ac2 = app_.FindAll(TreeScope.Descendants,
             * new PropertyCondition(AutomationElement.ClassNameProperty, "NetUITextbox"));
             * for (int i = 0; i < ac2.Count; ++i)
             * {
             *      AutomationElement wd = ac2[i];
             *      sb2.Append("name: " + wd.Current.Name + ", classname: " + wd.Current.ClassName + "\n");
             * }
             * MessageBox.Show(sb2.ToString());
             *
             * if (app_ != null)
             * {
             *      MessageBox.Show(app_.Current.Name + " " + app_.Current.ClassName);
             * }
             */

            return(app_ == null ? false : true);
        }
コード例 #2
0
        public string Search(string info)
        {
            AutomationElement search = FindElement(outlookSearchFrameName_);

            if (search == null)
            {
                MessageBox.Show("found failed\n");
                return("没有找到邮件");
            }

            int mailAll = GetInBoxMailNumber();

            UIA.SetValue(search, info);

            // 等待输入完成
            Thread.Sleep(2000);

            int mailSearchAll = GetInBoxMailNumber();

            return(string.Format("找到{0}/{1}封邮件", mailSearchAll, mailAll));
        }