Ejemplo n.º 1
0
        public static ExternalProcess FromWindow(Window window)
        {
            uint process_id;
            GetWindowThreadProcessId(window.Handle, out process_id);

            return new ExternalProcess(process_id);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Pass empty string to class_name to match all.
        /// Pass empty string to text_begin to match all.
        /// Pass null to begin_with to skip.
        /// </summary>
        /// <param name="class_name"></param>
        /// <param name="text_begin"></param>
        /// <param name="begin_with"></param>
        /// <returns></returns>
        public Window FindChildWindow(string class_name, string text_begin, Window begin_with)
        {
            IntPtr first = IntPtr.Zero;
            if (begin_with != null) first = begin_with.Handle;

            Window child = new Window(Interop.FindWindowEx(Handle, first, class_name, null));

            while (child.Handle != IntPtr.Zero && !child.Title.StartsWith(text_begin))
            {
                child = new Window(Interop.FindWindowEx(Handle, child.Handle, class_name, null));
            }

            if (child.Handle == IntPtr.Zero) return null;
            return child;
        }
Ejemplo n.º 3
0
        public Window FindChildWindow(string text_begin)
        {
            IntPtr first = IntPtr.Zero;

            Window child = new Window(Interop.FindWindowEx(Handle, first, "", null));

            while (child.Handle != IntPtr.Zero && !child.Title.StartsWith(text_begin))
            {
                child = new Window(Interop.FindWindowEx(Handle, child.Handle, "", null));
            }

            if (child.Handle == IntPtr.Zero) return null;
            return child;
        }
Ejemplo n.º 4
0
        public Window ChildWindowFromPoint(Point point, string class_name, Window begin_with)
        {
            Point screen_point = new Point(Rect.X + point.X, Rect.Y + point.Y);

            IntPtr first = IntPtr.Zero;
            if (begin_with != null) first = begin_with.Handle;

            Window child = new Window(Interop.FindWindowEx(Handle, first, class_name, null));

            while (child.Handle != IntPtr.Zero)
            {
                Rectangle child_rect = child.Rect;

                if (screen_point.X >= child_rect.X && screen_point.X < child_rect.X + child_rect.Width &&
                    screen_point.Y >= child_rect.Y && screen_point.Y < child_rect.Y + child_rect.Height)
                {
                    break;
                }

                child = new Window(Interop.FindWindowEx(Handle, child.Handle, class_name, null));
            }

            if (child.Handle == IntPtr.Zero) return null;
            return child;
        }
Ejemplo n.º 5
0
        public static Window GetOpenWindowFromProcessID(int process_id, string[] title_begins, out string matched_title)
        {
            IntPtr shell_window = User32.GetShellWindow();
            Window window = null;

            string title = "";

            User32.EnumWindows(delegate(IntPtr hwnd, int lparam)
            {
                if (hwnd == shell_window) return true;
                if (!User32.IsWindowVisible(hwnd)) return true;

                int length = User32.GetWindowTextLength(hwnd);
                if (length == 0) return true;

                uint window_pid;
                User32.GetWindowThreadProcessId(hwnd, out window_pid);
                if (window_pid != process_id) return true;

                StringBuilder sb = new StringBuilder(length);
                User32.GetWindowText(hwnd, sb, length + 1);

                string sb_s = sb.ToString();
                bool match = false;
                foreach (string title_begin in title_begins)
                    if (sb_s.StartsWith(title_begin))
                    {
                        match = true;
                        break;
                    }
                if (!match) return true;

                title = sb_s;
                window = new Window(hwnd);

                return false;
            }, 0);

            matched_title = title;

            return window;
        }
Ejemplo n.º 6
0
        // scan through top-level windows only
        private bool WindowEnumCallback(IntPtr hwnd, int lParam)
        {
            uint id;

            Interop.GetWindowThreadProcessId(hwnd, out id);

            if ((int)id == process.Id)
            {
                Window window = new Window(hwnd);
                if (IsGameWindow(window))
                    enum_result.Add(window);
            }

            return true;
        }
Ejemplo n.º 7
0
 public abstract bool IsGameWindow(Window window);
Ejemplo n.º 8
0
 public abstract BGGameWindow CreateGameWindow(Window window);
Ejemplo n.º 9
0
 public JoinOffer(GameOffer game_offer, string joiner, Window window)
     : base(game_offer.Creator, game_offer.GameType, game_offer.MatchTo, game_offer.Stake, game_offer.Limit, DateTime.UtcNow)
 {
     this.joiner = joiner;
     this.window = window;
 }
Ejemplo n.º 10
0
 public BGGameWindow(Window window, BGClient client)
 {
     this.window = window;
     this.client = client;
 }
Ejemplo n.º 11
0
 public static void SetWindow(Window window)
 {
     Mouse.window = window;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Clicks inside a rectangle relative to the parent window and uses the rectangular distribution attached.
        /// </summary>
        /// <param name="parent_window"></param>
        /// <param name="rectangle"></param>
        /// <param name="mouse_button"></param>
        public static void MoveClick(Rectangle rectangle, Window parent_window, MouseButton mouse_button)
        {
            Mouse.SetWindow(parent_window);

            MoveClick(rectangle, mouse_button);
        }