Moving Cursor using mouse_event()

This is a discussion on Moving Cursor using mouse_event() within the C++ Programming forums, part of the General Programming Boards category; i am trying to move mouse cursor by capturing finger coordinate in opencv. i am not able to move the ...

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    6

    Unhappy Moving Cursor using mouse_event()

    i am trying to move mouse cursor by capturing finger coordinate in opencv. i am not able to move the cursor to maximum screen size which is 1366*768. my webcam resolution is 640*480. my mouse pointer moves only to half of the screen. i do not know why.
    This is my code segment. mouse_pointer.x and mouse_pointer.y are the coordinate of my fore-finger.The Mouse_move is not an opencv function.
    this is the function call:

    Code:
    Mouse_Move(((1366*mouse_pointer.x)/640),((768*mouse_pointer.y)/480));
    void Mouse_Move(DWORD dx,DWORD dy)
    {
    
    DWORD event=0;
    event = MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE;
    mouse_event(event, dx*65535/Get_ScreenWidth(), dy*65535/Get_ScreenHight(), 0, 0);
    }
    Last edited by Salem; 04-18-2012 at 11:19 AM. Reason: demungled the code

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    > Mouse_Move(((1366*mouse_pointer.x)/640),((768*mouse_pointer.y)/480));
    What type are the .x, .y members?

    Unless they're DWORD, my guess is numeric overflow.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Apr 2012
    Posts
    6
    This is the function prototype.
    Mouse_Move(DWORD dx, DWORD dy);
    the .x and .y are integers. what am i supposed to do ?

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    Are those 16-bit integers?

    Because you have numeric overflow if they are.

    Another thing to consider is where "0,0" is considered to be for the different things you have.
    If the image thinks 0,0 is the centre of the image, and the mouse coordinates have 0,0 at the top-left, then this is something you have to take into account.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Apr 2012
    Posts
    6
    they are 32-bit integers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Moving cursor to the end of line
    By behzad_shabani in forum C Programming
    Replies: 5
    Last Post: 05-30-2008, 12:41 PM
  2. Moving the cursor
    By dra in forum C++ Programming
    Replies: 5
    Last Post: 05-03-2005, 04:11 AM
  3. Moving the cursor around.
    By Lithorien in forum C++ Programming
    Replies: 3
    Last Post: 12-25-2004, 03:36 PM
  4. Moving the cursor around
    By doormat in forum Linux Programming
    Replies: 6
    Last Post: 04-22-2004, 06:29 AM
  5. moving cursor to the next line
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 04-15-2002, 10:47 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21