| 5943 | |
| 5944 | |
| 5945 | void Line::MouseMove(int aX, int aY, int aSpeed, bool aMoveRelative) |
| 5946 | // Note: This is based on code in the AutoIt3 source. |
| 5947 | { |
| 5948 | POINT ptCur; |
| 5949 | int xCur, yCur; |
| 5950 | int delta; |
| 5951 | const int nMinSpeed = 32; |
| 5952 | RECT rect; |
| 5953 | |
| 5954 | if (aSpeed < 0) // This can happen during script's runtime due to MouseClick's speed being a var containing a neg. |
| 5955 | aSpeed = 0; // 0 is the fastest. |
| 5956 | else |
| 5957 | if (aSpeed > MAX_MOUSE_SPEED) |
| 5958 | aSpeed = MAX_MOUSE_SPEED; |
| 5959 | |
| 5960 | if (aMoveRelative) // We're moving the mouse cursor relative to its current position. |
| 5961 | { |
| 5962 | GetCursorPos(&ptCur); |
| 5963 | aX += ptCur.x; |
| 5964 | aY += ptCur.y; |
| 5965 | } |
| 5966 | else if (!(g.CoordMode & COORD_MODE_MOUSE)) // Moving mouse relative to the active window (rather than screen). |
| 5967 | { |
| 5968 | HWND fore = GetForegroundWindow(); |
| 5969 | // Revert to screen coordinates if the foreground window is minimized. Although it might be |
| 5970 | // impossible for a visible window to be both foreground and minmized, it seems that hidden |
| 5971 | // windows -- such as the script's own main window when activated for the purpose of showing |
| 5972 | // a popup menu -- can be foreground while simulateously being minimized. This fixes an |
| 5973 | // issue where the mouse will move to the upper-left corner of the screen rather than the |
| 5974 | // intended coordinates (v1.0.17): |
| 5975 | if (fore && !IsIconic(fore) && GetWindowRect(fore, &rect)) |
| 5976 | { |
| 5977 | aX += rect.left; |
| 5978 | aY += rect.top; |
| 5979 | } |
| 5980 | } |
| 5981 | |
| 5982 | // AutoIt3: Get size of desktop |
| 5983 | if (!GetWindowRect(GetDesktopWindow(), &rect)) // Might fail if there is no desktop (e.g. user not logged in). |
| 5984 | rect.bottom = rect.left = rect.right = rect.top = 0; // Arbitrary defaults. |
| 5985 | |
| 5986 | // AutoIt3: Convert our coords to MOUSEEVENTF_ABSOLUTE coords |
| 5987 | // v1.0.21: No actual change was made, but the below comments were added: |
| 5988 | // Jack Horsfield reports that MouseMove works properly on his multi-monitor system which has |
| 5989 | // its secondary display to the right of the primary. He said that MouseClick is able to click on |
| 5990 | // windows that exist entirely on the secondary display. That's a bit baffling because the below |
| 5991 | // formula should yield a value greater than 65535 when the destination coordinates are to |
| 5992 | // the right of the primary display (due to the fact that GetDesktopWindow() called above yields |
| 5993 | // the rect for the primary display only). Chances are, mouse_event() in Win2k/XP (and possibly |
| 5994 | // Win98, but that is far more doubtful given some of the things mentioned on MSDN) has been |
| 5995 | // enhanced (undocumented) to support values greater than 65535 (and perhaps even negative by |
| 5996 | // taking advantage of DWORD overflow?) |
| 5997 | aX = ((65535 * aX) / (rect.right - 1)) + 1; |
| 5998 | aY = ((65535 * aY) / (rect.bottom - 1)) + 1; |
| 5999 | |
| 6000 | // AutoIt3: Are we slowly moving or insta-moving? |
| 6001 | if (aSpeed == 0) |
| 6002 | { |
nothing calls this directly
no outgoing calls
no test coverage detected