| 1871 | |
| 1872 | |
| 1873 | void DoIncrementalMouseMove(int aX1, int aY1, int aX2, int aY2, int aSpeed) |
| 1874 | // aX1 and aY1 are the starting coordinates, and "2" are the destination coordinates. |
| 1875 | // Caller has ensured that aSpeed is in the range 0 to 100, inclusive. |
| 1876 | { |
| 1877 | // AutoIt3: So, it's a more gradual speed that is needed :) |
| 1878 | int delta; |
| 1879 | #define INCR_MOUSE_MIN_SPEED 32 |
| 1880 | |
| 1881 | while (aX1 != aX2 || aY1 != aY2) |
| 1882 | { |
| 1883 | if (aX1 < aX2) |
| 1884 | { |
| 1885 | delta = (aX2 - aX1) / aSpeed; |
| 1886 | if (delta == 0 || delta < INCR_MOUSE_MIN_SPEED) |
| 1887 | delta = INCR_MOUSE_MIN_SPEED; |
| 1888 | if ((aX1 + delta) > aX2) |
| 1889 | aX1 = aX2; |
| 1890 | else |
| 1891 | aX1 += delta; |
| 1892 | } |
| 1893 | else |
| 1894 | if (aX1 > aX2) |
| 1895 | { |
| 1896 | delta = (aX1 - aX2) / aSpeed; |
| 1897 | if (delta == 0 || delta < INCR_MOUSE_MIN_SPEED) |
| 1898 | delta = INCR_MOUSE_MIN_SPEED; |
| 1899 | if ((aX1 - delta) < aX2) |
| 1900 | aX1 = aX2; |
| 1901 | else |
| 1902 | aX1 -= delta; |
| 1903 | } |
| 1904 | |
| 1905 | if (aY1 < aY2) |
| 1906 | { |
| 1907 | delta = (aY2 - aY1) / aSpeed; |
| 1908 | if (delta == 0 || delta < INCR_MOUSE_MIN_SPEED) |
| 1909 | delta = INCR_MOUSE_MIN_SPEED; |
| 1910 | if ((aY1 + delta) > aY2) |
| 1911 | aY1 = aY2; |
| 1912 | else |
| 1913 | aY1 += delta; |
| 1914 | } |
| 1915 | else |
| 1916 | if (aY1 > aY2) |
| 1917 | { |
| 1918 | delta = (aY1 - aY2) / aSpeed; |
| 1919 | if (delta == 0 || delta < INCR_MOUSE_MIN_SPEED) |
| 1920 | delta = INCR_MOUSE_MIN_SPEED; |
| 1921 | if ((aY1 - delta) < aY2) |
| 1922 | aY1 = aY2; |
| 1923 | else |
| 1924 | aY1 -= delta; |
| 1925 | } |
| 1926 | |
| 1927 | MouseEvent(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, 0, aX1, aY1); |
| 1928 | DoMouseDelay(); |
| 1929 | // Above: A delay is required for backward compatibility and because it's just how the incremental-move |
| 1930 | // feature was originally designed in AutoIt v3. It may in fact improve reliability in some cases, |
no test coverage detected