Results 1 to 5 of 5

Thread: Need SendMessage help for a Video game

  1. #1
    Join Date
    Jun 2011
    Posts
    109

    Need SendMessage help for a Video game

    Hi, I have done coding for my game but it seems to be troubleshooting. Please help accordingly. I am from MMORPG gamin community. I have created simple tools for players for example as one of its parts should level up just holding down right mouse button and your character kills the monsters around it. You can also put something on your right hand of the character by holding the right mouse button and go outside. I want an abstract algorithm for my application actions. I have done the following coding:
    Code:
    LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
        switch (Msg)
        {
            case WM_DESTROY:
                PostQuitMessage(0);
                break;
                
            case WM_KEYDOWN:
            {
                if (wParam == VK_F11)
                {
                    SendMessage(hMU, WM_RBUTTONDOWN, 0, 0);
                }
                else if (wParam == VK_F12)
                {
                    SendMessage(hMU, WM_RBUTTONUP, 0, 0);
                }
                break;
            }
            
            default:
                return DefWindowProc(hWnd, Msg, wParam, lParam);
        }
        
        return 0;
    }

  2. #2
    Join Date
    May 2009
    Posts
    543

    Re: Need SendMessage help for a Video game

    You can take reference from the code below. In this code PostMessage() is used instead of SendMessage(). For the SendMessage() the code is similar, you just have to replace PostMessage() with SendMessage(). Also the mouseclick has been given some co-ordinates:
    Code:
    int mouseX = 200;
    int mouseY = 100;
    
    PostMessage(hMU, WM_LBUTTONDOWN, 0, MAKELPARAM(mouseX,mouseY))
    Also try putting debugger without an LPARAM. Just check, you will find help from these.

  3. #3
    Join Date
    Apr 2009
    Posts
    569

    Re: Need SendMessage help for a Video game

    Just modify the code as I am advising. Below, I have done the coding, you just have to copy paste it in your actual source.
    For Top:
    Code:
    if (wParam == VK_F11)
    {
        SetWindowPos(hMU, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE |
        SWP_NOSIZE | SWP_SHOWWINDOW);
                    
        INPUT input;
                    
        memset(&input, 0, sizeof(INPUT));
        input.type = INPUT_MOUSE;
        input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
                    
        SendInput(1, &input, sizeof(INPUT));
    }
    For Bottom:
    Code:
    SetWindowPos(hMU, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | 
    SWP_NOSIZE | SWP_HIDEWINDOW);

  4. #4
    Join Date
    Apr 2009
    Posts
    488

    Re: Need SendMessage help for a Video game

    You still did not found any help for your gaming action then try sum of these code below:
    Code:
    POINT pt;
    pt.x = 100;
    pt.y = 100;
    ScreenToClient(hMU, &pt);
    SendMessage(hMU, WM_RBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y));
    SendMessage(hMU, WM_RBUTTONUP, 0, MAKELPARAM(pt.x, pt.y));
    In this code the window is trying to post the messages is the main game window. Because it has seven or eight child windows. As soon as you will call the above functions you will get a pop-up window like edit controls.

  5. #5
    Join Date
    May 2009
    Posts
    527

    Re: Need SendMessage help for a Video game

    I have something for you. This might help you. The following is the code for F11 and F12. After applying your F11 and F12 button will function as you were wishing it to work. Just do the adjustments in your source code as I have suggested below:
    Code:
    HWND handles[10];
    int i;
    
    BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) { return (BOOL)(handles[i++] = hwnd); }
    
    LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
    ...
            case WM_KEYDOWN:
            {
                if (wParam == VK_F11)
                {
                    EnumChildWindows(hMU, EnumChildProc, 0);
                    i = 0;
                }
                else if (wParam == VK_F12)
                {
                    POINT pt;
                    pt.x = 100;
                    pt.y = 100;
                    ScreenToClient(hMU, &pt);
                    SendMessage(handles[i], WM_RBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y));
                    SendMessage(handles[i++], WM_RBUTTONUP, 0, MAKELPARAM(pt.x, pt.y));
                }
                else if (wParam == VK_F1)
                {
                    char index[2];
                    sprintf(index, "%d", i);
                    MessageBox(NULL, index, NULL, 0);
                }
                break;

Similar Threads

  1. Replies: 5
    Last Post: 11-07-2011, 02:31 AM
  2. Up Video game (Wii)
    By absolute55 in forum Reviews
    Replies: 1
    Last Post: 13-05-2011, 05:00 AM
  3. Replies: 5
    Last Post: 22-10-2010, 01:58 PM
  4. Dual screen: Video Game + Video => Bug!
    By Ethex in forum Windows Software
    Replies: 6
    Last Post: 20-10-2008, 04:37 PM
  5. Looking for a video game for Wii
    By Armani in forum Video Games
    Replies: 3
    Last Post: 16-10-2008, 07:36 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,007,347.76588 seconds with 17 queries