AutoIt介绍

article/2025/9/21 10:20:02

AutoIt的下载网址: https://www.autoitscript.com/site/autoit/downloads/
AutoIt在线文档:http://www.autoit3.cn/Doc/

AutoIt的优势:

  • 简单易懂的类BASIC 表达式
  • 模拟键盘,鼠标动作事件
  • 操作窗口与进程
  • 直接与窗口的”标准控件”交互(设置/获取文字,移动,关闭,等等)
  • 脚本可以编译为标准可执行文件
  • 创建用户图形界面接口(GUI)
  • COM 支持
  • 正则表达式
  • 直接调用外部DLL 和Windows API 函数
  • 程序运行为功能(让程序运行于其它账户)
  • 详细易懂的帮助文件于基于社区的支持论坛
  • 完全兼容于Windows 2000 / XP / 2003 / Vista / 2008
  • Unicode 与64位运算支持
  • 高精度,易使用的数学运算
  • 可以运行于Windows Vista Account Control (UAC)

运行AutoIt程序:

1.先打开SciTE Script Editor, 在Editor中输入以下程序:

Msgbox(0,"Autoit窗口","欢迎来到Autoit的世界")

2.编译:Tools –> Complie, 会生成.exe文件
3.双击.exe文件,就能看到运行结果



Autoit程序例子

例1: 消息框显示

Msgbox(0,"Autoit窗口","欢迎来到Autoit的世界")




例2:带交互的消息框显示

Dim $name
$name=InputBox("您好","请输入姓名:")
Msgbox(0,"欢迎",$name&",欢迎来到Autoit的世界")




例3: 变量的使用

在AU3中变量使用关键字Dim, Local 和Global 来声明并创建变量。一般变量是以美元符号$
开头的。

Dim $a, $b
$a=InputBox("运算","输入a:")
$b=InputBox("运算","输入b:")
Msgbox(0,"结果",$a&'*'&$b&'='&($a*$b))




例4 条件判断语句

Dim $age
$age=inputbox("您好","请输入年龄")
if $age < 18 then
msgbox(0,"结果","未成年人")
else
msgbox(0,"结果","年龄"& $age &",成年人")
endif




例5 循环结构 While…WEnd

Dim $sum, $i, $end
$sum = 0
$end = inputbox("输入","输入结尾数字")
$i = 1
While $i <= $end$sum = $sum + $i$i = $i +1
WEnd
MsgBox(0,"输出","1到"& $end &"的和是:"& $sum)




例6 循环结构 For…Next

Dim $sum, $i, $end
$sum = 0
$end = inputbox("输入","输入结尾数字")
For $i = 1 To $end$sum = $sum + $i
Next
MsgBox(0,"输出","1到"& $end &"的和是:"& $sum)



例7 九九乘法表

@CRLF 换行
@TAB 制表符
ACSII值:Chr(9)=@TAB

Dim $i, $j
Dim $s
For $i=1 To 9For $j=1 To $i$s = $s&$i&"*"&$j&"="&($i*$j)&@TABNext$s = $s & @CRLF
Next
MsgBox(0,"九九乘法表",$s)




例8 数组的使用

Const $N=50
Dim $a[$N], $i, $s=""
For $i=0 To $N-1$a[$i] = $i
Next
For $i=0 To $N-1$s = $s&$a[$i]&"  "
Next
MsgBox(0,"数组的使用", $s)




例9 数组的显示及随机数

#include<Array.au3>
Const $N=11
Dim $i, $RandomArray[$N]
For $i=0 To $N-1$RandomArray[$i] = Random(1,100,1)
Next
_ArrayDisplay($RandomArray,"随机数组")



例10 函数的使用

Func <函数名>([参数1][,参数2]...[,参数n])
     [函数体]
     [Return 数据]
EndFunc

样例代码:

Func Max($x, $y)Local $maxIf $x >= $y Then$max = $xElse$max = $yEndIfReturn $max
EndFuncLocal $a, $b, $c
$a = 10
$b = 20
$c = Max($a, $b)
MsgBox(0,"函数", $a&"和"&$b&"的最大值为:"&$c)



Autoit中的函数参考网址: http://kone-wu.iteye.com/blog/1910019

例11 自动化控制1:新建txt文件, 往记事本里输文字并不保存

