Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
         }
     }
 }