Wrong cursor movement win32apiHow to debug in Django, the good way?How to get the cursor positionPython progression path - From apprentice to guruwin32: simulate a click without simulating mouse movement?Get mouse cursor image positionHow to track mouse movements without limiting it to screen size?Mouse cursors for CHeaderCtrlPython(Turtle Module) - Mouse Cursor Position in WindowMove mouse in certain direction while holding key in C++how to set cursor position out off the application window? (c++)

Do I have to take mana from my deck or hand when tapping a dual land?

If the only attacker is removed from combat, is a creature still counted as having attacked this turn?

When is "ei" a diphthong?

Pre-Employment Background Check With Consent For Future Checks

Overlapping circles covering polygon

Usage of an old photo with expired copyright

How to preserve electronics (computers, iPads and phones) for hundreds of years

What does "Scientists rise up against statistical significance" mean? (Comment in Nature)

Why didn’t Eve recognize the little cockroach as a living organism?

Is there a distance limit for minecart tracks?

What (the heck) is a Super Worm Equinox Moon?

Personal or impersonal in a technical resume

Language involving irrational number is not a CFL

Typing CO_2 easily

Does the Crossbow Expert feat's extra crossbow attack work with the reaction attack from a Hunter ranger's Giant Killer feature?

Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?

Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?

Limit max CPU usage SQL SERVER with WSRM

Can I cause damage to electrical appliances by unplugging them when they are turned on?

Showing mass murder in a kid's book

Check if object is null and return null

Giving feedback to someone without sounding prejudiced

Mimic lecturing on blackboard, facing audience

Has the laser at Magurele, Romania reached a tenth of the Sun's power?



Wrong cursor movement win32api


How to debug in Django, the good way?How to get the cursor positionPython progression path - From apprentice to guruwin32: simulate a click without simulating mouse movement?Get mouse cursor image positionHow to track mouse movements without limiting it to screen size?Mouse cursors for CHeaderCtrlPython(Turtle Module) - Mouse Cursor Position in WindowMove mouse in certain direction while holding key in C++how to set cursor position out off the application window? (c++)













-1















I am trying to move my cursor with win32api. I need to move to the point mid_x and mid_y knowing my current cursor position(x,y).



x, y = win32api.GetCursorPos()


Then, I find how much should i move.



dx = int(mid_x -x)
dy= int(mid_y - y)


Finally, i move my cursor!



win32api.mouse_event(0x0001, dx,dy, 0, 0)


In the end, my mouse moves in a wrong direction. I read a c++ documentation and found that dx and dy should be a mickey value. What does that mean and how can i change it to pixels?










share|improve this question

















  • 1





    Use MOUSEEVENTF_ABSOLUTE (0x8000) then you can just specify the absolute coordinates to move to. Note that mouse_event is deprecated, you should use SendInput instead (if this is available from python).

    – Jonathan Potter
    Mar 7 at 3:29











  • win32api.mouse_event(0x8000, dx, dy ,0 , 0) mouse didn't move at all

    – qwerty qwert
    Mar 7 at 3:59






  • 1





    You need to or it with the existing flag. Probably reading the docs wouldn't hurt.

    – Jonathan Potter
    Mar 7 at 7:01












  • ok. I figured it out

    – qwerty qwert
    Mar 7 at 18:40















-1















I am trying to move my cursor with win32api. I need to move to the point mid_x and mid_y knowing my current cursor position(x,y).



x, y = win32api.GetCursorPos()


Then, I find how much should i move.



dx = int(mid_x -x)
dy= int(mid_y - y)


Finally, i move my cursor!



win32api.mouse_event(0x0001, dx,dy, 0, 0)


In the end, my mouse moves in a wrong direction. I read a c++ documentation and found that dx and dy should be a mickey value. What does that mean and how can i change it to pixels?










share|improve this question

















  • 1





    Use MOUSEEVENTF_ABSOLUTE (0x8000) then you can just specify the absolute coordinates to move to. Note that mouse_event is deprecated, you should use SendInput instead (if this is available from python).

    – Jonathan Potter
    Mar 7 at 3:29











  • win32api.mouse_event(0x8000, dx, dy ,0 , 0) mouse didn't move at all

    – qwerty qwert
    Mar 7 at 3:59






  • 1





    You need to or it with the existing flag. Probably reading the docs wouldn't hurt.

    – Jonathan Potter
    Mar 7 at 7:01












  • ok. I figured it out

    – qwerty qwert
    Mar 7 at 18:40













-1












-1








-1








I am trying to move my cursor with win32api. I need to move to the point mid_x and mid_y knowing my current cursor position(x,y).



x, y = win32api.GetCursorPos()


Then, I find how much should i move.



dx = int(mid_x -x)
dy= int(mid_y - y)


Finally, i move my cursor!



win32api.mouse_event(0x0001, dx,dy, 0, 0)


In the end, my mouse moves in a wrong direction. I read a c++ documentation and found that dx and dy should be a mickey value. What does that mean and how can i change it to pixels?










share|improve this question














I am trying to move my cursor with win32api. I need to move to the point mid_x and mid_y knowing my current cursor position(x,y).



x, y = win32api.GetCursorPos()


Then, I find how much should i move.



dx = int(mid_x -x)
dy= int(mid_y - y)


Finally, i move my cursor!



win32api.mouse_event(0x0001, dx,dy, 0, 0)


