Simple "unlimited" hotkey sending bot concept (C++)

Discussion in 'Tutorials & Source Codes' started by edx, Aug 2, 2015.

  1. edx

    edx The New Guy

    Post Count:
    40
    Likes Received:
    3
    Stats
    Based on what I have seen, most people (mainly the beginners) would usually create a thread for each function that sends a key to a window at it’s own pace. It’s inefficient when most of the functions are just simply sending a key every ‘x’ amount of time. Additionally, the codes are usually messy and ugly.

    I have a developed a concept for a simple and more efficient approach. With it, we can write bots that can send a lot of keys to a window at different intervals on a single thread.

    First, we will need a struct for the keys, which is the main part of this concept.

    Code:
    struct KeyToSend {
       char   key;        // The key to send.
       int    interval;   // Break duration in milliseconds (msecs.)
       bool   enabled;    // To enable or disable the sending of the key.
      
       int    tickCount;  // Counter how many msecs. has passed after the key was sent.
     };


    Next, there should be an array or a container of KeyToSend. We’ll just keep it simple and use an array with a fixed size, which could be like 100. It could be more or less but understand the amount of keys does affect the speed of processing the array. The longer it takes to process, the higher the interval of each items in the array will be.

    Code:
    KeyToSend KeysToSend[MAX_KEY_TO_SEND] = {};




    Then, there should be a function to process the array (KeysToSend). Like so:

    Code:
    void Processor()
    
     {
       while(true)
       {
         Sleep(1); // Wait for 1 msec. We could write or use some other functions instead of Sleep().
         for(int i = 0; i != MAX_KEY_TO_SEND; ++i)
         {
           if(KeysToSend.enabled)
           {
             if(KeysToSend.tickCount >= KeysToSend.interval) {
               // TO DO: Call a function to send KeysToSend.key.
               // PostMessage is recommended!
               KeysToSend.tickCount = 0; // Reset.
             }
             else { KeysToSend.tickCount++; }
           }
         }
     }
     }




    Now, we just need create a single thread for the processor, which can send more than 100 keys to a window at different intervals.

    Code:
    HANDLE processorThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&processor, NULL, 0, NULL);
    
     // Don't forget to close this handle when cleaning up.


    There we have it! There could be mistakes and more room for improvement but, it's a concept that explains the idea of what we need to write to create a working multi-key sending bot, which is capable of sending over 100 of keys at different interval -- with a single thread. I am looking forward to apply this concept to an actual application in my spare time!
     
    Last edited: Aug 6, 2015

    Mr. Ad Advertisement

     
  2. Lolzi

    Lolzi United States Fanatic Hacker

    Post Count:
    214
    Likes Received:
    7
    Stats


    I don't specialiazie / mess in maplestory that often ,but the concept looks great Thanks would help alot
     
  3. Millianna

    Millianna Romania The New Guy

    Post Count:
    28
    Likes Received:
    0
    Stats
    I'm going to try it!
    I hope I'll made it, because it looks a little complicated to me. :) But I'll try!!! :D
     
  4. edx

    edx The New Guy

    Post Count:
    40
    Likes Received:
    3
    Stats
    Thanks for trying it out! Makes me happy knowing that this thread is at least useful to someone. Let me know if you need help or if you have any questions. The more you practice, the more you can learn and gain experience. Good luck!
     
  5. Jan nielsen

    Jan nielsen Denmark Lurker

    Post Count:
    7
    Likes Received:
    1
    Stats
    going to try! ;P
     

Share This Page

  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies.
    Dismiss Notice
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies.
    Dismiss Notice