Page 1 of 2 12 LastLast
Results 1 to 25 of 32

Thread: [c++] runescape bot

  1. #1
    Join Date
    Apr 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default [c++] runescape bot

    so what im trying to do is create a rs client in c++. i have an api spy im using to grab the game child hwnd. is there anyway i can do this without first opening internet explorer? and how can i move the mouse in the client without moving the actual mouse?

  2. #2
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    To grab the HWND of the game, it has to be open first. As for making a fake mouse, look up "SendMessage" and "PostMessage" in the windows API.

  3. #3
    Join Date
    Apr 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thank you sir. and i know the game has to be open, i was just wondering if i could open it independantly so the user wouldnt have to

  4. #4
    Join Date
    Dec 2011
    Location
    Berlin
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    This is going to be a really nice project. Would be nice to see this thread updated =)

    I will try to answer all Runescape related questions!

  5. #5
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    You could create something like SMART (load the game client via java) and interface it with JNI, or you can simply open firefox up with the game URL.

  6. #6
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    You can use the SMART library.

    Edit: 'd.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  7. #7
    Join Date
    Apr 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I would use smart lib but im the type of guy who has to know how things work and do it myself.
    Anyways, i got the client working mostly, it just wont accept messages.
    Last edited by kibbles18; 04-15-2012 at 09:57 PM.

  8. #8
    Join Date
    Apr 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    does anybody know why the client wont accept sendmessage or postmessage?

  9. #9
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Let me see your code using SendMessage. By the way, you need to replicate the mouse. You can't just send random click events because its easily detectable. You need to replicate all the mouse movement.

  10. #10
    Join Date
    Apr 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    switch(msg)
    {
    case WM_CLOSE:
    DestroyWindow(hwnd);
    break;
    case WM_DESTROY:
    PostQuitMessage(0);
    break;
    case WM_KEYDOWN:
    switch(LOWORD (wParam))
    {
    //case VK_UP:
    }
    default:
    return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
    }
    Last edited by kibbles18; 04-16-2012 at 12:56 AM.

  11. #11
    Join Date
    Apr 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    whats the msg for mouse events?

  12. #12
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by kibbles18 View Post
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    SendMessageA(client, msg, wParam, lParam);
    switch(msg)
    {
    case WM_CLOSE:
    DestroyWindow(hwnd);
    break;
    case WM_DESTROY:
    PostQuitMessage(0);
    break;
    case WM_KEYDOWN:
    switch(LOWORD (wParam))
    {
    //case VK_UP:
    }
    default:
    return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
    }
    Try using PostMessage. Also, you need to use coordinates relative to the whole screen and not just your client.

    What do you mean it acts weird?

  13. #13
    Join Date
    Apr 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    it seems i need to choose which events get sent to the client and which dont.
    for example moving the parent will move the child client instead

  14. #14
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by kibbles18 View Post
    it seems i need to choose which events get sent to the client and which dont.
    for example moving the parent will move the child client instead
    Its probably the method you're using (why are you putting SendMessage in WndProc?). I really can't help any further since I don't have a windows PC to test anything on.

  15. #15
    Join Date
    Apr 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    because im not sure how else to send messages to the rs client seeing they wont by themselves

  16. #16
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Something along the lines of: (pseudo code)

    Code:
    void leftMouseClick(HWND window, int x, int y) // note: x, y are relative to the screen, not the client., so if the client is located at 500,500 and you want to click at 5, 5 - x, y would be: 505, 505.
    {
        SendMessage(window, WM_MBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
        SendMessage(window, WM_MBUTTONUP, MK_LBUTTON, MAKELPARAM(x, y));
    }
    Then you need some way of making scripts to do the clicking for you. (it might be alot more in depth than you think).

  17. #17
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Follow the discussion in this thread if you want to know how you could get the HWND: http://villavu.com/forum/showthread.php?t=54922
    There used to be something meaningful here.

  18. #18
    Join Date
    Apr 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    the problem is that i cant type in anything like my username and pass. ill add the botting stuff later right now its a client

  19. #19
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by kibbles18 View Post
    the problem is that i cant type in anything like my username and pass. ill add the botting stuff later right now its a client
    I see, well I can't really help much further. I don't have windows to test any code on and I can't point you in the right direction without testing.

  20. #20
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Perhaps these help?
    Code:
    void MainWindow::MouseMove(int x, int y)
    {
        double fScreenWidth = GetSystemMetrics(SM_CXSCREEN) - 1;
        double fScreenHeight = GetSystemMetrics(SM_CYSCREEN) - 1;
        double fx = x * (65535.0f / fScreenWidth);
        double fy = y * (65535.0f / fScreenHeight);
        INPUT input = {0};
        ZeroMemory(&input, sizeof(input));
        input.type = INPUT_MOUSE;
        input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
        input.mi.dx = fx;
        input.mi.dy = fy;
        SendInput(1, &input, sizeof(INPUT));
    }
    
    void MainWindow::KB_A(bool keyUp)
    {
        INPUT input = {0};
        ZeroMemory(&input, sizeof(input));
        if (keyUp && aDown)
        {
            input.type = INPUT_KEYBOARD;
            input.ki.wVk = 'A';
            input.ki.dwFlags = KEYEVENTF_KEYUP;
            input.ki.time = 0;
            input.ki.dwExtraInfo = NULL;
            aDown = false;
        } else {
            input.type = INPUT_KEYBOARD;
            input.ki.wVk = 'A';
            input.ki.time = 0;
            input.ki.dwExtraInfo = NULL;
            aDown = true;
        }
        SendInput(2, &input, sizeof(INPUT));
    }
    There used to be something meaningful here.

  21. #21
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Frement View Post
    Perhaps these help?
    Code:
    void MainWindow::MouseMove(int x, int y)
    {
        double fScreenWidth = GetSystemMetrics(SM_CXSCREEN) - 1;
        double fScreenHeight = GetSystemMetrics(SM_CYSCREEN) - 1;
        double fx = x * (65535.0f / fScreenWidth);
        double fy = y * (65535.0f / fScreenHeight);
        INPUT input = {0};
        ZeroMemory(&input, sizeof(input));
        input.type = INPUT_MOUSE;
        input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
        input.mi.dx = fx;
        input.mi.dy = fy;
        SendInput(1, &input, sizeof(INPUT));
    }
    
    void MainWindow::KB_A(bool keyUp)
    {
        INPUT input = {0};
        ZeroMemory(&input, sizeof(input));
        if (keyUp && aDown)
        {
            input.type = INPUT_KEYBOARD;
            input.ki.wVk = 'A';
            input.ki.dwFlags = KEYEVENTF_KEYUP;
            input.ki.time = 0;
            input.ki.dwExtraInfo = NULL;
            aDown = false;
        } else {
            input.type = INPUT_KEYBOARD;
            input.ki.wVk = 'A';
            input.ki.time = 0;
            input.ki.dwExtraInfo = NULL;
            aDown = true;
        }
        SendInput(2, &input, sizeof(INPUT));
    }
    I believe that code uses the real mouse/keyboard instead of simulating mouse/key presses.

  22. #22
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by ShawnjohnSJ View Post
    I believe that code uses the real mouse/keyboard instead of simulating mouse/key presses.
    Oh yes it does, sorry about that, but for keyboard it shouldn't matter?

    Heres more updated code:
    Code:
    void MainWindow::PressKey(WORD vKey, bool keyUp)
    {
        INPUT input;
        ZeroMemory(&input, sizeof(INPUT));
        input.type = INPUT_KEYBOARD;
        input.ki.wVk = vKey;
        input.ki.dwFlags = keyUp ? KEYEVENTF_KEYUP : 0;
        input.ki.time = 0;
        input.ki.dwExtraInfo = NULL;
        keys[vKey] = keyUp;
        SendInput(2, &input, sizeof(INPUT));
    }
    There used to be something meaningful here.

  23. #23
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Frement View Post
    Oh yes it does, sorry about that, but for keyboard it shouldn't matter?

    Heres more updated code:
    Code:
    void MainWindow::PressKey(WORD vKey, bool keyUp)
    {
        INPUT input;
        ZeroMemory(&input, sizeof(INPUT));
        input.type = INPUT_KEYBOARD;
        input.ki.wVk = vKey;
        input.ki.dwFlags = keyUp ? KEYEVENTF_KEYUP : 0;
        input.ki.time = 0;
        input.ki.dwExtraInfo = NULL;
        keys[vKey] = keyUp;
        SendInput(2, &input, sizeof(INPUT));
    }
    It does if you want to send key presses with the client minimized. That doesn't send key presses to any specific window, just to whatever is focused.
    Last edited by ShawnjohnSJ; 04-15-2012 at 11:11 PM.

  24. #24
    Join Date
    Apr 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    they help, but not right now.
    im out, ill try more tommorow

  25. #25
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by ShawnjohnSJ View Post
    It does if you want to send key presses with the client minimized. That doesn't send key presses to any specific window, just to whatever is focused.
    Well I'll be damned. I suppose I can't paste anything specific to this situation then.
    There used to be something meaningful here.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •