Exemple #1
0
        public static bool ClickOnButton(string processName, string buttonText, bool exact)
        {
            List <IntPtr> wins = WindowSearch.GetAllWindowsByText(processName, buttonText, exact);

            wins.AddRange(WindowSearch.GetAllWindowsByCaption(processName, buttonText, exact));
            wins = wins.Distinct().ToList();

            if (wins.Count == 0)
            {
                return(false);
            }

            IntPtr win = wins.Last();

            //WindowManipulation.SetForegroundWindow(win);

            Thread.Sleep(500);

            //WindowManipulation.SetForegroundWindow(win);

            Rectangle rect = WindowAttrib.GetWindowRect(win);

            rect.Location = new Point(rect.X + 7, rect.Y + 7);
            rect.Size     = new Size(rect.Width - 10, rect.Height - 10);

            ClickOnRect(rect, 1);

            Thread.Sleep(200);

            return(true);
        }
Exemple #2
0
        public static IntPtr GetChildWindowByText(IntPtr parent, string windowText, bool exact)
        {
            var wins = WindowSearch.GetChildWindows(parent);

            foreach (IntPtr w in wins)
            {
                string text = WindowAttrib.GetWindowText(w);
                if ((exact && text == windowText) || (!exact && text.Contains(windowText)))
                {
                    return(w);
                }
            }

            return(IntPtr.Zero);
        }
Exemple #3
0
        public static IntPtr WaitToOpen(string path, int maxWaitSec)
        {
            IntPtr win = IntPtr.Zero;

            DateTime start = DateTime.Now;

            while (win == IntPtr.Zero)
            {
                win = WindowSearch.GetWindowByPath(path);

                Thread.Sleep(defaultSleep);

                if ((DateTime.Now - start).TotalSeconds > maxWaitSec)
                {
                    break;
                }
            }

            return(win);
        }