In the end, my mouse moves in a wrong direction. I read a c++ documentation and found that dx and dy should be a mickey value. What does that mean and how can i change it to pixels?







python winapi






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 3:24









qwerty qwertqwerty qwert

2




2







  • 1





    Use MOUSEEVENTF_ABSOLUTE (0x8000) then you can just specify the absolute coordinates to move to. Note that mouse_event is deprecated, you should use SendInput instead (if this is available from python).

    – Jonathan Potter
    Mar 7 at 3:29











  • win32api.mouse_event(0x8000, dx, dy ,0 , 0) mouse didn't move at all

    – qwerty qwert
    Mar 7 at 3:59






  • 1





    You need to or it with the existing flag. Probably reading the docs wouldn't hurt.

    – Jonathan Potter
    Mar 7 at 7:01












  • ok. I figured it out

    – qwerty qwert
    Mar 7 at 18:40












  • 1





    Use MOUSEEVENTF_ABSOLUTE (0x8000) then you can just specify the absolute coordinates to move to. Note that mouse_event is deprecated, you should use SendInput instead (if this is available from python).

    – Jonathan Potter
    Mar 7 at 3:29











  • win32api.mouse_event(0x8000, dx, dy ,0 , 0) mouse didn't move at all

    – qwerty qwert
    Mar 7 at 3:59






  • 1





    You need to or it with the existing flag. Probably reading the docs wouldn't hurt.

    – Jonathan Potter
    Mar 7 at 7:01












  • ok. I figured it out

    – qwerty qwert
    Mar 7 at 18:40







1




1





Use MOUSEEVENTF_ABSOLUTE (0x8000) then you can just specify the absolute coordinates to move to. Note that mouse_event is deprecated, you should use SendInput instead (if this is available from python).

– Jonathan Potter
Mar 7 at 3:29





Use MOUSEEVENTF_ABSOLUTE (0x8000) then you can just specify the absolute coordinates to move to. Note that mouse_event is deprecated, you should use SendInput instead (if this is available from python).

– Jonathan Potter
Mar 7 at 3:29













win32api.mouse_event(0x8000, dx, dy ,0 , 0) mouse didn't move at all

– qwerty qwert
Mar 7 at 3:59





win32api.mouse_event(0x8000, dx, dy ,0 , 0) mouse didn't move at all

– qwerty qwert
Mar 7 at 3:59




1




1





You need to or it with the existing flag. Probably reading the docs wouldn't hurt.

– Jonathan Potter
Mar 7 at 7:01






You need to or it with the existing flag. Probably reading the docs wouldn't hurt.

– Jonathan Potter
Mar 7 at 7:01














ok. I figured it out

– qwerty qwert
Mar 7 at 18:40





ok. I figured it out

– qwerty qwert
Mar 7 at 18:40












1 Answer
1






active

oldest

votes


















0














//get the Screen resolution.
scalex = win32api.GetSystemMetrics(win32con.SM_CXSCREEN);
scaley = win32api.GetSystemMetrics(win32con.SM_CYSCREEN);

//get the scale(a screen has 65535*65535 mickey value)
scalex = 65535 / scalex;
scaley = 65535 / scaley;

win32api.mouse_event(0x8000 | 0x0001, dx* scalex, dy* scaley, 0, 0);





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55035576%2fwrong-cursor-movement-win32api%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    //get the Screen resolution.
    scalex = win32api.GetSystemMetrics(win32con.SM_CXSCREEN);
    scaley = win32api.GetSystemMetrics(win32con.SM_CYSCREEN);

    //get the scale(a screen has 65535*65535 mickey value)
    scalex = 65535 / scalex;
    scaley = 65535 / scaley;

    win32api.mouse_event(0x8000 | 0x0001, dx* scalex, dy* scaley, 0, 0);





    share|improve this answer



























      0














      //get the Screen resolution.
      scalex = win32api.GetSystemMetrics(win32con.SM_CXSCREEN);
      scaley = win32api.GetSystemMetrics(win32con.SM_CYSCREEN);

      //get the scale(a screen has 65535*65535 mickey value)
      scalex = 65535 / scalex;
      scaley = 65535 / scaley;

      win32api.mouse_event(0x8000 | 0x0001, dx* scalex, dy* scaley, 0, 0);





      share|improve this answer

























        0












        0








        0







        //get the Screen resolution.
        scalex = win32api.GetSystemMetrics(win32con.SM_CXSCREEN);
        scaley = win32api.GetSystemMetrics(win32con.SM_CYSCREEN);

        //get the scale(a screen has 65535*65535 mickey value)
        scalex = 65535 / scalex;
        scaley = 65535 / scaley;

        win32api.mouse_event(0x8000 | 0x0001, dx* scalex, dy* scaley, 0, 0);





        share|improve this answer













        //get the Screen resolution.
        scalex = win32api.GetSystemMetrics(win32con.SM_CXSCREEN);
        scaley = win32api.GetSystemMetrics(win32con.SM_CYSCREEN);

        //get the scale(a screen has 65535*65535 mickey value)
        scalex = 65535 / scalex;
        scaley = 65535 / scaley;

        win32api.mouse_event(0x8000 | 0x0001, dx* scalex, dy* scaley, 0, 0);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 2:34









        Drake Wu - MSFTDrake Wu - MSFT

        63017




        63017





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55035576%2fwrong-cursor-movement-win32api%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            1928 у кіно

            Захаров Федір Захарович

            Ель Греко