示例#1
0
        /// <summary>
        /// Does the mailing.
        /// </summary>
        public static void DoMail()
        {
            MailList.Load();
            Thread.Sleep(1000);
            MouseHelper.Hook();
            if (!MakeMailReady())
            {
                MouseHelper.ReleaseMouse();
                return;
            }
            AddedItemsStatus answer = ClickItems(true, 12);
            bool             done   = false;

            while (true)
            {
                switch (answer)
                {
                case AddedItemsStatus.ClickedAll:
                    Logging.Write("Mail full sending");
                    MailFrame.ClickSend();
                    Thread.Sleep(3500);
                    if (LazySettings.MacroForMail)
                    {
                        SetMailNameUsingMacro();
                    }
                    else
                    {
                        MailFrame.SetReceiverHooked(LazySettings.MailTo);
                    }
                    Thread.Sleep(500);
                    break;

                case AddedItemsStatus.ClickedSomething:
                    Logging.Write("Mail partly full sending and stopping loop");
                    MailFrame.ClickSend();
                    Thread.Sleep(500);
                    done = true;
                    break;

                case AddedItemsStatus.Error:
                    //Continue the loop as it could just be a single read error.
                    break;

                default:
                    done = true;
                    break;
                }
                if (done)
                {
                    break;
                }
                Thread.Sleep(1000);
                Application.DoEvents();
                answer = ClickItems(false, 12);
            }
            MailFrame.Close();
            MouseHelper.ReleaseMouse();
            CloseAllBags();
            Logging.Write("Brok loop with: " + answer);
        }
示例#2
0
        /// <summary>
        /// Returns an enum based on how it went, send reset if you want to start from the beginning of the bags.
        /// </summary>
        /// <param name="reset">if set to <c>true</c> [reset].</param>
        /// <param name="howMany">How many should we click before returning ClickedAll.</param>
        /// <returns></returns>
        public static AddedItemsStatus ClickItems(bool reset, int howMany)
        {
            Logging.Write("Called addedToMail");
            if (reset)
            {
                _containerIndex = 1;
                _positionInBag  = 1;
            }
            int clicked = 0;

            while (_containerIndex != 6)
            {
                Frame containerFrame = InterfaceHelper.GetFrameByName("ContainerFrame" + _containerIndex);
                if (containerFrame != null)
                {
                    int slots = GetSlotCount(_containerIndex);
                    Logging.Write("Found ContainerFrame with Slot count: " + slots);
                    while (_positionInBag != slots + 1 && clicked != howMany)
                    {
                        string itemStr = "ContainerFrame" + _containerIndex + "Item" + _positionInBag;
                        Frame  itemOb  = InterfaceHelper.GetFrameByName(itemStr);
                        if (itemOb != null)
                        {
                            itemOb.HoverHooked();
                            Thread.Sleep(150);
                            try
                            {
                                Frame toolTip = InterfaceHelper.GetFrameByName("GameTooltip");
                                if (toolTip != null)
                                {
                                    if (MailList.ShouldMail(toolTip.GetChildObject("GameTooltipTextLeft1").GetText))
                                    {
                                        Logging.Write("Adding: " +
                                                      toolTip.GetChildObject("GameTooltipTextLeft1").GetText);
                                        Thread.Sleep(150);
                                        itemOb.RightClickHooked();
                                        Thread.Sleep(150);
                                        clicked++;
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                Logging.Write("Exception when pasing gametooltip: " + e);
                            }
                        }
                        _positionInBag++;
                    }
                    if (_positionInBag == slots + 1)
                    {
                        _positionInBag = 1;
                        _containerIndex++;
                    }
                    if (clicked == howMany)
                    {
                        return(AddedItemsStatus.ClickedAll);
                    }
                }
                else
                {
                    _containerIndex++;
                    return(AddedItemsStatus.Error);
                }
            }
            if (clicked != 0)
            {
                return(AddedItemsStatus.ClickedSomething);
            }
            return(AddedItemsStatus.ClickedNothing);
        }