mouse_event

This is a discussion on mouse_event within the Windows Programming forums, part of the Platform Specific Boards category; Hey, i am using mouse_event function to simulate mouse input, but when i set the mouse position it moves very ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220

    mouse_event

    Hey, i am using mouse_event function to simulate mouse input, but when i set the mouse position it moves very litlle, the values i used are the in the range of my screen resolution [0x0 - 1440x900]. What should i do?

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,772
    I think you need to explain a little more... I don't get the big picture.
    What are you trying to do?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220
    Ah, sorry :P

    Im trying to set the mouse position at some position on the screen, but when i set like 900x350, the mouse dont appear at the position i wished, it appears in 50x10 (hipothetical values :P ).

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,772
    And how are you setting the mouse position?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220
    Code:
    RECT resolution;
    HWND desktop = GetDesktopWindow();
    
    GetWindowRect(desktop, &resolution);
    
    int width  = resolution.right;
    int height = resolution.bottom;
    
    mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, (dot1.X) * width, (1.0f - dot1.Y) * height, 0, 0);
    Where dot1.X is between 0.0f and 1.0f, and same for dot1.Y.

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,772
    If you want the set the mouse's coordinates on the screen, use SetCursorPos.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220
    Yes, i tried that but if i use SetCursorPos inside a game the cursor just dont answer, and that isnt true with mouse_event.

    After reading the remarks: "If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface, (65535,65535) maps onto the lower-right corner."

    Thats for me to learn that i should always read remarks :P. Thank you =)

Popular pages Recent additions subscribe to a feed

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