AutoIt Automation - 如何模拟人类的光标移动

AutoIt Automation - How To Simulate Human Like Cursor Movement

我写了一个问题 关于如何使用 Selenium Web Driver 和 Java.

模拟类似人类的光标移动

在这个任务中,我发现 Selenium Web Driver 可能不是最合适的。它不能直接移动光标。或者能够以我需要的方式。

我不需要实际移动鼠标。只要网站认为光标移动正常即可。

我了解了 AutoIt 自动化并构建了一些脚本。我构建了一个脚本来自动执行上传照片时所需的击键。 我想到了将需要上传的文件路径写入 .txt 文件。这是在我的 Java 应用程序中完成的。然后当我从 Java 调用我的 AutoIt .exe 文件时。然后它读取 .txt 文件。获取文件路径 URL。然后执行粘贴文件路径所需的操作。然后点击“打开”按钮将文件上传到网站。

在此基础上,我可以将坐标保存在我希望鼠标移动的位置。 在 .txt 文件中。然后当我触发 .exe AutoIt 文件时。它读取此 .txt 文件并执行“类人”鼠标行为。

我只需要知道如何在 AutoIt 中模拟真实的 mouse/cursor 运动? 我可以给它一些坐标的函数。

I saw an article on doing in this CSS and JS... This should give you a good idea.

有人可以帮忙吗?或提供任何建议?谢谢。

感谢对我的问题的评论。那链接到一个脚本。效果惊人!

它产生的非线性鼠标移动比我想象的要好:)

; Smoother Mouse Move
; by the DtTvB

; Ease in function
func __calci1($i, $sm)
    return $i ^ $sm;
endFunc

; Ease out function
func __calci2($i, $sm)
    return 1 - ((1 - $i) ^ $sm);
endFunc

; Ease in out function
func __calci($i, $sm)
    if ($i < 0.5) then
        return __calci1($i * 2, $sm) / 2;
    else
        return (__calci2(($i - 0.5) * 2, $sm) / 2) + 0.5;
    endIf
endFunc

; Ease backward function
func __calof($i, $sm)
    if ($i < 0.5) then
        return __calci($i * 2, $sm);
    else
        return __calci((1 - $i) * 2, $sm);
    endIf
endfunc

; MAIN FUNCTION
func mouseMove2($x2, $y2)
    $x1 = mouseGetPos(0);
    $y1 = mouseGetPos(1);
    $xv = random(-100, 100);
    $yv = random(-100, 100);
    $sm = random(1.5, 2.5);
    $m = random(50, 160);
    for $i = 0 to $m
        $ci = __calci($i / $m, $sm);
        $co = __calof($i / $m, $sm);
        $cx = $x1 + (($x2 - $x1) * $ci) + ($xv * $co);
        $cy = $y1 + (($y2 - $y1) * $ci) + ($yv * $co);
        mouseMove ($cx, $cy, 1);
    next
endFunc

; Test Script
mouseMove2 (512, 386);