Пример #1
0
 public void LoadSetting()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load("account.xml");
         foreach (XmlNode node2 in document.SelectSingleNode("root").ChildNodes)
         {
             if (node2.Name.Equals("account"))
             {
                 this._account = node2.InnerText;
             }
             else
             {
                 if (node2.Name.Equals("p1"))
                 {
                     this._K = node2.InnerText;
                     continue;
                 }
                 if (node2.Name.Equals("accountTime"))
                 {
                     this._accountTime = WindowUtil.StringToUint(node2.InnerText);
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }
Пример #2
0
        public static int GetLinkElementIndex(IHTMLDocument2 doc, IHTMLElement ele, string itemName, string tagStr)
        {
            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 (IHTMLElement element2 in links)
                {
                    if (IsElementMatch(element2, outerText, itemName, ""))
                    {
                        if (ele == element2)
                        {
                            flag = true;
                            break;
                        }
                        num++;
                    }
                }
            }
            else
            {
                links = doc.images;
                if (links != null)
                {
                    foreach (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);
        }
Пример #3
0
        public static IHTMLElement GetInputElement(IHTMLDocument2 doc, string itemName, string tagStr, string indexStr)
        {
            IHTMLElementCollection o       = (IHTMLElementCollection)doc.all.tags("input");
            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 (IHTMLElement element2 in o)
            {
                if (IsElementMatch(element2, iD, itemName, ""))
                {
                    if (num2 == num)
                    {
                        element = element2;
                        break;
                    }
                    num2++;
                }
            }
            if (o != null)
            {
                Marshal.ReleaseComObject(o);
            }
            return(element);
        }
Пример #4
0
        public static int GetButtonElementIndex(IHTMLDocument2 doc, IHTMLElement ele, string itemName, string tagStr)
        {
            int  num  = 0;
            bool flag = false;

            if (ele != null)
            {
                ElementTag iD = ElementTag.ID;
                if ((tagStr != string.Empty) && (tagStr != ""))
                {
                    iD = (ElementTag)WindowUtil.StringToInt(tagStr);
                }
                if (iD != ElementTag.ID)
                {
                    IHTMLElementCollection o = (IHTMLElementCollection)doc.all.tags("input");
                    foreach (IHTMLElement element in o)
                    {
                        if ((IsElementMatchType(element, "submit") || IsElementMatchType(element, "button")) && IsElementMatch(element, iD, itemName, ""))
                        {
                            if (ele == element)
                            {
                                flag = true;
                                break;
                            }
                            num++;
                        }
                    }
                    if (o != null)
                    {
                        Marshal.ReleaseComObject(o);
                    }
                    if (!flag)
                    {
                        o = (IHTMLElementCollection)doc.all.tags("button");
                        foreach (IHTMLElement element2 in o)
                        {
                            if (IsElementMatch(element2, iD, itemName, ""))
                            {
                                if (ele == element2)
                                {
                                    flag = true;
                                    break;
                                }
                                num++;
                            }
                        }
                        if (o != null)
                        {
                            Marshal.ReleaseComObject(o);
                        }
                    }
                }
            }
            if (!flag)
            {
                num = 0;
            }
            return(num);
        }
Пример #5
0
        public void ShowWindow()
        {
            IntPtr mainWindowHandle = this.GetMainWindowHandle();

            if (mainWindowHandle != IntPtr.Zero)
            {
                WindowUtil.ShowWindow(mainWindowHandle, 8);
            }
        }
Пример #6
0
        public static 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);
            IHTMLDocument2 document = (IHTMLDocument2)ppvObject;

            ppvObject = null;
            return(document);
        }
Пример #7
0
 public void RunTask(uint taskID, COPYDATASTRUCT cds)
 {
     foreach (TaskBrowser2 browser in this._taskBrowsers)
     {
         if (browser.IsEmptyWindow())
         {
             IntPtr mainWindowHandle = browser.GetMainWindowHandle();
             if (mainWindowHandle != IntPtr.Zero)
             {
                 browser.RunTask(taskID);
                 WindowUtil.SendMessage(mainWindowHandle, 0x4a, 0, ref cds);
             }
         }
     }
 }
Пример #8
0
        public static IHTMLElement GetButtonElement(IHTMLDocument2 doc, string itemName, string tagStr, string indexStr)
        {
            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);
            }
            IHTMLElementCollection o = (IHTMLElementCollection)doc.all.tags("input");

            foreach (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 = (IHTMLElementCollection)doc.all.tags("button");
            foreach (IHTMLElement element3 in o)
            {
                if (IsElementMatch(element3, iD, itemName, ""))
                {
                    if (num == num2)
                    {
                        return(element3);
                    }
                    num++;
                }
            }
            return(element);
        }
