Keypresses in Maplestory with C++

Discussion in 'MapleStory Global & Europe' started by Bunni671, Jan 2, 2018.

  1. Bunni671

    Bunni671 United States Lurker

    Post Count:
    5
    Likes Received:
    0
    Stats
    Hey everyone, I've only recently started trying to bot in Maplestory and would really appreciate some help. I've spent some time reading about utilizing SendInput from the Windows API to send key scan codes to mimic keypresses, and I've tried it but couldn't get it to work. The posts I was reading were pretty outdated, so I might be trying something that doesn't work anymore.

    Nowadays, which methods work to send keypresses to Maplestory? Do I need to package the code in a .dll file and inject into Maplestory, or is that unnecessary? I'm ultimately trying to write a macro with C++ to automate some repetitive tasks.

    If anyone could share some insight, I'd really appreciate it!
     

    Mr. Ad Advertisement

     
  2. NORBIN

    NORBIN Canada Veteran Hacker

    Post Count:
    143
    Likes Received:
    2,218
    Stats
    SendInput most likely does not work for the same reason Post/SendMessage does not work here:
     
  3. Bunni671

    Bunni671 United States Lurker

    Post Count:
    5
    Likes Received:
    0
    Stats
    Thanks for the quick response. If Maplestory is the window currently being focused on, PostMessage will still work, right? Also, do I need to make sure my C++ executable is running before loading Maplestory, or can I make changes while having Maple open on the side?
     
  4. NORBIN

    NORBIN Canada Veteran Hacker

    Post Count:
    143
    Likes Received:
    2,218
    Stats
    Should work, I don't really use Windows API methods for anything personally so can't tell you for sure. I don't think it matters if you're injected or not, an executable can still send keypresses as long as you specify what window to send them to (usually the attached process for a trainer).
     
  5. Bunni671

    Bunni671 United States Lurker

    Post Count:
    5
    Likes Received:
    0
    Stats
    #include <windows.h>

    int main() {
    HWND hWnds = FindWindow("MapleStoryClass", NULL);​

    SetForegroundWindow(hWnds);
    Sleep(1000);
    PostMessage(hWnds, WM_KEYDOWN, 0x41, 0x1E0001);
    Sleep(200);
    PostMessage(hWnds, WM_KEYUP, 0x41, 0x1E0001);​
    }

    I can't even trigger this keypress in Maplestory using the code above. Does this look good to you? I grabbed 0x41 and 0x1E0001 from spy++.

    Edit: Added tabs for spacing.
     
    Last edited: Jan 3, 2018
  6. hackbotmaple

    hackbotmaple Malaysia Fanatic Hacker

    Post Count:
    203
    Likes Received:
    1,744
    Stats
    Declare AttackKey
    Code:
    DWORD AttackKey = 0xA2;
    
    Code:
    HWND hwnd = FindWindow(TEXT("MapleStoryClass"), 0);
    LPARAM lParam = (MapVirtualKey(AttackKey, 0) << 16) + 1;
    PostMessage(hwnd, WM_KEYDOWN, AttackKey, lParam); //
    Sleep(50); //
    PostMessage(hwnd, WM_KEYUP, AttackKey, lParam);
    Sleep(10);
    
    This works for me :)

    Edit: You have to set maplestory window on focus.
     
  7. Bunni671

    Bunni671 United States Lurker

    Post Count:
    5
    Likes Received:
    0
    Stats
    I don't understand. This doesn't work for me. Did you have to do anything else, or did you just run your executable from the terminal?
     
  8. omgimanerd1998

    omgimanerd1998 United States Lurker

    Post Count:
    1
    Likes Received:
    0
    Stats
    Was there any update on this? There are conflicting answers on whether or not PostMessage() still works with Maplestory.
     
  9. g1zstar

    g1zstar United States The New Guy

    Post Count:
    18
    Likes Received:
    1
    Stats
    Its always has semi-worked. Just certain things you can't do. Such as movement when the window is not focused, depending on how you do it.
     
  10. MiguelBLopez6

    MiguelBLopez6 United States Windia's King Premium

    Post Count:
    376
    Likes Received:
    190
    Stats
    It still works. The people saying otherwise aren't running their debug/release as Admin.
     
  11. LiuL14n

    LiuL14n Taiwan Lurker

    Post Count:
    1
    Likes Received:
    0
    Stats
    Thank you very much! This works for me! :)
     

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