What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Divine Blessings Coin Clicker

mscard02

New Member
Joined
Nov 10, 2014
Messages
40
Reaction score
0
Credit to mm2211 for his original code, i just modified it a little to get it working in the event. This will hold everyone over until Out can fix his new method.

Code:
using System;
using System.Collections.Generic;
using System.Threading;
using ArcheBuddy.Bot.Classes;
using System.Runtime.InteropServices;
using System.Windows;
namespace DivineGiftClicker
{
    public class DivineGiftClicker : Core
    {
        private int secondsBetweenClick = 905; //45mins is more than enough if your bot run more than 7.5hours per day but whatever number works for you

        public static string GetPluginAuthor()
        {
            return "mm2211";
        }
        public static string GetPluginVersion()
        {
            return "1.2";
        }
        public static string GetPluginDescription()
        {
            return "DivineGiftClick";
        }
        int windowDimensionsW = 1920;
        int windowDimensionsH = 1080;

        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool GetWindowRect(HandleRef hWnd, out RECT lpRect);

        [StructLayout(LayoutKind.Sequential)]
        public struct RECT
        {
            public int Left;        // x position of upper-left corner
            public int Top;         // y position of upper-left corner
            public int Right;       // x position of lower-right corner
            public int Bottom;      // y position of lower-right corner
        }
        public void PluginRun()
        {
            Log(DateTime.Now.ToString("M/d/yyyy H:mm:ss.fff") + " > Starting divinegiftclicker");
            Thread.Sleep(5000);
            handle = GetGameClientHandle();
            try
            {
                int style = GetWindowLong(handle, GWL_STYLE);
                bool wasminimized = false;
                if ((style & WS_MINIMIZE) == WS_MINIMIZE)
                { //this workaround an issue where the minimized game return a very small size (160x90 in my tests)
                    Log(" Window was minimized, restoring temporarily");
                    wasminimized = true;
                    ShowWindowAsync(handle, 1);//activate it
                    //because im too lazy to implement a proper way with call backs or locks, ill just spam it ! :P
                    Thread.Sleep(5000);
                    ShowWindowAsync(handle, 1);//activate it
                    Thread.Sleep(5000);
                    ShowWindowAsync(handle, 1);//activate it
                    Thread.Sleep(1000);
                    ShowWindowAsync(handle, 1);//activate it
                    Thread.Sleep(100);
                    ShowWindowAsync(handle, 1);//activate it
                }
                object o = new object();
                RECT data = new RECT();
                HandleRef hwnd = new HandleRef(o, handle);
                GetWindowRect(hwnd, out data);
                windowDimensionsH = Math.Abs(data.Bottom - data.Top);
                windowDimensionsW = Math.Abs(data.Left - data.Right);
                Log(" Window dimensions are : " + windowDimensionsW + " x " + windowDimensionsH);
                if (wasminimized)
                {
                    Log(" Window was minimized, minimizing back");
                    ShowWindowAsync(handle, 6);//minize it back
                    Thread.Sleep(5000);
                    //because im too lazy to implement a proper way with call backs or locks, ill just spam it ! :P
                    ShowWindowAsync(handle, 6);//minize it back
                    Thread.Sleep(1000);
                }
            }
            catch (Exception e)
            {
                if (e.GetType() != typeof(System.Threading.ThreadAbortException))
                {
                    Log("windowsgetdimension ERROR " + e.GetType().ToString() + " " + e.StackTrace);
                    Log(e.Message);
                }
            }


            double lastupdate = 0;
            while (true)
            { //to quit this plugin, you must click the stop button in the plugin manager, if the game crash the plugin will remain stuck in memory
                Thread.Sleep(10000);
                if (gameState != GameState.Ingame)
                    continue;
                double now = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
                if (now - lastupdate > secondsBetweenClick)
                {
                    lastupdate = now + (120 - r.Next(240)); //give or take 2 minutes
                    getDivineGift();
                    Log(DateTime.Now.ToString("M/d/yyyy H:mm:ss.fff") + " > Clicked the gift icon");
                }
            }
        }

