AutoIT3介绍AutoIT语言用于Windows GUI(图形用户界面)的自动化操作,它利用模拟键盘按键,鼠标移动和窗口/控件的组合来实现自动化任务,语言风格类似BASIC脚本语言,是实现Windows钩子的语言,下面我们就来聊聊关于pc安装开源模拟器系统?接下来我们就一起去了解一下吧!
pc安装开源模拟器系统
AutoIT3AutoIT3介绍
AutoIT语言用于Windows GUI(图形用户界面)的自动化操作,它利用模拟键盘按键,鼠标移动和窗口/控件的组合来实现自动化任务,语言风格类似BASIC脚本语言,是实现Windows钩子的语言。
AutoIt3官网:https://www.autoitscript.com/site/autoit/
AutoIt3下载地址:https://www.autoitscript.com/site/autoit/downloads/
Windows钩子原理
Windows下的应用程序大部分都是基于消息机制的,它们都会有一个消息过程函数,根据不同的消息完成不同的功能。Windows操作系统提供的钩子机制的作用就是用来截获和监视这些系统中的消息。
按照钩子作用的范围不同,又可以分为局部钩子和全局钩子。局部钩子是针对某个线程的;而全局钩子则是作用于整个系统中基于消息的应用。全局钩子需要使用DLL文件,在DLL中实现相应的钩子函数。在操作系统中安装全局钩子后,只要进程接收到可以发出钩子的消息,全局钩子的DLL文件就会被操作系统自动或强行地加载到该进程中。因此,设置消息钩子,也可以达到DLL注入的目的。
代码案例案例1,自动化mstsc远程连接:
;;锁定屏幕
BlockInput(1)
$val1 = ShellExecuteWait("mstsc.exe")
Sleep(1*1000)
$val2 = WinActivate("[CLASS:#32770]")
Sleep(1*1000)
Send("192.168.1.2")
Sleep(1*1000)
Send("{ENTER}")
;;解锁屏幕
BlockInput(0)
案例2,操作某软件:
#include <MsgBoxConstants.au3>
;; 检查指定的窗口是否存在
Local $hExists = WinExists("[CLASS:MetaQuotes::MetaTrader::4.00]");
If $hExists < 0 Then
Return
EndIf
;;锁定屏幕
BlockInput(1);
;; 暂停脚本的执行,直到请求的窗口存在
Local $hWnd = WinWait("[CLASS:MetaQuotes::MetaTrader::4.00]", "", 1000)
;; 激活窗口
WinActivate($hWnd);
;;
Sleep(800)
;; 获取坐标
Local $aPos = WinGetPos($hWnd);
;; 移动或调整窗口大小
WinMove($hWnd, "", 0, 0, 1600, 1200, 800)
Send("!{T}")
;; Sleep(2000)
;;解锁屏幕
BlockInput(0);
MsgBox(0, "提示", "Over!");
案例3:
MsgBox(0, "", "当前工作目录:" & @WorkingDir);
MsgBox(0, "", "当前工作目录:" & @ScriptDir);
MsgBox(0, "日期:", @YEAR & "-" & @MON & "-" & @MDAY);
MsgBox(0, "时间:", @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC);
;; 获取内存相关信息
$mem = MemGetStats();
MsgBox(64, "", "内存使用率:" & $mem[0]& "%");
MsgBox(64, "", "物理内存总数 (MB):" & $mem[1]/1024 );
MsgBox(64, "", "可用物理内存 (MB):" & $mem[2]/1024);
MsgBox(64, "", "页面文件大小 (MB):" & $mem[3]/1024);
MsgBox(64, "", "可用页面文件大小 (MB):" & $mem[4]/1024);
MsgBox(64, "", "虚拟内存大小 (MB):" & $mem[5]/1024);
MsgBox(64, "", "可用虚拟内存大小 (MB):" & $mem[6]/1024);
案例4,字符串和数组应用:
#include <Array.au3>
;字符串的大小写转换
$str01 = "abdcefg";
$result01 = StringUpper($str01);
$result02 = StringLower($result01);
MsgBox(64,"大小写转换结果","大写:" & $result01 & Chr(13) & "小写:" & $result02);
;字符串的长度
$str02 = "acer01acer02acer03acer04acer05";
$len = StringLen($str02);
MsgBox(64,"长度","字符串的长度为:" & $len );
;返回指定数量的字符串
$str03 = StringLeft($str02,12);
$str04 = StringRight($str02,12);
MsgBox(64,"返回指定字符数","左边的12个字符:" & $str03 & Chr(13) & "右边的12个字符:" & $str04);
;字符串替换
$str05 = "a-b-c-d-e-f-g";
$str06 = StringReplace($str05,"-","=");
$replaceNum = @extended;
MsgBox(64,"字符替换","原串:" & $str05 & Chr(13) & "替换后的串:" & $str06 & Chr(13) & "替换个数:" & $replaceNum);
;字符串分割
$str07 = "123,456,789,0,a,d,gg";
$array01 = StringSplit($str07,",",1);
MsgBox(64,"分割字符串", "分割后的数量:" & $array01[0] & Chr(13) & "第3个串:" & $array01[3]);
MsgBox(64,"数组长度", "长度:" & $array01[0]);
;将字符串转换为数组
$array02 = StringToASCIIArray($str01);;默认为UNICODE
$array03 = StringToASCIIArray($str01,"GBK");
$array04 = StringToASCIIArray($str01,2,4,"GBK");;从第2个开始第5个结束
_ArrayDisplay($array02,"");
_ArrayDisplay($array03,"");
MsgBox(64,"数组长度", "长度:" & $array02[0]);
案例5,字符串转数组:
; Binary ANSI to String
$buffer = StringToBinary("Hello - 你好")
MsgBox(4096, "String() representation" , $buffer)
$buffer = BinaryToString($buffer)
MsgBox(4096, "BinaryToString() ANSI representation" , $buffer)
; Binary UTF16-LE to String
$buffer = StringToBinary("Hello - 你好", 2)
MsgBox(4096, "String() representation" , $buffer)
$buffer = BinaryToString($buffer, 2)
MsgBox(4096, "BinaryToString() UTF16-LE representation" , $buffer)
; Binary UTF16-BE to String
$buffer = StringToBinary("Hello - 你好", 3)
MsgBox(4096, "String() representation" , $buffer)
$buffer = BinaryToString($buffer, 3)
MsgBox(4096, "BinaryToString() UTF16-BE representation" , $buffer)
; Binary UTF8 to String
$buffer = StringToBinary("Hello - 你好", 4)
MsgBox(4096, "String() representation" , $buffer)
$buffer = BinaryToString($buffer, 4)
MsgBox(4096, "BinaryToString() UTF8 representation" , $buffer)