AutoHotKey sporadic mouse movement behavior in particular program with Click/MoveMouse
<p>I made a quick ahk script that moved the mouse and found that the mouse wasn't getting moved to the desired location. I set up a loop that continually moved the cursor to the same position every couple of seconds, and the mouse would be moved to different, seemingly-random positions instead. I found that this was only the case with a specific program's window focused and if I had any other program focused the mouse moved as expected. I tried using Click/MouseMove, and they both exhibited this behavior. I also tried DllCall("SetCursorPosition"), but that wouldn't even move the mouse. Just to further clarify, all three of those worked fine when the problem program wasn't focused -- I only had issues when the problem program was focused.</p>

<p>Upon further inspection, this seemed to be due to the program's custom mouse sensitivity implementation. If I used MouseMove to move the cursor 1 pixel down relative to the current position, it'd move down ~50. If I increased the program's mouse sensitivity, it'd move down even further. I assume this is also why I was getting seemingly-random mouse positions with Click.</p>

<p>For now I've implemented a custom click function which unfocuses the program, moves the mouse, re-focuses the program, and then clicks, but the program doesn't like that. Sometimes it works, but sometimes the program will ignore mouse clicks from the position the mouse was when the window was focused, leading to the script not being able to do the things I want it to be able to do.</p>

<p>Is there a way for me to take into account this program's mouse sensitivity while using Click x,y/MouseMove? Or maybe an alternative method of moving the mouse that isn't affected by the program's mouse sensitivity. I've tried using all types of CoordMode, but all of them have the same problem.</p>

<p>Edit: Script I'm using</p>

<pre><code>CoordMode, Mouse,Screen ; I've tried every CoordMode but none solve the problem

AppsKey::
    while true {
        Click 500,500,0
        sleep,2000
    }
Return
</code></pre>