Пример #9
0
        private void buttonModifyAccountSubmit_Click(object sender, EventArgs e)
        {
            this.labelTip.Text = "";
            string str = WorldPacket.ResizeUTF8String(this.textBoxUserName.Text.Trim(), 0x20);

            this.textBoxUserName.Text = str;
            string account = WorldPacket.ResizeUTF8String(this.textBoxModifyAccount.Text.Trim(), 0x40);

            this.textBoxModifyAccount.Text = account;
            string str3 = WorldPacket.ResizeUTF8String(this.textBoxModifyPassword.Text.Trim(), 0x20);

            this.textBoxModifyPassword.Text = str3;
            string str4 = WorldPacket.ResizeUTF8String(this.textBoxModifyPassword2.Text.Trim(), 0x20);

            this.textBoxModifyPassword2.Text = str4;
            string phone = WorldPacket.ResizeUTF8String(this.textBoxModifyPhone.Text.Trim(), 0x40);

            this.textBoxModifyPhone.Text = phone;
            string referee = WorldPacket.ResizeUTF8String(this.textBoxReferee.Text.Trim(), 0x40);

            this.textBoxReferee.Text = referee;
            if (string.IsNullOrEmpty(str))
            {
                this.labelTip.Text = "请输入您的用户名";
            }
            else if (!WindowUtil.CheckEmail(account))
            {
                this.labelTip.Text = "请输入您的Email地址";
            }
            else if ((string.IsNullOrEmpty(str3) || (str3.Length < 6)) || (str3.Length > 0x20))
            {
                this.labelTip.Text = "请输入6位-32位密码";
            }
            else if (string.IsNullOrEmpty(str4))
            {
                this.labelTip.Text = "请再次输入您的密码";
            }
            else if (str3 != str4)
            {
                this.labelTip.Text = "两次输入的密码不一致!";
            }
            else
            {
                this._parent.SendModifyAccount(str, account, str3, phone, referee);
                base.Close();
            }
        }
Пример #10
0
        public void CreateBrowserProcess(bool isHiden, IntPtr hwnd)
        {
            IntPtr foregroundWindow = WindowUtil.GetForegroundWindow();

            this._process = new System.Diagnostics.Process();
            ProcessStartInfo info = new ProcessStartInfo {
                FileName = "TaskBrowser.exe"
            };

            if (isHiden)
            {
                info.WindowStyle = ProcessWindowStyle.Hidden;
            }
            info.Arguments          = hwnd.ToInt64().ToString();
            this._process.StartInfo = info;
            this._process.Start();
            WindowUtil.SetForegroundWindow(foregroundWindow);
        }
Пример #11
0
        public static IHTMLElement FindElement(IntPtr fromHandle, IHTMLDocument2 doc, int x, int y)
        {
            IHTMLElement elem   = null;
            Rect         lpRect = new Rect();

            WindowUtil.GetWindowRect(fromHandle, out lpRect);
            elem = doc.elementFromPoint(x - lpRect.Left, y - lpRect.Top);
            while (((elem != null) && (elem.tagName != null)) && (elem.tagName.ToLower().Equals("iframe") || elem.tagName.ToLower().Equals("frame")))
            {
                Rectangle      elementRect = GetElementRect(doc.body, elem);
                IWebBrowser2   o           = elem as IWebBrowser2;
                IHTMLDocument2 document    = o.Document as IHTMLDocument2;
                IHTMLElement   element2    = document.elementFromPoint((x - lpRect.Left) - elementRect.X, (y - lpRect.Top) - elementRect.Y);
                if (element2 != null)
                {
                    elem = element2;
                }
                Marshal.ReleaseComObject(document);
                Marshal.ReleaseComObject(o);
            }
            return(elem);
        }
