Пример #1
0
        public static mshtml.IHTMLElement2 GetWindowWidthAndHeight(IntPtr hwnd, mshtml.IHTMLDocument2 doc, ref int clientWidth, ref int clientHeight, ref int scrollWidth, ref int scrollHeight)
        {
            HTMLDocumentClass class2 = doc as HTMLDocumentClass;

            mshtml.IHTMLElement2 documentElement = null;
            if (class2 != null)
            {
                documentElement = class2.documentElement as mshtml.IHTMLElement2;
                if (documentElement != null)
                {
                    clientWidth  = documentElement.clientWidth;
                    clientHeight = documentElement.clientHeight;
                }
            }
            else
            {
                Rect lpRect = new Rect();
                documentElement = doc.body as mshtml.IHTMLElement2;
                WindowUtil.GetWindowRect(hwnd, out lpRect);
                if (documentElement != null)
                {
                    clientWidth  = lpRect.Right - lpRect.Left;
                    clientHeight = lpRect.Bottom - lpRect.Top;
                }
            }
            if (documentElement != null)
            {
                scrollWidth  = documentElement.scrollWidth;
                scrollHeight = documentElement.scrollHeight;
            }
            return(documentElement);
        }
Пример #2
0
        public static int GetWindowMessageLParam(IntPtr hwnd, Point mousePoint)
        {
            Rect lpRect = new Rect();

            WindowUtil.GetWindowRect(hwnd, out lpRect);
            return(((lpRect.Top + mousePoint.Y) << 0x10) + (lpRect.Left + mousePoint.X));
        }
Пример #3
0
        public static int GetLinkElementIndex(mshtml.IHTMLDocument2 doc, mshtml.IHTMLElement ele, string itemName, string tagStr)
        {
            mshtml.IHTMLElementCollection links;
            int        num       = 0;
            bool       flag      = false;
            ElementTag outerText = ElementTag.outerText;

            if (!string.IsNullOrEmpty(tagStr))
            {
                outerText = (ElementTag)WindowUtil.StringToInt(tagStr);
            }
            if (outerText != ElementTag.src)
            {
                links = doc.links;
                if (links == null)
                {
                    goto Label_00EA;
                }
                foreach (mshtml.IHTMLElement element2 in links)
                {
                    if (IsElementMatch(element2, outerText, itemName, ""))
                    {
                        if (ele == element2)
                        {
                            flag = true;
                            break;
                        }
                        num++;
                    }
                }
            }
            else
            {
                links = doc.images;
                if (links != null)
                {
                    foreach (mshtml.IHTMLElement element in links)
                    {
                        if (IsElementMatch(element, outerText, itemName, ""))
                        {
                            if (ele == element)
                            {
                                flag = true;
                                break;
                            }
                            num++;
                        }
                    }
                    Marshal.ReleaseComObject(links);
                }
                goto Label_00EA;
            }
            Marshal.ReleaseComObject(links);
Label_00EA:
            if (!flag)
            {
                num = 0;
            }
            return(num);
        }
Пример #4
0
        public static mshtml.IHTMLElement GetInputElement(mshtml.IHTMLDocument2 doc, string itemName, string tagStr, string indexStr)
        {
            mshtml.IHTMLElementCollection o       = (mshtml.IHTMLElementCollection)doc.all.tags("input");
            mshtml.IHTMLElement           element = null;
            ElementTag iD   = ElementTag.ID;
            int        num  = 0;
            int        num2 = 0;

            if (!string.IsNullOrEmpty(indexStr))
            {
                num = WindowUtil.StringToInt(indexStr);
            }
            if ((tagStr != string.Empty) && (tagStr != ""))
            {
                iD = (ElementTag)WindowUtil.StringToInt(tagStr);
            }
            foreach (mshtml.IHTMLElement element2 in o)
            {
                if (IsElementMatch(element2, iD, itemName, ""))
                {
                    if (num2 == num)
                    {
                        element = element2;
                        break;
                    }
                    num2++;
                }
            }
            if (o != null)
            {
                Marshal.ReleaseComObject(o);
            }
            return(element);
        }
Пример #5
0
 public void InitLoader(string sContent, string sBaseUrl)
 {
     this.m_sBaseName = sBaseUrl;
     if (WindowUtil.CreateStreamOnHGlobal(Marshal.StringToHGlobalAuto(sContent), true, out this.m_stream) == 0)
     {
         IStream stream = this.m_stream;
     }
 }
Пример #6
0
        public static bool ScrollToAbsolutePoint(IntPtr hwnd, mshtml.IHTMLDocument2 doc, int scrollTop, int y, int scrollHeight, int winHeight, ref Point fakeMousePoint, bool scrollFast, bool isTimeout, HtmlElement htmlElement)
        {
            int    num2;
            bool   flag   = false;
            int    num    = 0;
            Random random = new Random();

            if (isTimeout)
            {
                if (htmlElement == null)
                {
                    return(flag);
                }
                int num3 = y - (winHeight / 2);
                if (num3 < 0)
                {
                    num3 = 0;
                }
                else if (num3 > (scrollHeight - winHeight))
                {
                    num3 = scrollHeight - winHeight;
                }
                htmlElement.ScrollTop = num3;
                return(true);
            }
            if (scrollFast)
            {
                num2 = 100;
            }
            else
            {
                num2 = random.Next(5, 10);
            }
            CheckMousePoint(hwnd, ref fakeMousePoint, doc);
            while (!flag && (num < num2))
            {
                int windowMessageLParam = GetWindowMessageLParam(hwnd, fakeMousePoint);
                if ((y <= ((scrollTop + (winHeight / 2)) - 120)) && (scrollTop > 0))
                {
                    scrollTop = ((scrollTop - 120) >= 0) ? (scrollTop - 120) : 0;
                    WindowUtil.PostMessage(hwnd, 0x20a, 0x780000, windowMessageLParam);
                }
                else if ((y >= ((scrollTop + (winHeight / 2)) + 120)) && ((scrollTop + winHeight) < scrollHeight))
                {
                    scrollTop = (((scrollTop + winHeight) + 120) <= scrollHeight) ? (scrollTop + 120) : (scrollHeight - winHeight);
                    WindowUtil.PostMessage(hwnd, 0x20a, -7864320, windowMessageLParam);
                }
                else
                {
                    flag = true;
                }
                num++;
            }
            return(flag);
        }
Пример #7
0
        public static bool MoveToDest(IntPtr hwnd, HtmlElement htmlElement, mshtml.IHTMLDocument2 doc, int x, int y, ref Point fakeMousePoint, bool scrollfast, bool isTimeout)
        {
            bool flag         = true;
            int  clientWidth  = 0;
            int  clientHeight = 0;
            int  scrollWidth  = 0;
            int  scrollHeight = 0;

            if ((GetWindowWidthAndHeight(hwnd, doc, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight) != null) && (htmlElement != null))
            {
                int scrollLeft = htmlElement.ScrollLeft;
                int scrollTop  = htmlElement.ScrollTop;
                if ((clientWidth == 0) && (clientHeight == 0))
                {
                    return(flag);
                }
                flag = ScrollToAbsolutePoint(hwnd, doc, scrollTop, y + scrollTop, scrollHeight, clientHeight, ref fakeMousePoint, scrollfast, isTimeout, htmlElement);
                if (!flag)
                {
                    return(flag);
                }
                flag = false;
                int num7 = 0;
                if (((scrollLeft + x) + (clientWidth / 2)) > scrollWidth)
                {
                    num7 = scrollWidth - clientWidth;
                }
                else if ((scrollLeft + x) < (clientWidth / 2))
                {
                    num7 = 0;
                }
                else
                {
                    num7 = (scrollLeft + x) - (clientWidth / 2);
                }
                htmlElement.ScrollLeft = num7;
                if ((x + scrollLeft) < 0)
                {
                    x = 4;
                }
                else if ((x + scrollLeft) > scrollWidth)
                {
                    x = clientWidth - 8;
                }
                if (((scrollLeft + x) >= num7) && ((scrollLeft + x) <= (num7 + clientWidth)))
                {
                    SetMousePoint(hwnd, ref fakeMousePoint, x, y, doc);
                    int lParam = (fakeMousePoint.Y << 0x10) + fakeMousePoint.X;
                    WindowUtil.PostMessage(hwnd, 0x200, 0, lParam);
                    flag = true;
                }
            }
            return(flag);
        }
Пример #8
0
        public static mshtml.IHTMLDocument2 GetIEWindowDocument(IntPtr hwnd)
        {
            object ppvObject = new object();
            int    lParam    = 0;
            Guid   riid      = new Guid();
            int    wMsg      = WindowUtil.RegisterWindowMessage("WM_Html_GETOBJECT");

            WindowUtil.ObjectFromLresult(WindowUtil.SendMessage(hwnd, wMsg, 0, lParam), ref riid, 0, ref ppvObject);
            mshtml.IHTMLDocument2 document = (mshtml.IHTMLDocument2)ppvObject;
            ppvObject = null;
            return(document);
        }
Пример #9
0
 public void SendStopTask()
 {
     if (WindowUtil.IsWindow(this._parentProcessHwnd) && (this._ieItem != null))
     {
         TaskBrowser.COPYDATASTRUCT copydatastruct;
         string s      = "a";
         int    length = Encoding.Unicode.GetBytes(s).Length;
         copydatastruct.dwData = (IntPtr)2;
         copydatastruct.lpData = s;
         copydatastruct.cbDaat = length + 2;
         WindowUtil.SendMessage(this._parentProcessHwnd, 0x4a, 0, ref copydatastruct);
     }
 }
Пример #10
0
        public static bool MoveToDest(IntPtr hwnd, mshtml.IHTMLDocument2 doc, Point to, ref Point fakeMousePoint)
        {
            bool flag         = false;
            int  clientWidth  = 0;
            int  clientHeight = 0;
            int  scrollWidth  = 0;
            int  scrollHeight = 0;

            if ((GetWindowWidthAndHeight(hwnd, doc, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight) != null) && ((clientWidth != 0) || (clientHeight != 0)))
            {
                int num5 = 50;
                if ((Math.Abs((int)(fakeMousePoint.Y - to.Y)) >= num5) || (Math.Abs((int)(fakeMousePoint.X - to.X)) >= num5))
                {
                    if (((to.X >= 0) && (to.X < clientWidth)) && ((to.Y >= 0) && (to.Y <= clientHeight)))
                    {
                        Random random = new Random();
                        int    num6   = 0;
                        int    num7   = 0;
                        if ((fakeMousePoint.X - to.X) > 0)
                        {
                            num6 = -random.Next(Math.Max(fakeMousePoint.X - to.X, 50));
                        }
                        else if ((fakeMousePoint.X - to.X) < 0)
                        {
                            num6 = random.Next(Math.Max(to.X - fakeMousePoint.X, 50));
                        }
                        if ((fakeMousePoint.Y - to.Y) > 0)
                        {
                            num7 = -random.Next(Math.Max(fakeMousePoint.Y - to.Y, 50));
                        }
                        else if ((fakeMousePoint.Y - to.Y) < 0)
                        {
                            num7 = random.Next(Math.Max(to.Y - fakeMousePoint.Y, 50));
                        }
                        SetMousePoint(ref fakeMousePoint, fakeMousePoint.X + num6, fakeMousePoint.Y + num7, clientWidth, clientHeight);
                        int lParam = (fakeMousePoint.Y << 0x10) + fakeMousePoint.X;
                        WindowUtil.PostMessage(hwnd, 0x200, 0, lParam);
                    }
                    return(flag);
                }
                flag = true;
                if ((fakeMousePoint.Y != to.Y) || (fakeMousePoint.X != to.X))
                {
                    SetMousePoint(ref fakeMousePoint, to.X, to.Y, clientWidth, clientHeight);
                    int num9 = (fakeMousePoint.Y << 0x10) + fakeMousePoint.X;
                    WindowUtil.PostMessage(hwnd, 0x200, 0, num9);
                }
            }
            return(flag);
        }
Пример #11
0
        public static mshtml.IHTMLElement GetButtonElement(mshtml.IHTMLDocument2 doc, string itemName, string tagStr, string indexStr)
        {
            mshtml.IHTMLElement element = null;
            ElementTag          iD      = ElementTag.ID;
            int num  = 0;
            int num2 = 0;

            if ((indexStr != string.Empty) && (indexStr != ""))
            {
                num2 = WindowUtil.StringToInt(indexStr);
            }
            if ((tagStr != string.Empty) && (tagStr != ""))
            {
                iD = (ElementTag)WindowUtil.StringToInt(tagStr);
            }
            mshtml.IHTMLElementCollection o = (mshtml.IHTMLElementCollection)doc.all.tags("input");
            foreach (mshtml.IHTMLElement element2 in o)
            {
                if ((IsElementMatchType(element2, "submit") || IsElementMatchType(element2, "button")) && IsElementMatch(element2, iD, itemName, ""))
                {
                    if (num == num2)
                    {
                        element = element2;
                        break;
                    }
                    num++;
                }
            }
            if (o != null)
            {
                Marshal.ReleaseComObject(o);
            }
            o = (mshtml.IHTMLElementCollection)doc.all.tags("button");
            foreach (mshtml.IHTMLElement element3 in o)
            {
                if (IsElementMatch(element3, iD, itemName, ""))
                {
                    if (num == num2)
                    {
                        return(element3);
                    }
                    num++;
                }
            }
            return(element);
        }