#include <Constants.au3>; Script Function:
;   Opens Notepad, types in some text and then quits the application.
;; Prompt the user to run the script - use a Yes/No prompt with the flag parameter set at 4 (see the help file for more details)
Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "AutoIt Example", "This script will run Notepad, type in some text and then quit.  Do you want to run it?"); Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $iAnswer = 7 ThenMsgBox($MB_SYSTEMMODAL, "AutoIt", "OK.  Bye!")Exit
EndIf; Run Notepad
Run("notepad.exe"); Wait for the Notepad to become active. The classname "Notepad" is monitored instead of the window title
WinWaitActive("[CLASS:Notepad]"); Now that the Notepad window is active type some text
Send("Hello from Notepad.{ENTER}1 2 3 4 5 6 7 8 9 10{ENTER}")
Sleep(500)
Send("+{UP 2}")
Sleep(500); Now quit by pressing Alt-F and then scrolling down (simulating the down arrow being pressed six times) to the Exit menu
Send("!f")
Sleep(1000)
Send("{DOWN 6}{ENTER}"); Now a screen will pop up and ask to save the changes, the classname of the window is called
; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
WinWaitActive("[CLASS:#32770]")
Sleep(500)
Send("{TAB}{ENTER}"); Now wait for Notepad to close before continuing
WinWaitClose("[CLASS:Notepad]"); Finished!

Send 函数参考网址:http://blog.csdn.net/u012248603/article/details/52706093

例12 自动化控制2: 自己新建txt文件,然后往记事本里面写入文字并保存

自己新建txt文件放在桌面, 利用AutoIt Window Info工具查到其位置(x,y)



; using AutoIt Window Info to find the location of new created txt file
MouseClick('left', 409, 234, 2); sleep for 2 seconds, then type some words into txt file
sleep(2000)
Send("Hello{Enter}{Space}from{Enter}{Space}Autoit{Enter}{!}{Enter}"); Now quit by pressing Alt-F and then scrolling down (simulating the down arrow being pressed six times) to the Exit menu
Send("!f")
Sleep(1000)
Send("{DOWN 6}{ENTER}"); Now a screen will pop up and ask to save the changes, the classname of the window is called
; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
WinWaitActive("[CLASS:#32770]")
Sleep(500)
Send("{ENTER}"); Now wait for Notepad to close before continuing
WinWaitClose("[CLASS:Notepad]")

编译上述文件,生成first_au3.exe, 并将exe文件E盘中。这样就能通过CMD来运行exe文件了,该命令为: E://first_au3.exe.



本地分享到此结束,欢迎大家交流~


http://chatgpt.dhexx.cn/article/lakduaqb.shtml

相关文章

AutoIt的应用

少数情况下需要操作系统级的弹窗&#xff0c;可以使用AutoIt。 AutoIt现在最新版是V3版本&#xff0c;这是一个类似BASIC脚本语言的免费软件&#xff0c;用于Windows GUI中进行自动化操作。利用模拟键盘按键&#xff0c;鼠标移动&#xff0c;窗口和控件的组合来实现自动化任务…

java 调用autoit_java和autoit连接

autoit可以实现本机文件的上传&#xff0c;修改&#xff0c;新建&#xff0c;也可以实现网页上文件下载到本地 连接步骤&#xff1a; (1)下载autoitx4java 包&#xff0c;地址在code.google.com/p/autoitx4java。解压后直接将jar包添加到工程里面。然后需要使用jacob包&#xf…

AutoIt在线使用手册地址

AutoIt 在线文档https://autoitx.com/Doc/

AutoIt3.0

autoIt主要用于窗口自动化&#xff0c;结合python&#xff0c;可解决web自动化&#xff0c;页面调出窗口的问题 autoIt脚本代码例子&#xff1a; 1.打开Windows 任务管理器 2.依次点击【应用程序、进程、服务、性能、联网、用户】按钮 3.再次点击应用程序按钮 4.点选第二个…

Python + Selenium + AutoIt 模拟键盘实现另存为、上传、下载操作详解

前言 在web页面中&#xff0c;可以使用selenium的定位方式来识别元素&#xff0c;从而来实现页面中的自动化&#xff0c;但对于页面中弹出的文件选择框&#xff0c;selenium就实现不了了&#xff0c;所以就需引用AutoIt工具来实现。 AutoIt介绍 AutoIt简单介绍下&#xff0c…

autoit 下载图片验证码

autoit 下载图片验证码 自动化测试中&#xff0c;我做了验证码识别的功能&#xff0c;那么接下来就是怎么获取验证码图片了&#xff0c;还好autoit 里面提供了一些方法。下面就介绍一下怎样利用autoit 下载验证码图片&#xff1a; 先说思路&#xff1a; 右键点击验证码 使用…

获取硬盘序列号的真正方法!!

最近要获取磁盘的序列号&#xff0c;在网上找了很久发现大部分都是通过diskpart来查询 这种查询方法只是查询的磁盘的id 真正查询磁盘序列号应该使用下面方法&#xff1a;wmic diskdrive get serialnumber 打开cmd后输入 serialNumber下面的就是硬盘序列号

如何查询硬盘序列号?百度基本都是错的,其实一条命令搞定!

百度上答案不知是不懂还是怎么着&#xff0c;都是通过diskpart -->detail disk查询&#xff0c;查出来的是磁盘ID&#xff0c;不是序列号&#xff01; 其实查询磁盘序列号方式很简单&#xff1a; 1.Win R打开 “运行” &#xff0c;在 运行 中输入“cmd”&#xff0c;然后…

