Thread: Mousekeys

  1. #1
    Registered User Bag a Bones's Avatar
    Join Date
    Dec 2005
    Posts
    15

    Mousekeys

    Im doing a term project in grade 11 computer and information science. My project has a joystick that will controll the mouse. Unfortunatly, im fairly new to C++, and I don't how to move the mouse... I found this code and I think its what I need, but I dont know how to use it. Can anybody give me a hand?

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Hi, welcome to the forums!

    It sounds like you wish to use code to move the mouse cursor. You can do this with the SetCursorPos function or the mouse_event function. The page you linked to is part of the Windows CE documentation. If you are not using CE, you should use the normal Windows documentation.
    Code:
    #include <windows.h>
    
    int main(void)
    {
        SetCursorPos(10, 20);
        return 0;
    }

  3. #3
    Registered User Bag a Bones's Avatar
    Join Date
    Dec 2005
    Posts
    15
    Wow. That was way simpler than I thought it would be! Thanks very much! Now I need to do the whole joystick part...WooHoo... Any resources you might suggest for that?

    BTW: how do you make it click?
    Last edited by Bag a Bones; 12-21-2005 at 09:12 AM.

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    >> BTW: how do you make it click? <<

    You can use the mouse_event function to simulate a mouse click. A click consists of a button down event followed by a button up event.
    Code:
    #include <windows.h>
    
    int main(void)
    {
        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
        return 0;
    }

Popular pages Recent additions subscribe to a feed