Пример #12
0
        public int GetTaskInfo(ref TaskInfo taskItem, ref int taskIndex, ref bool startLoop, ref bool loop, ref int loopTime)
        {
            if (startLoop && loop)
            {
                taskIndex--;
                loopTime++;
            }
            else
            {
                startLoop = false;
                loop      = false;
                loopTime  = 0;
            }
            if (taskIndex >= this._taskItems.Count)
            {
                return(-1);
            }
            taskItem = (TaskInfo)this._taskItems[taskIndex++];
            switch (WindowUtil.StringToInt(taskItem._param1))
            {
            case 5:
            case 7:
            case 13:
            case 15:
            case 0x11:
            case 0x17:
            case 0x19:
            case 0x13:
            case 0x15:
            case 0x1b:
                startLoop = loop = true;
                break;

            default:
                startLoop = loop = false;
                break;
            }
            return(0);
        }
Пример #13
0
        public static bool isClickElement(IntPtr hwnd, mshtml.IHTMLDocument2 doc, mshtml.IHTMLElement ele, int x, int y, ClickEvent clickEvent)
        {
            bool flag = false;

            clickEvent.SetElement(ele);
            WindowUtil.ClickMouse(hwnd, x, y);
            if (clickEvent.CouldClick)
            {
                if (clickEvent.IsClick)
                {
                    flag = true;
                }
                return(flag);
            }
            mshtml.IHTMLElement parentElement = ele;
            mshtml.IHTMLElement activeElement = doc.activeElement;
            while ((parentElement != null) && (parentElement != doc.body))
            {
                if (parentElement == activeElement)
                {
                    flag = true;
                    break;
                }
                parentElement = parentElement.parentElement;
            }
            if (!flag)
            {
                parentElement = ele;
                for (activeElement = doc.activeElement; (activeElement != null) && (activeElement != doc.body); activeElement = activeElement.parentElement)
                {
                    if (parentElement == activeElement)
                    {
                        return(true);
                    }
                }
            }
            return(flag);
        }
Пример #14
0
        public uint CalculateScore()
        {
            uint num = 0;

            switch (((TaskCommand)WindowUtil.StringToInt(this._param1)))
            {
            case TaskCommand.Task_Wait:
                if (!string.IsNullOrEmpty(this._param2))
                {
                    num = (WindowUtil.StringToUint(this._param2) + 0x1d) / 30;
                }
                return(num);

            case TaskCommand.Task_DeepClick:
                if (!string.IsNullOrEmpty(this._param2))
                {
                    num = 1 + (WindowUtil.StringToUint(this._param2) * ((WindowUtil.StringToUint(this._param3) + 0x1d) / 30));
                }
                return(num);

            case TaskCommand.Task_FindLinkLinkPage1:
            case TaskCommand.Task_FindLinkHrefPage1:
            case TaskCommand.Task_FindHrefLinkPage1:
            case TaskCommand.Task_FindHrefHrefPage1:
            case TaskCommand.Task_FindSrcLinkPage1:
            case TaskCommand.Task_FindSrcHrefPage1:
            case TaskCommand.Task_FindHrefSrcPage1:
            case TaskCommand.Task_FindLinkSrcPage1:
            case TaskCommand.Task_FindSrcSrcPage1:
                if (!string.IsNullOrEmpty(this._param4))
                {
                    num = WindowUtil.StringToUint(this._param4) + 1;
                }
                return(num);
            }
            return(1);
        }
