Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>mouse_event (and SendInput, which is the preferred API to use for input) have a couple of tricky bits, it's a good idea to <A HREF="http://msdn.microsoft.com/en-us/library/windows/desktop/ms646260(v=vs.85).aspx" rel="nofollow">read the MSDN page for mouse_event</A> fully and carefully before using it - pay attention to the small print: in particular, the x and y values are <em>not</em> pixels, so you can't just put in values you get from GetCursorPos.</p> <p>It just happens that 0,0 is the bottom-left corner, so points near the bottom left will be roughly in the same area of the screen, but the further away from that you get, the more the pixel values diverge from the actual units that this API uses: so it can appear to work for positions near the start button (assuming it's in the bottom left of the screen), but for other values, it may appear to be clicking somewhere else, which sounds similar to what you are seeing.</p> <p>From MSDN:</p> <blockquote> dx [in] <br> Type: DWORD <br> The mouse's absolute position along the x-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE. Absolute data is specified as the mouse's actual x-coordinate; relative data is specified as the number of mickeys moved. A mickey is the amount that a mouse has to move for it to report that it has moved. </blockquote> <p>So first of all, you need the MOUTEVENTF_ABSOLUTE flag. But that's not all:</p> <blockquote> Remarks<br> ... If MOUSEEVENTF_ABSOLUTE value is specified, <b>dx and dy contain normalized absolute coordinates between 0 and 65,535.</b> 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. </blockquote> <p>...so you'll need to scale your target coordinates appropriately before passing them to this API.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload