Beispiel #1
0
        /// <summary>
        /// Is the active window an open "Task" window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <param name="subType">The focused Outlook window control element </param>
        /// <returns>true if it is</returns>
        public bool IsOpenTaskWindow(WindowActivityMonitorInfo monitorInfo, ref OutlookControlSubType subType)
        {
            Log.Debug();

            subType = OutlookControlSubType.Unknown;

            bool retVal = true;

            if (monitorInfo.FocusedElement == null)
            {
                return(false);
            }

            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            if (windowElement == null)
            {
                return(false);
            }

            var element = (AgentUtils.FindElementByAutomationId(windowElement, "REComboBox20W", ControlType.ComboBox, "4481", R.GetString2("Outlook2013OpenTaskStatusFieldLabel")) ??
                           AgentUtils.FindElementByAutomationId(windowElement, "REComboBox20W", ControlType.ComboBox, "4480", R.GetString2("Outlook2013OpenTaskPriorityFieldLabel"))) ??
                          AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Edit, "4112", R.GetString2("Outlook2013OpenTaskPercentCompleteFieldLabel"));

            retVal = (element != null);

            if (retVal)
            {
                if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "RichEdit20WPT", "ControlType.Document", "4097"))
                {
                    subType = OutlookControlSubType.TaskSubjectField;
                }
                else if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "_WwG", "ControlType.Document", ""))
                {
                    subType = OutlookControlSubType.TaskMessageBodyField;
                }

                Log.Debug(subType.ToString());
            }

            Log.Debug("Returning " + retVal);
            return(retVal);
        }
Beispiel #2
0
        /// <summary>
        /// Is the active window a new or existing open email  window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <param name="isNewMessage">true if this is a new email window</param>
        /// <param name="subType">The focused Outlook window control element </param>
        /// <returns>true if it is</returns>
        public bool IsEmailMsgWindow(WindowActivityMonitorInfo monitorInfo, ref bool isNewMessage, ref OutlookControlSubType subType)
        {
            Log.Debug();

            isNewMessage = false;

            subType = OutlookControlSubType.Unknown;

            bool retVal = true;

            if (monitorInfo.FocusedElement == null)
            {
                return(false);
            }

            var title = monitorInfo.Title.ToLower();

            if (!title.Contains(R.GetString2("Outlook2013EmailTitleSuffixHTML").ToLower()) &&
                !title.Contains(R.GetString2("Outlook2013EmailTitleSuffixPlainText").ToLower()) &&
                !title.Contains(R.GetString2("Outlook2013EmailTitleSuffixRichText").ToLower()))
            {
                Log.Debug("Title: " + monitorInfo.Title);
                Log.Debug("TITLE DOES NOT MATCH.  RETURNING ");
                return(false);
            }

            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);
            var element       = AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Document, "4099");
            var toButton      = AgentUtils.FindElementByAutomationId(windowElement, "Button", ControlType.Button, "4352");

            if (element != null)
            {
                var patterns = element.GetSupportedPatterns();
                foreach (var pattern in patterns)
                {
                    if (String.Compare(pattern.ProgrammaticName, "ValuePatternIdentifiers.Pattern", true) == 0)
                    {
                        bool obj = (bool)element.GetCurrentPropertyValue(ValuePatternIdentifiers.IsReadOnlyProperty);

                        isNewMessage = !obj || (toButton != null);

                        if (isNewMessage)
                        {
                            if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "Button",
                                                                   "ControlType.Button", "4352"))
                            {
                                subType = OutlookControlSubType.NewEmailToButton;
                            }
                            else if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "Button",
                                                                        "ControlType.Button", "4353"))
                            {
                                subType = OutlookControlSubType.NewEmailCCButton;
                            }
                            else if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "Button",
                                                                        "ControlType.Button", "4256"))
                            {
                                subType = OutlookControlSubType.NewEmailCCButton;
                            }
                            else if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "RichEdit20WPT", "ControlType.Edit", "4101"))
                            {
                                subType = OutlookControlSubType.NewEmailSubjectField;
                            }
                            else if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "_WwG", "ControlType.Document", ""))
                            {
                                subType = OutlookControlSubType.NewEmailMessageBodyField;
                            }

                            Log.Debug(subType.ToString());
                        }
                    }
                }
            }
            else
            {
                Log.Debug("Could not find element");
                retVal = false;
            }

            Log.Debug("Returning " + retVal);
            return(retVal);
        }