Пример #15
0
 public void SendCompleteTask(int id, bool completed, int taskStep, string errorStr)
 {
     if (WindowUtil.IsWindow(this._parentProcessHwnd))
     {
         try
         {
             TaskBrowser.COPYDATASTRUCT copydatastruct;
             XmlDocument document = new XmlDocument();
             XmlElement  newChild = document.CreateElement("root");
             XmlElement  element2 = document.CreateElement("taskid");
             XmlElement  element3 = document.CreateElement("isCompleted");
             XmlElement  element4 = document.CreateElement("errorString");
             XmlElement  element5 = document.CreateElement("taskStep");
             element2.InnerText = id.ToString();
             element3.InnerText = completed.ToString();
             element4.InnerText = errorStr;
             element5.InnerText = taskStep.ToString();
             newChild.AppendChild(element2);
             newChild.AppendChild(element3);
             newChild.AppendChild(element4);
             newChild.AppendChild(element5);
             document.AppendChild(newChild);
             string outerXml = document.OuterXml;
             int    length   = Encoding.Unicode.GetBytes(outerXml).Length;
             copydatastruct.dwData = (IntPtr)1;
             copydatastruct.lpData = outerXml;
             copydatastruct.cbDaat = length + 2;
             WindowUtil.SendMessage(this._parentProcessHwnd, 0x4a, 0, ref copydatastruct);
             newChild = null;
             document = null;
         }
         catch (Exception)
         {
         }
     }
 }
Пример #16
0
        public static mshtml.IHTMLElement GetLinkElement(mshtml.IHTMLDocument2 doc, string itemName, string keyword, string tagStr, string indexStr)
        {
            mshtml.IHTMLElement           element = null;
            mshtml.IHTMLElementCollection links;
            ElementTag outerText = ElementTag.outerText;
            int        num       = 0;
            int        num2      = 0;

            if (!string.IsNullOrEmpty(indexStr))
            {
                num = WindowUtil.StringToInt(indexStr);
            }
            if (!string.IsNullOrEmpty(tagStr))
            {
                outerText = (ElementTag)WindowUtil.StringToInt(tagStr);
            }
            if (outerText != ElementTag.src)
            {
                links = doc.links;
                if (links == null)
                {
                    return(element);
                }
                keyword = keyword.Trim();
                foreach (mshtml.IHTMLElement element3 in links)
                {
                    if (!IsElementMatch(element3, outerText, itemName, ""))
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(keyword))
                    {
                        if (num2 == num)
                        {
                            element = element3;
                            break;
                        }
                        num2++;
                        continue;
                    }
                    if ((element3.getAttribute("href", 0) != null) && (((string)element3.getAttribute("href", 0)).Trim().IndexOf(keyword) != -1))
                    {
                        element = element3;
                        break;
                    }
                }
            }
            else
            {
                links = doc.images;
                if (links != null)
                {
                    foreach (mshtml.IHTMLElement element2 in links)
                    {
                        if (IsElementMatch(element2, outerText, itemName, keyword))
                        {
                            if (num == num2)
                            {
                                element = element2;
                                break;
                            }
                            num2++;
                        }
                    }
                    Marshal.ReleaseComObject(links);
                }
                return(element);
            }
            Marshal.ReleaseComObject(links);
            return(element);
        }