        private long LastPauseRequest = 0;
        private int GiftAttemptCount = 0;
        private bool GaveErrorMessage = false;
        private int[] offsety = {0,-10, -20, 10,20};
        private void getDivineGift()
        {
            int retrycount = 0;
            if (gameState != GameState.Ingame)
                return; //not ingame
            if ((long)((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds) - LastPauseRequest < 1400)
            {
                return; //wait for 4 hours after a pause is requested
            }
            if (GiftAttemptCount > 12)
            {
                Log(DateTime.Now.ToString("M/d/yyyy H:mm:ss.fff") + " > Did it 11 times in this session, stop bothering for 4hours");
                LastPauseRequest = (long)((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds); //well try again in 4 hours
                GiftAttemptCount = 0;
            }
            int giftcount = 0;
            {
                List<Item> gifts = getInvItems(8000273);
                foreach (Item gift in gifts)
                {
                    giftcount += gift.count;
                }
            }
            Log(giftcount.ToString());
            
            int newgiftcount = giftcount;
            while (giftcount == newgiftcount && retrycount < 6)
            {
                Click(25, Convert.ToInt32(windowDimensionsH - 80 + offsety[retrycount]));
                Thread.Sleep(2000);
                newgiftcount = 0;
                {
                    List<Item> gifts = getInvItems(8000273);
                    foreach (Item gift in gifts)
                    {
                        newgiftcount += gift.count;
                    }
                }
                if (giftcount == newgiftcount)
                {
                    retrycount++;
                    Log(DateTime.Now.ToString("M/d/yyyy H:mm:ss.fff") + " > Click error, trying again in 5 secs... attempt:" + retrycount);
                    Thread.Sleep(5000);
                }
                else
                {
                    if (retrycount != 0)
                    {
                        offsety[0] = offsety[retrycount];
                    }
                    Log(DateTime.Now.ToString("M/d/yyyy H:mm:ss.fff") + " > Got Divine gift.");
                    return;
                }
            }
            if (!GaveErrorMessage && giftcount == newgiftcount)
            {
                Log(DateTime.Now.ToString("M/d/yyyy H:mm:ss.fff") + " > Unable to get the divine gift or it was sent to mail. Make sure you have an inventory slot, this can also happen if no gift are remaining. You will only see that message once");
                GaveErrorMessage = true;
            }
        }
        private static Random r = new Random(Convert.ToInt32(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds));
        private IntPtr handle;
        [return: MarshalAs(UnmanagedType.Bool)]
        [DllImport("user32.dll", SetLastError = true)]
        static extern bool PostMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

        [DllImport("user32.dll")]
        private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

        [DllImport("user32.dll", SetLastError = true)]
        static extern int GetWindowLong(IntPtr hWnd, int nIndex);
        const UInt32 WS_MINIMIZE = 0x20000000;
        const int GWL_STYLE = (-16);

        private void Click(int x, int y)
        {
            object o = new object();
            HandleRef hwnd = new HandleRef(o, handle);
            IntPtr secondparam = new IntPtr((y << 16) | x);
            IntPtr secondparamoffset = new IntPtr(((y+5) << 16) | (x+5));
            IntPtr zero = new IntPtr(0);
            
            int basesleep = 100;
            PostMessage(hwnd, 0x200, zero, secondparam); //first move the mouse virtually inside the window
            Thread.Sleep(r.Next(basesleep, basesleep * 2));
            PostMessage(hwnd, 0x202, zero, secondparam); //release the click
            Thread.Sleep(10);
            PostMessage(hwnd, 0x200, zero, secondparam); //move it again just in case the user is also moving the mouse
            PostMessage(hwnd, 0x201, zero, secondparam); //click the position
            Thread.Sleep(r.Next(basesleep / 4, basesleep/2));
            PostMessage(hwnd, 0x200, zero, secondparamoffset); //move it again just in case the user is also moving the mouse
            PostMessage(hwnd, 0x202, zero, secondparamoffset); //release the click
        }

        public void PluginStop()
        {
            Log(DateTime.Now.ToString("M/d/yyyy H:mm:ss.fff") + " > ----- " + GetPluginDescription() + " stopped -----");
        }
    }
}
 
Cheers m8, big thx, I created a plugin with the new method, but just noticed that it doesn`t work!

EDIT: Keep getting:

Code:
Window dimensions are : 33 x 21
6/8/2015 23:47:52.407 > Click error, trying again in 5 secs... attempt:1

Commented the line that automatically gets the windows dimension and set it manually, but it didn`t work also. :(
 
Last edited:
did a quick update, didn`t work for me, I had the window problem when it was lagging a lot in one of the computers, in this one its running 4 sessions, it is a bit slow, but not very much.
 
Voyager we probably just wrote did the same thing, lol

A bit annoyed actually at it myself.

Using an older Autoit method i have from earlier until it's working.

EDIT: I also have an ID of 8000007 not 8000273 as listed here.

Hummn
 
Last edited:
the dimension bug is because of how it act when a window is minimized , it reduce its resolution which mess with the detection (thats why i unmimize the window in the detection part), im currently using the same code and its working fine here.
 
i have 3 clients running at same time
it doesn't work for me : (
and it runs once and it turns itself off
 
double check to be sure the clicked position match your icon location. If you have a client mod changing its location or non default ui scaling it may be missing it (you can try just changing the

Click(25, Convert.ToInt32(windowDimensionsH - 80 + offsety[retrycount]));

line to be directly the relative coordinate of your button
(its Click(x,y)) the default config try a few different offset in hope to grab one that work.
 
i have 1024x768 will it work fine ? really need this working - you can purchase work compensation <
 
is the concept so complicated to understand ? If its not clicking at the right place change the code to tell it where to click... Theres very little point for me to actually improve / maintain the original code since its going to be deprecated by the proper fix on scheduled item once OUT does it.
 
is the concept so complicated to understand ? If its not clicking at the right place change the code to tell it where to click... Theres very little point for me to actually improve / maintain the original code since its going to be deprecated by the proper fix on scheduled item once OUT does it.
it clicks , tested for 1 hour ,sometimes it stopps randomly, not sure why. Good work !:)
 
Last edited:
Should be fixed. You can try it with latest update with getScheludedItems
 
6.9.2015 14:26:47.771 > Starting divinegiftclicker
Window dimensions are : 1920 x 1080
6
6.9.2015 14:28:35.011 > Got Divine gift.
6.9.2015 14:28:35.012 > Clicked the gift icon
6.9.2015 14:28:41.792 > ----- DivineGiftClick stopped -----
6.9.2015 14:47:51.492 > Starting divinegiftclicker
Window dimensions are : 1920 x 1080
7
6.9.2015 14:48:08.668 > Click error, trying again in 5 secs... attempt:1
6.9.2015 14:48:15.858 > Click error, trying again in 5 secs... attempt:2
6.9.2015 14:48:23.044 > Click error, trying again in 5 secs... attempt:3
6.9.2015 14:48:30.269 > Click error, trying again in 5 secs... attempt:4
6.9.2015 14:48:37.487 > Click error, trying again in 5 secs... attempt:5
6.9.2015 14:48:42.649 > ----- DivineGiftClick stopped -----
6.9.2015 14:50:25.209 > Starting divinegiftclicker
Window dimensions are : 1920 x 1080
6
6.9.2015 14:52:12.408 > Got Divine gift.
6.9.2015 14:52:12.421 > Clicked the gift icon
6.9.2015 14:56:40.110 > Starting divinegiftclicker
Window was minimized, restoring temporarily
Window dimensions are : 160 x 27
Window was minimized, minimizing back
6
6.9.2015 14:59:04.416 > Click error, trying again in 5 secs... attempt:1
6.9.2015 14:59:11.597 > Click error, trying again in 5 secs... attempt:2
6.9.2015 14:59:18.813 > Click error, trying again in 5 secs... attempt:3
6.9.2015 14:59:25.990 > Click error, trying again in 5 secs... attempt:4
6.9.2015 14:59:33.232 > Click error, trying again in 5 secs... attempt:5
6.9.2015 14:59:38.487 > ----- DivineGiftClick stopped -----



Thats Log

I am noob , can u make me file i download copy paste in plugin folder and click play.

interesting no one is selling this, i would paid 10$ for it with smile that anyone had made working one
 
Should be fixed. You can try it with latest update with getScheludedItems

i dont know what u talking about.

where is that ?
how i do that ?
is that pluging ?
pls i am new
 
Back
Top