title: Mouse Events in vb.net
body: <p>I'm trying to move the mouse while a 3rd party application (out of my control) is activated (the topmost program). Ideally I want to move the mouse relative to my current position, but using absolute positions wouldn't be hard to convert to. Here's what I currently use;</p>
  
  <pre><code>&lt;DllImport("user32.dll")&gt; _
  Private Shared Sub mouse_event(dwFlags As UInteger, dx As UInteger, dy As UInteger, dwData As UInteger, dwExtraInfo As Integer)
  End Sub
  
  Public Sub MoveMouse(ByVal xPos As Long, ByVal yPos As Long)
      mouse_event(MOUSEEVENTF_MOVE, xPos, yPos, 0, 0)
  End Sub
  
  Public Const MOUSEEVENTF_MOVE = &amp;H1
  </code></pre>
  
  <p>It's called with;</p>
  
  <pre><code> MoveMouse(100, 100)
  </code></pre>
  
  <p>Now my problem is my mouse moves in y but not in x. I've tried some troubleshooting and it turns out the first value in the call (xPos) is actually the distance moved in y, not x. The yPos doesn't do anything.
  For example the below code moves the mouse down by 50 pixels;</p>
  
  <pre><code> MoveMouse(50, 0)
  </code></pre>
  
  <p>What am I doing wrong?</p>