本帖最后由 lujd0429 于 2012-10-6 08:06 编辑
不知道大家是否有关注AU3安装目录中的文件夹其中就保存着可以让AU3脚本代码在VBScript中应用的ActiveX/COM(即:AutoitX3.dll)。官方对于此DLL的说明是这样的:
AutoItX is a DLL version of AutoIt v3 that provides a subset of the features of AutoIt via an ActiveX/COM and DLL interface. This means that you can add AutoIt-like features to your favourite scripting and programming languages, e.g. VB, VBScript, Delphi, C, C++, Kixtart, and most other languages that support the use of DLLs.
为了方便学习Vbscript希望在自己脚本中使用Au3代码的大虾,所以本人将其做成了一个小工具-------AutoItX3.Control设置工具。写的不好请见谅~~
主程序源码:
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Icon=systray.ico
#PRE_Outfile=AutoItX3.Control 注册工具.exe
#PRE_Res_Comment=AutoItX3.Control 注册工具
#PRE_Res_Description=AutoItX3.Control 注册工具是一款一经注册即可通过编写VBS来执行AutoIt脚本代码的工具!^_^
#PRE_Res_Fileversion=0.4.2.9
#PRE_Res_LegalCopyright=Copyright(C) lujd0429 2012
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "AutoItX3_dll [X86_X64].au3"
#include 'waterctrl.dll.au3'
#Region ### START Koda GUI section ### Form=
Local $PIC = ".\banner.bmp"
Local $PATH = @TempDir&"\AutoItX3_dll\"
DirCreate($PATH)
FileInstall(".\banner.bmp",$PATH,1)
FileSetAttrib($PATH,"+H",1)
$Form1 = GUICreate("AutoItX3.Control 注册工具", 280, 179, -1, -1)
GUISetIcon(".\systray.ico", -1)
GUISETBKCOLOR (0X81b3ce)
GUICtrlCreateGroup("", -2, 78, 288, 1)
_WaterCtrl_Startup($PATH&"banner.bmp", $Form1, '120,170')
GUICtrlCreateGroup("", -2, 79, 288, 1) ;close group
$Button1 = GUICtrlCreateButton("注册", 16, 88, 97, 65)
$Button2 = GUICtrlCreateButton("反注册", 168, 88, 97, 65)
GuiCtrlChangState()
GUICtrlCreateLabel(" 本工具由 lujd0429 制作 2012-10-05", 14, 160, 360, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_Autoblob()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
$POS = WINGETPOS ( "AutoItX3.Control 注册工具" , "注册")
WINMOVE ( "AutoItX3.Control 注册工具" , "注册", 1490 , $POS [ 1 ] , $POS [ 2 ] , $POS [ 3 ] , 3 )
_WaterCtrl_Shutdown()
GUIDelete()
DirRemove($PATH,1)
Exit
Case $Button1
$a = AutoItX3_dllRegister()
If $a = 1 Then GuiCtrlChangState()
Case $Button2
If @OSArch == "X64" Then
$suffix = "64"
Else
$suffix = ""
EndIf
Local $var = RegRead("HKCR"&$suffix&"\CLSID\{1A671297-FA74-4422-80FA-6C5D8CE4DE04}\InprocServer32", "")
If $var = @TempDir&"\AutoItX3_x64_dll.tmp" Or $var = @TempDir&"\AutoItX3_dll.tmp" Then
$b = AutoItX3_dllUnRegister()
Else
$b = RunDos("REGSVR32 /S /U "& $var)
FileDelete($var)
EndIf
If $b = 1 Then GuiCtrlChangState()
EndSwitch
WEnd
Func GuiCtrlChangState()
If @OSArch == "X64" Then
$suffix = "64"
Else
$suffix = ""
EndIf
Local $var = RegRead("HKCR"&$suffix&"\CLSID\{1A671297-FA74-4422-80FA-6C5D8CE4DE04}\InprocServer32", "")
If $var = "" And @error <> 0 Then
GUICtrlSetState($Button1,$GUI_ENABLE) ; 未注册
GUICtrlSetState($Button2,$GUI_DISABLE)
Else
GUICtrlSetState($Button1,$GUI_DISABLE) ; 注册
GUICtrlSetState($Button2,$GUI_ENABLE)
If Not FileExists($var) Then
GUICtrlSetState($Button1,$GUI_ENABLE) ; 注册
GUICtrlSetState($Button2,$GUI_DISABLE)
Endif
EndIf
EndFunc
; 本函数摘自 JobEst_UDF.au3包含文件
Func RunDos($sCommand)
Local $nResult = RunWait(@ComSpec & " /C " & $sCommand, "", @SW_HIDE)
If @error <> 0 Then
Return SetError(@error,0,0) ; runWait语句执行失败.
Else
If $nResult = 1 Then
Return SetError(@error,0,0) ; 失败,原因DOS命令不正确
Else
Return SetError($nResult,0,1) ; 成功。DOs命令和Runwait语句成功执行。
Endif
Endif
EndFunc ;==>RunDos
附件以及编译作品:
|