AutoIt 自动化 - 如何模拟人类的光标移动 [英] AutoIt Automation - How To Simulate Human Like Cursor Movement

查看:36
本文介绍了AutoIt 自动化 - 如何模拟人类的光标移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里写了一个关于如何模拟的问题使用 Selenium Web Driver 和 Java 实现类人光标移动.

I wrote a question here on how to simulate human-like cursor movement with Selenium Web Driver and Java.

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

On this quest, I discovered that Selenium Web Driver might not be the best fit. It can't move the cursor directly. Or be able to in the fashion I need.

我不需要物理移动鼠标.只要网站认为光标移动正常即可.

I don't need to physically move the mouse. Just as long as the website thinks the cursor is moving normally.

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

I have learned about AutoIt automation and have built some scripts. I built a script to automate the Key Strokes I require when uploading a photo. I had the idea to write the file path I need to upload to a .txt file. This is done in my Java App. Then when I call my AutoIt .exe file from Java. It then reads the .txt file. Gets the file path URL. It then does the operations necessary to paste the file path. Then click the "Open" button to upload the file to the website.

继此之后,我可以将坐标保存在我希望鼠标移动的位置.在 .txt 文件中.然后当我触发 .exe AutoIt 文件时.它读取这个 .txt 文件并执行类似人类"的操作.鼠标行为.

Following on from this, I could save coordinates on where I want the mouse to go. In a .txt file. Then when I fire the .exe AutoIt file. It reads this .txt file and does the "human-like" mouse behavior.

我只需要知道如何在 AutoIt 中模拟真实的鼠标/光标移动?我可以提供一些坐标的函数.

I just need to know how to simulate real mouse/cursor movement in AutoIt? A function I can give some coordinates to.

我看到了一篇关于在这个 CSS 和 JS 中做的文章......这应该给你一个好主意.

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

Can anybody help? or offer any advice? Thank you.

推荐答案

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

Thanks to a comment made on my question. That linked to a script. It works amazingly!

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

It produces nonlinear mouse movements better than I ever imagined :)

; 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);

这篇关于AutoIt 自动化 - 如何模拟人类的光标移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