Ejemplo n.º 1
0
 public static bool ClickCheckedRect(IntPtr hwnd, mshtml.IHTMLDocument2 doc, string itemName, string tagStr, string indexStr, ref bool isClick, ref Point fakeMousePoint, ClickEvent clickEvent)
 {
     mshtml.IHTMLElement elem = GetCheckedElement(doc, itemName, tagStr, indexStr);
     bool flag = false;
     if (elem != null)
     {
         flag = true;
         Rectangle elementRect = GetElementRect(doc.body, elem);
         isClick = false;
         if ((elementRect.Width > 0) && (elementRect.Height > 0))
         {
             Random random = new Random();
             int num = random.Next(elementRect.Width);
             int num2 = random.Next(elementRect.Height);
             SetMousePoint(hwnd, ref fakeMousePoint, elementRect.X + num, elementRect.Y + num2, doc);
             isClick = isClickElement(hwnd, doc, elem, elementRect.X + num, elementRect.Y + num2, clickEvent);
         }
     }
     if (elem != null)
     {
         Marshal.ReleaseComObject(elem);
     }
     return flag;
 }
Ejemplo n.º 2
0
 public static bool ClickLinkRect(IntPtr hwnd, mshtml.IHTMLDocument2 doc, string itemName, string keyword, string tagStr, string indexStr, ref bool isClick, ref Point fakeMousePoint, ClickEvent clickEvent, ref int clickLinkCount)
 {
     Rectangle elementRect = new Rectangle();
     bool flag = false;
     mshtml.IHTMLElement elem = GetLinkElement(doc, itemName, keyword, tagStr, indexStr);
     if (elem != null)
     {
         flag = true;
         elementRect = GetElementRect(doc.body, elem);
         isClick = false;
         if ((elementRect.Width > 0) && (elementRect.Height > 0))
         {
             Random random = new Random();
             int num = random.Next(elementRect.Width);
             int num2 = random.Next(elementRect.Height);
             SetMousePoint(hwnd, ref fakeMousePoint, elementRect.X + num, elementRect.Y + num2, doc);
             isClick = isClickElement(hwnd, doc, elem, elementRect.X + num, elementRect.Y + num2, clickEvent);
         }
         clickLinkCount++;
     }
     return flag;
 }
Ejemplo n.º 3
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;
 }