找回密码
 加入
搜索
查看: 9825|回复: 12

[原创] AutoItx3.Control控件注册&反注册工具 (无DLL版)

  [复制链接]
发表于 2012-10-5 23:19:50 | 显示全部楼层 |阅读模式
本帖最后由 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




附件以及编译作品:
  

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 1金钱 +10 收起 理由
lpxx + 10

查看全部评分

发表于 2012-10-6 00:43:22 | 显示全部楼层
同样支持一下
发表于 2012-10-6 07:32:31 | 显示全部楼层
学习一下了
发表于 2012-10-6 12:05:12 | 显示全部楼层
同样支持一下
发表于 2012-10-6 12:05:19 | 显示全部楼层
同样支持一下
发表于 2012-10-6 12:05:35 | 显示全部楼层
同样支持一下
发表于 2012-10-7 16:53:17 | 显示全部楼层
很不错的例子 支持了
发表于 2012-10-11 15:06:51 | 显示全部楼层
本来有注册和卸载的批处理啊!
 楼主| 发表于 2012-10-11 18:03:54 | 显示全部楼层
本帖最后由 lujd0429 于 2012-10-11 18:05 编辑

回复 8# 卫和谐


这不是本来要用到好几个DLL文件吗,现在不用FileInstall也不用DLL了吗!
发表于 2012-10-15 01:03:13 | 显示全部楼层
谢谢楼主。
发表于 2012-12-16 21:48:06 | 显示全部楼层
看看再说,还带水文不错。。
发表于 2015-10-9 11:16:09 | 显示全部楼层
有需要,非常感谢。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-17 20:26 , Processed in 0.088683 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表