Example #1
0
        /// <summary>
        /// Is the active window an open "Contact" 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 IsOpenContactWindow(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);
            var element       = (AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Edit, "4481", "Company:") ??
                                 AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Edit, "4480", "Job Title:")) ??
                                AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Edit, "4096", "FullName");

            retVal = (element != null);

            if (retVal)
            {
                if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "_WwG", "ControlType.Pane", "", "Message"))
                {
                    subType = OutlookControlSubType.ContactMessageField;
                }
            }

            Log.Debug("Returning " + retVal);
            return(retVal);
        }
Example #2
0
        /// <summary>
        /// Is the active window an open Appointment 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 IsOpenAppointmentWindow(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);
            var element       = AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.ComboBox, "4098", "Start Date:") ??
                                AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Edit, "4100", "Subject:");

            retVal = (element != null);

            if (retVal)
            {
                if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "RichEdit20WPT", "ControlType.Edit", "4100", "Subject:"))
                {
                    subType = OutlookControlSubType.AppointmentSubjectField;
                }
                else if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "_WwG", "ControlType.Pane", "", "Message"))
                {
                    subType = OutlookControlSubType.AppointmentMessageBodyField;
                }
            }

            Log.Debug("Returning " + retVal);
            return(retVal);
        }
Example #3
0
        /// <summary>
        /// Is the active window the Outlook Address book 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 IsAddressBookWindow(WindowActivityMonitorInfo monitorInfo, ref OutlookControlSubType subType)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var retVal = (windowElement != null) && (monitorInfo.Title.StartsWith("Address Book") &&
                                                     AgentUtils.IsElementByAutomationId(windowElement, "OutexABCLS",
                                                                                        "ControlType.Window", String.Empty));

            if (retVal)
            {
                if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "RichEdit20WPT", "ControlType.Edit", "101", "Search:"))
                {
                    subType = OutlookControlSubType.AddressBookSearchField;
                }
            }

            return(retVal);
        }
Example #4
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);
        }
Example #5
0
        /// <summary>
        /// Is the active window an open Outlook "Note" 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 IsOpenNoteWindow(WindowActivityMonitorInfo monitorInfo, ref OutlookControlSubType subType)
        {
            bool retVal = false;

            subType = OutlookControlSubType.Unknown;

            var element = AgentUtils.GetElementOrAncestorByAutomationId(monitorInfo.FocusedElement, "RichEdit20WPT", "ControlType.Edit", "4159");

            if (element != null)
            {
                var name = element.Current.Name;
                retVal = (name == "Note text");
            }

            if (retVal)
            {
                if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "RichEdit20WPT", "ControlType.Edit", "4159"))
                {
                    subType = OutlookControlSubType.OpenNoteMessageBodyField;
                }
            }

            return(retVal);
        }
Example #6
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);
            }

            if (!monitorInfo.Title.Contains(" - Message (HTML)") &&
                !monitorInfo.Title.Contains(" - Message (Plain Text)") &&
                !monitorInfo.Title.Contains(" - Message (Rich Text)"))
            {
                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.Text, "4099") ??
                                AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Edit, "4099");

            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;

                        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.Pane", "", "Message"))
                            {
                                subType = OutlookControlSubType.NewEmailMessageBodyField;
                            }
                        }
                    }
                }
            }
            else
            {
                Log.Debug("Could not find element");
                retVal = false;
            }

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