rictirse 發表於 2012-11-5 23:12

DU Meter 6.01 一鍵安裝 Code

本帖最後由 rictirse 於 2014-12-24 08:34 編輯


#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.8.1
Author:      Dang Wang

Script Function: DisplayFusion 4.2
      Template AutoIt script.

#ce ----------------------------------------------------------------------------
#Region
#AutoIt3Wrapper_icon=C:\NewDang.ico
#AutoIt3Wrapper_Compression=5
#AutoIt3Wrapper_Res_Comment=DisplayFusion 4.2
#AutoIt3Wrapper_Res_Description=DisplayFusion 4.2
#AutoIt3Wrapper_Res_Fileversion=4.2.0.0
#AutoIt3Wrapper_Res_LegalCopyright=噹噹
#EndRegion
#NoTrayIcon
#RequireAdmin
AutoItSetOption ( "WinTitleMatchMode", 4)

_OneOpen()

Dim Const $FileName="DUMeter-Install.exe"
Dim Const $FormName = "Setup - DU Meter"
;------- (基於版權不公開 序號)-------
Dim Const $IID = '';; 認證碼
Dim Const $UserName = '';;; 授權者
Dim Const $SerialNum = '' ;; 序號


;------- (1 Click;2 Check;3 UnCheck;4 SetText )-------
Dim $Text = [ [ "Select Setup Language", "Select the language to use during the installation:", "TNewButton1", 1, ""], _
                                                      [ $FormName, "Welcome to the DU Meter", "TNewButton1", 1, ""], _
                                                      [ $FormName, "Please read the following important information before continuing.", "TNewRadioButton1", 2, ""], _
                                                      [ $FormName, "Please read the following important information before continuing.", "TNewButton2", 1, ""], _
                                                      [ $FormName, "Where should DU Meter be installed?", "TNewButton3", 1, ""], _
                                                      [ $FormName, "Click Finish to exit Setup.", "TNewCheckListBox1", 3, ""], _
                                                      [ $FormName, "Click Finish to exit Setup.", "TNewButton3", 1, ""] ]

$begin = TimerInit()
FileInstall( "DUMeter-Install.exe", @TempDir&"\"&$FileName)

FileInstall( "DUMeter.exe", @TempDir&"\DUMeter.exe")
FileInstall( "DUMeterSvc.exe", @TempDir&"\DUMeterSvc.exe")

ShellExecute (@TempDir&"\"&$FileName)

While 1
      For $i = 0 To UBound ( $Text, 1)-1
                Select
                        Case WinExists ( $Text[$i], $Text[$i])
                              If $Text[$i] = 1 Then
                                        ControlClick ( $Text[$i], $Text[$i], $Text[$i])
                              ElseIf $Text[$i] = 2 Then
                                        ControlCommand ( $Text[$i], $Text[$i], $Text[$i], "Check", "")
                              ElseIf $Text[$i] = 3 Then
                                        ControlCommand ( $Text[$i], $Text[$i], $Text[$i], "UnCheck", "")
                              ElseIf $Text[$i] = 4 Then
                                        ControlSetText ( $Text[$i], $Text[$i], $Text[$i], $Text[$i])
                              EndIf
                              If $i = (UBound ( $Text, 1)-1) Then ExitLoop(2)
                EndSelect
      Next
WEnd

ProcessWait ("DUMeter.exe")
Do
      ProcessClose ("DUMeter.exe")
      ProcessClose ("DUMeterSvc.exe")
Until Not ProcessExists ("DUMeter.exe") And Not ProcessExists ("DUMeterSvc.exe")

FileMove ( @TempDir&"\DUMeter.exe", @ProgramFilesDir&"\DU Meter\DUMeter.exe", 9)
FileMove ( @TempDir&"\DUMeterSvc.exe", @ProgramFilesDir&"\DU Meter\DUMeterSvc.exe", 9)

_Crack()
$dif = TimerDiff($begin)
ShellExecute (@ProgramFilesDir&"\DU Meter\DUMeter.exe")

MsgBox ( 0, "安裝完成", StringFormat ( "總安裝時間:%s秒", $dif/1000))

Func _Crack()
      RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Hagel\DU Meter\Registration', 'IID', 'REG_SZ', $IID)
      RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Hagel\DU Meter\Registration', 'UserName', 'REG_SZ', $UserName)
      RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Hagel\DU Meter\Registration', 'SerialNum', 'REG_SZ', $SerialNum)
EndFunc

Func _OneOpen()
      Local $ProcessName = _FileNameConver (@AutoItExe)
      Local $list = ProcessList()
      Local $Cnt = 0
      For $i = 1 To $list
                If $list[$i] = $ProcessName Then
                        $Cnt += 1
                        If $Cnt > 1 Then
                              Exit
                        EndIf
                EndIf
      Next
EndFunc

Func _FileNameConver ($FileName, $Flag = 0)
      $strtmp = StringSplit ($FileName, "\");; 返回檔名
      If $Flag <> 1 Then
                $strtmp = StringSplit ( $strtmp[$strtmp], ".");; 返回副檔名
      EndIf
      Return $strtmp[$strtmp]
EndFunc
頁: [1]
查看完整版本: DU Meter 6.01 一鍵安裝 Code