Thread: Handle raw mouse movement?

  1. #1
    Algorithm engineer
    Join Date
    Jun 2006

    Handle raw mouse movement?

    Hi, is there any way to prevent that the cursor position changes when the physical mouse moves, and at the same time see the movement of the mouse?

    If the task is platform dependent, the platform used is Windows.

    The reason I'm asking is that the mouse is going to be used to steer a robot arm when ctrl is held down. So pressing down ctrl should change the task of the mouse, from moving the mouse cursor to moving a robot arm. Hence, the cursor should freeze completely when ctrl is pressed down. It would be good if it was possible to take such control over the mouse buttons as well (i.e. preventing clicking and scrolling while using these events yourself), but maybe that is impossible in windows.
    Come on, you can do it! b( ~_')

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    segmentation fault
    It's for sure possible, but you need a library that deals with "mouse events". I imagine on windows that's the Win32 API.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    E.G. and for instance:

    ShowCursor Function (Windows)
    (although this may not be what you want exactly)

    SetCapture Function (Windows)

    I don't think your program can prevent the user from physically pushing a mouse button. You can ignore the message that your program will get, though.

  4. #4
    Algorithm engineer
    Join Date
    Jun 2006
    ShowCursor might be useful although it's not necessary. SetCapture might also be good, especially since I don't want buttons in other applications to be clicked accidentally, for example. However, this doesn't solve my problem.

    The question was never about preventing the user from physically moving the mouse. The mouse is after all going to be used for steering a robot arm. The question was to prevent the normal effects moving the mouse and using it's buttons usually have, while at the same time using the raw data from those events in my own program to steer the arm.

    Edit: What I have found, is the RAWMOUSE structure in windows.h. I'm not really sure how it works or if it can help me preventing unwanted effects of mouse events, but I hope that it can help me to collect that raw data I wanted.
    Last edited by TriKri; 05-03-2010 at 09:34 AM.
    Come on, you can do it! b( ~_')

  5. #5
    Registered User
    Join Date
    Jan 2009
    SetWindowsHookEx Function (Windows)

    You can install a global mouse or low level mouse hook.

    From memory if you don't pass it down the hook chain the data is not passed to other applications, and you can use the data. Which is, I think, what you want.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  2. simple mouse movement program
    By skankles in forum Windows Programming
    Replies: 3
    Last Post: 05-27-2007, 07:54 PM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  4. Mouse Movement
    By Extol in forum Windows Programming
    Replies: 6
    Last Post: 04-22-2003, 08:48 PM
  5. Need to read mouse movement in program
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 01-03-2002, 03:15 PM

Tags for this Thread