Пример #17
0
 private void ProcessRunTask(string xmlDoc)
 {
     if (this._task == null)
     {
         try
         {
             XmlDocument document = new XmlDocument();
             XmlNode     node     = null;
             document.LoadXml(xmlDoc);
             foreach (XmlNode node2 in document.SelectSingleNode("root").ChildNodes)
             {
                 if (node2.Name.Equals("tasks"))
                 {
                     foreach (XmlNode node3 in node2.ChildNodes)
                     {
                         if (node3.Name.Equals("task"))
                         {
                             MyTask task = new MyTask();
                             foreach (XmlNode node4 in node3.ChildNodes)
                             {
                                 if (node4.Name.Equals("taskinfo"))
                                 {
                                     string s         = string.Empty;
                                     string innerText = string.Empty;
                                     string str3      = string.Empty;
                                     string str4      = string.Empty;
                                     string str5      = string.Empty;
                                     foreach (XmlNode node5 in node4)
                                     {
                                         if (node5.Name.Equals("param1"))
                                         {
                                             s = node5.InnerText;
                                         }
                                         else
                                         {
                                             if (node5.Name.Equals("param2"))
                                             {
                                                 innerText = node5.InnerText;
                                                 continue;
                                             }
                                             if (node5.Name.Equals("param3"))
                                             {
                                                 str3 = node5.InnerText;
                                                 continue;
                                             }
                                             if (node5.Name.Equals("param4"))
                                             {
                                                 str4 = node5.InnerText;
                                                 continue;
                                             }
                                             if (node5.Name.Equals("param5"))
                                             {
                                                 str5 = node5.InnerText;
                                             }
                                         }
                                     }
                                     if ((WindowUtil.StringToInt(s) > -1) && (WindowUtil.StringToInt(s) < 0x1d))
                                     {
                                         TaskInfo info = new TaskInfo(s, innerText, str3, str4, str5);
                                         task.Insert(info, -1);
                                     }
                                     continue;
                                 }
                                 if (node4.Name.Equals("params"))
                                 {
                                     foreach (XmlNode node6 in node4)
                                     {
                                         XmlElement element = (XmlElement)node6;
                                         if (element.Name.Equals("taskid"))
                                         {
                                             task._id = WindowUtil.StringToInt(element.InnerText);
                                         }
                                         if (element.Name.Equals("ClickIntervalTime"))
                                         {
                                             task._clickIntervalTime = WindowUtil.StringToInt(element.InnerText);
                                         }
                                         else
                                         {
                                             if (element.Name.Equals("ClickCountPerIP"))
                                             {
                                                 task._clickCountPerIP = WindowUtil.StringToInt(element.InnerText);
                                                 continue;
                                             }
                                             if (element.Name.Equals("ClickRate"))
                                             {
                                                 task._clickRate = WindowUtil.StringToInt(element.InnerText);
                                                 continue;
                                             }
                                             if (element.Name.Equals("AllowScrollWhileWaiting"))
                                             {
                                                 task._allowScrollWhileWaiting = Convert.ToBoolean(element.InnerText);
                                                 continue;
                                             }
                                             if (element.Name.Equals("vipmode"))
                                             {
                                                 task.VipMode = Convert.ToBoolean(element.InnerText);
                                             }
                                         }
                                     }
                                     continue;
                                 }
                             }
                             if (task._taskItems.Count > 0)
                             {
                                 this._task = task;
                             }
                             task = null;
                         }
                     }
                     continue;
                 }
                 if (node2.Name.Equals("setting"))
                 {
                     foreach (XmlNode node7 in node2.ChildNodes)
                     {
                         if (node7.Name.Equals("waitFindTime"))
                         {
                             this._waitFindTime = WindowUtil.StringToInt(node7.InnerText);
                         }
                         else if (node7.Name.Equals("waitDocCompleteTime"))
                         {
                             this._waitDocCompleteTime = WindowUtil.StringToInt(node7.InnerText);
                         }
                         if (node7.Name.Equals("curAddress"))
                         {
                             this.ShowTip1(node7.InnerText);
                         }
                     }
                     continue;
                 }
             }
             node     = null;
             document = null;
             if (this._task != null)
             {
                 this.StartTaskThread(this._task);
             }
         }
         catch (Exception exception)
         {
             Logger.Error(exception);
         }
     }
 }
Пример #18
0
        public static mshtml.IHTMLElement GetRadioElement(mshtml.IHTMLDocument2 doc, string itemName, string tagStr, string indexStr)
        {
            mshtml.IHTMLElementCollection o       = (mshtml.IHTMLElementCollection)doc.all.tags("input");
            mshtml.IHTMLElement           element = null;
            ElementTag iD   = ElementTag.ID;
            bool       flag = false;
            int        num  = 0;
            int        num2 = 0;

            if (!string.IsNullOrEmpty(tagStr))
            {
                iD = (ElementTag)WindowUtil.StringToInt(tagStr);
            }
            if (!string.IsNullOrEmpty(indexStr))
            {
                num = WindowUtil.StringToInt(indexStr);
            }
            foreach (mshtml.IHTMLElement element2 in o)
            {
                if (IsElementMatchType(element2, "radio") && IsElementMatch(element2, iD, itemName, ""))
                {
                    if (num == num2)
                    {
                        element = element2;
                        flag    = true;
                        break;
                    }
                    num2++;
                }
            }
            if (o != null)
            {
                Marshal.ReleaseComObject(o);
            }
            if (!flag)
            {
                o = (mshtml.IHTMLElementCollection)doc.all.tags("label");
                foreach (mshtml.IHTMLElement element3 in o)
                {
                    if (element3.getAttribute("htmlFor", 0) != null)
                    {
                        string str = element3.getAttribute("htmlFor", 0).ToString();
                        if (!string.IsNullOrEmpty(str))
                        {
                            mshtml.IHTMLElement ele = doc.all.item(str, Missing.Value) as mshtml.IHTMLElement;
                            if (((ele != null) && IsElementMatchType(ele, "radio")) && IsElementMatch(element3, iD, itemName, ""))
                            {
                                if (num == num2)
                                {
                                    element = element3;
                                    flag    = true;
                                    break;
                                }
                                num2++;
                            }
                        }
                    }
                }
            }
            if (o != null)
            {
                Marshal.ReleaseComObject(o);
            }
            return(element);
        }