Пример #12
0
        public static int GetInputElementIndex(IHTMLDocument2 doc, IHTMLElement ele, string itemName, string tagStr)
        {
            int  num  = 0;
            bool flag = false;

            if (ele != null)
            {
                IHTMLElementCollection o  = (IHTMLElementCollection)doc.all.tags("input");
                ElementTag             iD = ElementTag.ID;
                if (!string.IsNullOrEmpty(tagStr))
                {
                    iD = (ElementTag)WindowUtil.StringToInt(tagStr);
                }
                if (iD != ElementTag.ID)
                {
                    foreach (IHTMLElement element in o)
                    {
                        if (IsElementMatch(element, iD, itemName, ""))
                        {
                            if (ele == element)
                            {
                                flag = true;
                                break;
                            }
                            num++;
                        }
                    }
                }
                if (o != null)
                {
                    Marshal.ReleaseComObject(o);
                }
            }
            if (!flag)
            {
                num = 0;
            }
            return(num);
        }
Пример #13
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.Split(new char[] { ',' })[0]) + 1;
                }
                return(num);
            }
            return(1);
        }
Пример #14
0
 private static void HandleRunningInstance(Process instance)
 {
     WindowUtil.ShowWindowAsync(instance.MainWindowHandle, 4);
     WindowUtil.SetForegroundWindow(instance.MainWindowHandle);
 }
Пример #15
0
        public static int GetRadioElementIndex(IHTMLDocument2 doc, IHTMLElement ele, string itemName, string tagStr)
        {
            int  num  = 0;
            bool flag = false;

            if (ele != null)
            {
                ElementTag iD = ElementTag.ID;
                if (!string.IsNullOrEmpty(tagStr))
                {
                    iD = (ElementTag)WindowUtil.StringToInt(tagStr);
                }
                if (iD != ElementTag.ID)
                {
                    IHTMLElementCollection o = (IHTMLElementCollection)doc.all.tags("input");
                    foreach (IHTMLElement element in o)
                    {
                        if (IsElementMatchType(element, "radio") && IsElementMatch(element, iD, itemName, ""))
                        {
                            if (ele == element)
                            {
                                flag = true;
                                break;
                            }
                            num++;
                        }
                    }
                    if (o != null)
                    {
                        Marshal.ReleaseComObject(o);
                    }
                    if (!flag)
                    {
                        o = (IHTMLElementCollection)doc.all.tags("label");
                        foreach (IHTMLElement element2 in o)
                        {
                            if (element2.getAttribute("htmlFor", 0) != null)
                            {
                                string str = element2.getAttribute("htmlFor", 0).ToString();
                                if (!string.IsNullOrEmpty(str))
                                {
                                    IHTMLElement element3 = doc.all.item(str, Missing.Value) as IHTMLElement;
                                    if (((element3 != null) && IsElementMatchType(element3, "radio")) && IsElementMatch(element2, iD, itemName, ""))
                                    {
                                        if (ele == element2)
                                        {
                                            flag = true;
                                            break;
                                        }
                                        num++;
                                    }
                                }
                            }
                        }
                        if (o != null)
                        {
                            Marshal.ReleaseComObject(o);
                        }
                    }
                }
            }
            if (!flag)
            {
                num = 0;
            }
            return(num);
        }
Пример #16
0
 public IntPtr GetMainWindowHandle()
 {
     return(WindowUtil.GetWindowHandleFromProcessID(this._process.Id));
 }
Пример #17
0
        public static IHTMLElement GetLinkElement(IHTMLDocument2 doc, string itemName, string keyword, string tagStr, string indexStr)
        {
            IHTMLElement           element = null;
            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 (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 (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);
        }