示例#1
0
文件: iectl.cs 项目: wrmsr/iectl
        public static IEDoc FromTitle(string pattern, out Wnd ie)
        {
            Regex rx = new Regex(pattern, RegexOptions.Compiled);

            ie = null;
            foreach(Wnd cur in new Wnd(IntPtr.Zero).Children)
                if((cur.ClassName == "IEFrame") && rx.Match(cur.WindowText).Success)
                    return FromIE(ie = cur);

            return null;
        }
示例#2
0
文件: iectl.cs 项目: wrmsr/iectl
        public static IEDoc FromProcessId(int id, out Wnd ie)
        {
            ie = null;
            foreach(Wnd cur in new Wnd(IntPtr.Zero).Children)
                if(cur.ProcessId == id && cur.ClassName == "IEFrame")
                    return FromIE(ie = cur);

            return null;
        }
示例#3
0
文件: iectl.cs 项目: wrmsr/iectl
        public bool TryFind(string pattern)
        {
            Wnd ieNew = null;

            if(IEDoc.FromTitle(pattern, out ieNew) == null)
                return false;

            window = ieNew;

            return true;
        }
示例#4
0
文件: iectl.cs 项目: wrmsr/iectl
        public static IEDoc FromIE(Wnd ie)
        {
            foreach(Wnd cur in ie.Children)
                if(cur.ClassName == "Internet Explorer_Server") {
                    HTMLDocument doc = GetHTMLDocument((IntPtr)cur);

                    if(doc == null || doc.readyState != "complete")
                        return null;

                    return new IEDoc(doc);
                }

            return null;
        }
示例#5
0
文件: iectl.cs 项目: wrmsr/iectl
        public bool HandleAlert(string action)
        {
            Wnd alert = GetAlert();

            if(alert == null || string.IsNullOrEmpty(action))
                return false;

            action = action.ToLower();

            if(action == "close")
                Wnd.SendMessage(alert, Wnd.WM_CLOSE, 0, 0);
            else if(action == "cancel" || action == "ok") {
                Wnd btn = new Wnd(Wnd.FindWindowEx(alert, IntPtr.Zero, "Button", action == "cancel" ? "Cancel" : "OK"));

                if(btn == null)
                    return false;

                Wnd.SendMessage(btn, Wnd.WM_LBUTTONDOWN, 0, 0);
                Thread.Sleep(250);

                Wnd.SendMessage(btn, Wnd.WM_LBUTTONUP, 0, 0);
                Thread.Sleep(250);
            }
            else
                return false;

            return true;
        }