将demo.au3和test.au3放在同目录下,运行demo.au3或编译之
demo.au3:#cs ____________________________________
欢迎使用 AutoIt v3 中文版 !
AutoIt v3 中文主页: http://au3.net/
AutoIt v3 中文学院: http://au3.cc/
Au3版本: 3.3.10.2
脚本作者:
脚本功能:
更新日志:
联系方式:
#ce _______________脚本开始_________________
_Main()
Exit
Func _Main()
Local $AutoIt3Exe = _GetAutoIt3Exe()
Switch @error
Case 1
MsgBox(0 + 16, '错误', 'Au3安装目录未发现!')
Exit
Case 2
MsgBox(0 + 16, '错误', 'AutoIt3.exe未发现')
Exit
EndSwitch
Local $Au3Script = @ScriptDir & '\test.au3' ; <--改成你的要调用的AU3脚本
If Not (FileExists($Au3Script)) Then
MsgBox(0 + 16, '错误', '目标au3脚本未发现')
Exit
EndIf
_RunAu3Script($AutoIt3Exe, $Au3Script)
Return
EndFunc ;==>_Main
Func _GetAutoIt3Exe()
Local $InstallDir = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir')
If $InstallDir = '' Then RegRead('HKLM64\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir')
If $InstallDir = '' Then
Return SetError(1, 0, 0)
EndIf
Local $AutoIt3Exe = ''
Switch @OSArch
Case 'x86'
$AutoIt3Exe = $InstallDir & '\AutoIt3.exe'
Case 'x64'
$AutoIt3Exe = $InstallDir & '\AutoIt3_x64.exe'
EndSwitch
If Not (FileExists($AutoIt3Exe)) Then
Return SetError(2, 0, 0)
EndIf
Return SetError(0, 0, $AutoIt3Exe)
EndFunc ;==>_GetAutoIt3Exe
Func _RunAu3Script($AutoIt3Exe, $Au3Script, $Wait = 0)
Local $Cmd = '"' & $AutoIt3Exe & '"' & ' /AutoIt3ExecuteScript ' & '"' & $Au3Script & '"'
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Cmd = ' & $Cmd & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
If $Wait Then
RunWait($Cmd)
Else
Run($Cmd)
EndIf
Return
EndFunc ;==>_RunAu3Script
test.au3:MsgBox(0,'','Hello World')
|