private int WndComparison(VWindow x, VWindow y) { if (x.Handle == null) { if (y.Handle == null) { return(0); // equal } else { return(-1); // y is greater } } else { if (y.Handle == null) { return(1); // x is greater } else { return(x.Zorder.CompareTo(y.Zorder)); // compare x value with y value } } }
/// <summary> /// Adds the specified window to the profile. /// </summary> /// <param name="hWnd">Handle of the window to be added.</param> public void AddWindow(IntPtr hWnd) { //AutomationElement root = AutomationElement.FromHandle(hWnd); //string className = root.Current.ClassName; VWindow window = new VWindow(hWnd, _count, WindowUtility.Instance.GetProcessName(hWnd)); _windows.Add(window); _count++; _sorted = false; }
public bool Equals(VWindow wnd) { if ((object)wnd == null) { return(false); } else { return(Handle == wnd.Handle); } }
///// <summary> ///// Gets the window title. ///// </summary> ///// <returns>String containing the window title.</returns> //public string GetTitle() //{ // return WindowUtility.Instance.GetWindowTitle(this); //} ///// <summary> ///// Sets a new window title ///// </summary> ///// <param name="text">String containing the new window title.</param> //public void SetTitle(string text) //{ // WindowUtility.Instance.SetWindowTitle(this, text); //} ///// <summary> ///// Gets the URL or PATH of the address bar of this window. ///// </summary> ///// <returns>String containing the URL or PATH.</returns> //public string GetUrl() //{ // return WindowUtility.Instance.GetUrl(this); //} ///// <summary> ///// Gets the text contained in this window. ///// </summary> ///// <returns>String containing the text.</returns> //public string GetText() //{ // return WindowUtility.Instance.GetText(this); //} ///// <summary> ///// Gets the currently selected text by the user in this window. ///// </summary> ///// <returns>String containing the selected text by the user.</returns> //public string GetSelectedText() //{ // return WindowUtility.Instance.GetSelectedText(this); //} ///// <summary> ///// Gets the content of this window. ///// </summary> ///// <returns>String array containing the window content.</returns> //public string[] GetContent() //{ // return WindowUtility.Instance.GetContent(this); //} ///// <summary> ///// Gets the currently selected content by the user in this window. ///// </summary> ///// <returns>String array containing the selected content.</returns> //public string[] GetSelectedContet() //{ // return WindowUtility.Instance.GetSelectedContent(this); //} #endregion #region Operators public override bool Equals(object obj) { if (obj == null) // check if its null { return(false); } VWindow wnd = (VWindow)obj; if (wnd == null) // check if it can be casted { return(false); } return(Handle == wnd.Handle); }
/// <summary> /// Gets the next window with smaller z-order priority, when compared to the specified window. /// </summary> /// <param name="wnd">Visible window to be compared.</param> /// <returns>Next visible window with smaller z-order priority.</returns> public VWindow GetNextWindow(VWindow wnd) { //return GetNextWindow(hWnd, 1); if (_wndProfile.Windows.Contains(wnd)) { if (wnd.Zorder < _wndProfile.Count - 1) { return(_wndProfile.Windows[wnd.Zorder + 1]); } else { return(_wndProfile.Windows[_wndProfile.Count - 1]); } } else { return(VWindow.InvalidWindow); } }
/// <summary> /// Gets the next window with bigger z-order priority, when compared to the specified window. /// </summary> /// <param name="wnd">Visible window to be compared.</param> /// <returns>Next visible window with bigger z-order priority.</returns> public VWindow GetPreviousWindow(VWindow wnd) { //return GetPreviousWindow(hWnd, 1); if (_wndProfile.Windows.Contains(wnd)) { if (wnd.Zorder > 0) { return(_wndProfile.Windows[wnd.Zorder - 1]); } else { return(_wndProfile.Windows[0]); } } else { return(VWindow.InvalidWindow); } }
private void RankWnd() { int pos = 0; IntPtr forewindow = Win32.GetForegroundWindow(); if (forewindow != IntPtr.Zero) { for (int i = 0; i < _windows.Count; i++) { if (_windows[i].Handle == forewindow) { _windows[i] = new VWindow(forewindow, pos, _windows[i].ProcessName); //MessageBox.Show("Title: "+WindowUtility.Instance.GetWindowTitle(forewindow) + " Class: " + WindowUtility.Instance.GetClassName(forewindow) + " Process: " + WindowUtility.Instance.GetProcessName(forewindow)); pos++; break; } } } IntPtr hWnd = Win32.GetWindow(Win32.GetForegroundWindow(), (uint)GetWindow_Cmd.GW_HWNDFIRST); while (hWnd != IntPtr.Zero) { //if (_windows.Contains(hWnd)) //{ // _window_position[hWnd] = pos; // pos++; //} if (hWnd != forewindow) { for (int i = 0; i < _windows.Count; i++) { if (_windows[i].Handle == hWnd) { _windows[i] = new VWindow(hWnd, pos, _windows[i].ProcessName); pos++; break; } } } hWnd = Win32.GetWindow(hWnd, (uint)GetWindow_Cmd.GW_HWNDNEXT); } }