AutoIt Automation-如何模拟像人一样的光标移动 [英] AutoIt Automation - How To Simulate Human Like Cursor Movement

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

问题描述

我在此处提出了有关如何模拟的问题使用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 Automation-如何模拟像人一样的光标移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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