手动查询硬盘序列号

win7旗舰版1. 开始-运行-输入&#xff1a;wbemtest 回车 2. 单击"连接", 输入&#xff1a;root\cimv2 回车; 或者ROOT\SecurityCenter 3. 单击"查询", 输入&#xff1a;select * from Win32_PhysicalMedia 应用&#xff0c;出来三个&#xff0c;我这第一…

怎么查询电脑的磁盘序列号和各种硬件信息(Windows系统)

之前实习时遇到过这种情况&#xff0c;听说国家保密局要统计高校领导办公电脑的磁盘信息&#xff0c;防止信息泄露&#xff0c;就让我和同事就统计磁盘的序列号&#xff0c;很简单&#xff0c;就是电脑太多&#xff0c;统计速度太慢啦&#xff0c;都是Windows系统&#xff0c;没…

查看硬盘序列号的方法 和查看设备序列号的方法

查看硬盘序列号 wmic diskdrive get serialnumber 显示的就是序列号了 查看设备序列号 wmic bios get serialnumber

怎么看计算机的硬盘牌子,硬盘序列号,详细教您怎么查看硬盘序列号

有的时候在一些非常时期&#xff0c;我们会需要知道硬盘的序列号&#xff0c;那么这个时候我们要怎么查看电脑的硬盘序列号呢&#xff1f;不慌&#xff0c;稳住。小编现在就带你们打破地方水晶&#xff01;&#xff01;接下来我就来告诉你们怎么查看电脑硬盘序列号。 小伙伴们&…

Windows查询计算机设备序列号、MAC地址和硬盘序列号

1 进入命令提示符 搜索cmd&#xff0c;以管理员身份打开命令提示符 2 查询设备序列号 输入命令 wmic bios get serialnumber返回的字符串即为设备序列号&#xff08;SerialNumber&#xff09; 3 查询MAC地址 输入命令 ipconfig /all 返回物理地址即为所需MAC地址 需要…

如何查看计算机的硬盘序列号,电脑硬盘序列号怎么查?一招查看硬盘序列号的简单方法...

好多网友想知道自己电脑硬盘序列号是多少&#xff1f;这该怎么查看&#xff1f;硬盘的序列号是一个唯一的识别号,我们安装一些大型的开发软件时都会用到。其实查看硬盘序列号的方法很简单&#xff0c;今天小编教大家一招查看电脑硬盘序列号的简单方法。 具体方法如下&#xff1…

硬盘序列号、设备序列等查询

1.硬盘序列号查询。 1&#xff09;Windowsr,输入cmd 回车 2&#xff09;输入diskpart&#xff0c;回车 3&#xff09;输入list disk&#xff0c;回车 4&#xff09;输入select disk *(可选)&#xff0c;回车 5&#xff09;输入detail disk&#xff0c;回车结束。 2.ip(mac)地…

windows10如何查看硬盘序列号

使用命令提示符 点击任务栏搜索框或搜索图标&#xff0c;搜索命令提示符并以管理员身份将其打开。 运行命令&#xff1a;wmic diskdrive get model,name,serialnumber &#xff0c;按Enter键。您将看到列出的连接到计算机的所有硬盘驱动器的型号&#xff0c;名称和序列号。

磁盘序列号,磁盘ID,卷序列号的区别

1. 磁盘序列号 这个东西可以硬盘标签上看到&#xff0c;可查找SN字样&#xff0c;为厂家确定&#xff0c;类似mac地址&#xff0c;属于唯一属性&#xff0c;与OS无关&#xff0c;即使格式化硬盘也不会改变。 windows查看命令&#xff1a;wmic diskdrive get serialnumber 2…

windows查看硬盘序列号

目录 1、打开cmd命令提示&#xff0c;输入diskpart2、输入list disk&#xff0c;查看硬盘基本信息3、输入select disk 0、查看磁盘0信息4、输入detail disk&#xff0c;查看磁盘序列号 按下windowsr&#xff0c;输入cmd打开命令提示 1、打开cmd命令提示&#xff0c;输入diskpa…

cmd命令 查询硬盘序列号,设备序列号,MAC地址,操作系统及安装时间,以及与AIDA64软件的对比

cmd命令 查询硬盘序列号&#xff0c;设备序列号&#xff0c;MAC地址&#xff0c;操作系统及安装时间&#xff0c;以及与AIDA64软件查询结果的对比 统计单位计算机基础信息或计算机资产信息&#xff0c;往往需要统计“操作系统&#xff0c;安装时间&#xff0c;硬盘序列号&…

命令行查看硬盘序列号

1.按WinR打开运行&#xff0c;输入cmd,回车&#xff1a; 2.在命令提示符中输入diskpart,点击回车来启动diskpart程序&#xff0c;通过这个程序来查看硬盘序列号&#xff1a; 3.接着输入并执行list disk, 也就是把电脑上的所有硬盘都罗列出来&#xff0c;图中只有一个硬盘&#…