Beispiel #1
0
        /// <summary>
        /// Checks if the window can be minimized
        /// </summary>
        /// <param name="fgHandle">window handle</param>
        /// <returns>true if it can</returns>
        private bool isWindowMinimizable(IntPtr fgHandle)
        {
            if (fgHandle == IntPtr.Zero)
            {
                return(false);
            }

            var window = AutomationElement.FromHandle(fgHandle);

            if (!Windows.IsApplicationFrameHostProcessWindow(fgHandle))
            {
                object objPattern;
                Log.Debug("controltype: " + window.Current.ControlType.ProgrammaticName);

                bool retVal = false;
                if (window.TryGetCurrentPattern(WindowPattern.Pattern, out objPattern))
                {
                    var windowPattern = objPattern as WindowPattern;
                    retVal = (windowPattern.Current.CanMinimize) && !windowPattern.Current.IsModal;

                    Log.Debug("canminimize: " + windowPattern.Current.CanMinimize + ", ismodal: " + windowPattern.Current.IsModal);
                }

                return(retVal);
            }

            var titleBar = findTitleBar(window);

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

            return(AgentUtils.FindElementByAutomationId(titleBar, "", ControlType.Button, "Minimize") != null);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        /// <summary>
        /// Is the active window the email inbox window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <returns>true if it is</returns>
        public bool IsInboxWindow(WindowActivityMonitorInfo monitorInfo)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var element = AgentUtils.FindElementByAutomationId(windowElement, "SuperGrid", ControlType.Table, "4704");

            return(element != null);
        }
Beispiel #5
0
        /// <summary>
        /// Is the active window the details window that is
        /// displayed when the user clicks on a name in the
        /// address book search results
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <returns>true if it is</returns>
        public bool IsAddressBookDetailsWindow(WindowActivityMonitorInfo monitorInfo)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var element = AgentUtils.FindElementByAutomationId(windowElement, "Edit", "ControlType.Edit", "2002", R.GetString2("Outlook2010AddrBookFirstNameFieldLabel")) ??
                          AgentUtils.FindElementByAutomationId(windowElement, "Edit", "ControlType.Edit", "2006", R.GetString2("Outlook2010AddrBookLastNameFieldLabel")) ??
                          AgentUtils.FindElementByAutomationId(windowElement, "Button", "ControlType.Button", "108", R.GetString2("Outlook2010AddrBookAddToContactsButtonText"));

            return(element != null);
        }
Beispiel #6
0
        /// <summary>
        /// Is the active window the details window that is
        /// displayed when the user clicks on a name in the
        /// address book search results
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <returns>true if it is</returns>
        public bool IsAddressBookDetailsWindow(WindowActivityMonitorInfo monitorInfo)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var element = AgentUtils.FindElementByAutomationId(windowElement, "Edit", "ControlType.Edit", "2002", "First:") ??
                          AgentUtils.FindElementByAutomationId(windowElement, "Edit", "ControlType.Edit", "2006", "Last:") ??
                          AgentUtils.FindElementByAutomationId(windowElement, "Button", "ControlType.Button", "108", "Add to Contacts");


            return(element != null);
        }
Beispiel #7
0
        /// <summary>
        /// Is the active window the Outlook calendar window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <returns>true if it is</returns>
        public bool IsCalendarWindow(WindowActivityMonitorInfo monitorInfo)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var element = AgentUtils.FindElementByAutomationId(windowElement, "AfxWndW", ControlType.Text, "");

            if (element != null)
            {
                Log.Debug("&&&&&& " + element.Current.Name);
                return(element.Current.Name.StartsWith("Calendar "));
            }

            return(false);
        }
Beispiel #8
0
        /// <summary>
        /// Is the active window the Outlook calendar window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <returns>true if it is</returns>
        public bool IsCalendarWindow(WindowActivityMonitorInfo monitorInfo)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var element = AgentUtils.FindElementByAutomationId(windowElement, "AfxWndW", ControlType.Text, "");

            if (element != null)
            {
                Log.Debug(element.Current.Name);
                return(element.Current.Name.ToLower().StartsWith(R.GetString2("Outlook2010TitleCalendarPrefix").ToLower()));
            }

            return(false);
        }
Beispiel #9
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 #10
0
        /// <summary>
        /// Is the active window the Appointement scheduling 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 IsAppointmentSchedulingWindow(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, "SUPERGRID", ControlType.List, "4542", "All Attendees") ??
                                 AgentUtils.FindElementByAutomationId(windowElement, "Button", ControlType.Button, "4370", "Add Attendees...")) ??
                                AgentUtils.FindElementByAutomationId(windowElement, "RIchEdit20WPT", ControlType.Edit, "4098", "Meeting Start Date:");

            retVal = (element != null);

            Log.Debug("Returning " + retVal);

            return(retVal);
        }
Beispiel #11
0
 /// <summary>
 /// Checks if the window has a TitleBar control and returns
 /// the element
 /// </summary>
 /// <param name="element">window automation element</param>
 /// <returns>the element</returns>
 private AutomationElement findTitleBar(AutomationElement element)
 {
     return(AgentUtils.FindElementByAutomationId(element, "", ControlType.TitleBar, "TitleBar"));
 }
Beispiel #12
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);
        }