請選擇 進入手機版 | 繼續訪問電腦版

微剋多資訊

 找回密碼
 註冊

Login

搜索

該用戶從未簽到

發表於 2012-11-4 13:56 | 顯示全部樓層 |閱讀模式
本帖最後由 rictirse 於 2014-9-14 00:11 編輯

AutoIt GUI 進階班 Aero Install

這個GUI 噹噹已經刻好,只需要使用ini 稍微設定一下就可以做出簡單又漂亮的自動安裝介面


請看DEMO 影片



code需要者自取
需要搭配 圖片包與ini 載點
  1. #include <GUIConstantsEx.au3>
  2. #include <WindowsConstants.au3>
  3. #include <sendmessage.au3>
  4. #include <GuiEdit.au3>
  5. #Include <Date.au3>
  6. #include <GDIPlus.au3>
  7. #Region
  8. #AutoIt3Wrapper_icon=C:\NewDang.ico;; 設定 icon 路徑
  9. #AutoIt3Wrapper_Compression=5 ;; 壓縮等級
  10. #AutoIt3Wrapper_Res_Comment=Aero Install
  11. #AutoIt3Wrapper_Res_Description=Aero Install
  12. #AutoIt3Wrapper_Res_Fileversion=2.3.0.0 ;; 版本代號
  13. #AutoIt3Wrapper_Res_LegalCopyright=噹噹 ;; 作者
  14. #EndRegion

  15. Global $ini = @ScriptDir&"\install.ini"

  16. If IniRead ($ini, "install", "IconHide", 0) = 1 Then AutoItSetOption ( "TrayIconHide", 1)
  17. ;-----------(隨機選圖)-----------
  18. Dim $i = 0, $file[100];;; 預設圖片最大數量 100
  19. Dim $ImgRoute = @ScriptDir&IniRead ($ini, "install", "ImgRoute","")

  20. FileDelete (@ScriptDir&"\img\copypic.bmp");; 刪除暫存圖片
  21. $search = FileFindFirstFile($ImgRoute&"\*.BMP")

  22. If $search = -1 Then
  23.   MsgBox(0, "錯誤", "找不到圖片")
  24.   Exit
  25. EndIf

  26. While 1
  27.   $i += 1
  28.   $file[$i] = FileFindNextFile($search)
  29.   If @error Then ExitLoop
  30.   $file[0] = $i
  31. WEnd
  32. FileClose($search)

  33. $numimg = Random ( 1, $file[0], 1)
  34. Global $img = $ImgRoute&$file[$numimg]
  35. ;~ MsgBox ( 0, $numimg, $img);顯示抽到哪張圖
  36. ;-----------(隨機選圖)-----------
  37. Global $FormName = IniRead ($ini, "install", "FormName","")
  38. Global $exeName =  IniRead ($ini, "install", "exeName","")
  39. Global $FileName =  IniRead ($ini, "install", "FileName","")
  40. Global $DirRoute =  IniRead ($ini, "install", "DirRoute","")
  41. Global $LabelDay =  IniRead ($ini, "install", "LabelDay","")
  42. Global $Design = IniRead ($ini, "install", "Design","")

  43. ; 0 = 自動判斷OS 如果是 W7 會隨機選 MOD 1 or 2
  44. ; 1 = 強制W7 MOD_1
  45. ; 2 = 強制W7 MOD_2
  46. ; 3 = 強制XP MOD ;預設=2 非 0或 1 其餘返回值皆為2
  47. Global $MOD = IniRead ($ini, "install", "MOD", 3)


  48. If $MOD = 0 Then
  49.   If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Then
  50.     If Random() < 0.5 Then
  51.       Global $SHOW = 1;W7 MOD_1
  52.     Else
  53.       Global $SHOW = 2;W7 MOD_2
  54.     Endif
  55.   Else
  56.     Global $SHOW = 3;XP MOD
  57.   EndIf
  58. ElseIf $MOD = 1 Then
  59.   Global $SHOW = 1;W7 MOD_1
  60. ElseIf $MOD = 2 Then
  61.   Global $SHOW = 2;W7 MOD_2
  62. Else
  63.   Global $SHOW = 3;XP MOD
  64. EndIf
  65. Error()

  66. If $SHOW = 1 Then ;; WINDOWS 7 MOD_1
  67.   Dim $MyArea[4] = [9999,9999,9999,9999]
  68.   $_alpha=_WinAPI_DwmGetColorizationColor( )
  69.   $CtrlBkColor="0X"&Hex(BitAND($_alpha,0xFFFFFF),6)
  70.   $_alpha="0X"&Hex($_alpha)
  71.   _GDIPlus_Startup()
  72.   $hImage1 = _GDIPlus_ImageLoadFromFile($img)
  73.   Dim $picSize_wide = _GDIPlus_ImageGetWidth($hImage1)
  74.   Dim $picSize_height = _GDIPlus_ImageGetHeight($hImage1)
  75.   Dim $alpha = IniRead ($ini, "install", "alpha", 255)
  76.   If $alpha = "" Then $alpha = 255
  77.   If $alpha > 255 Or $alpha < 0 Then $alpha = 255 ;設定alpha值 alpha = 0 全透明, alpha = 255 不透明, 預設255
  78.   If  $picSize_wide < 758 Or  $picSize_height < 426 Then
  79.     MsgBox ( 16,"ERROR","圖片大小不得小於 758x426")
  80.     Exit
  81.   EndIf
  82.   $hBitmap1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1)
  83.   $hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1)
  84.   $hHBITMAP = _WinAPI_CreateBitmap($picSize_wide, $picSize_height, 1, 32)
  85.   $hCDC = _WinAPI_CreateCompatibleDC(0)
  86.   _WinAPI_SelectObject($hCDC, $hHBITMAP)
  87.   $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hCDC)
  88.   _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $picSize_wide, $picSize_height)
  89.   _WinAPI_DeleteObject($hImage)
  90.   _GDIPlus_GraphicsDispose($hGraphic)
  91.   _WinAPI_DeleteDC($hCDC)

  92.   $form1 = GUICreate($FormName,$picSize_wide, $picSize_height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)

  93.   _WinAPI_UpdateLayeredWindowEx($form1, $hHBITMAP, $alpha, 1)
  94.   _GDIPlus_ImageDispose($hImage1)
  95.   _WinAPI_DeleteObject($hBitmap1)
  96.   _GDIPlus_Shutdown()

  97.   WinSetOnTop ($form1,"",1)
  98.   GUISetState()

  99.   $pos1=WinGetPos($form1,"")
  100.   $GUI = GUICreate ( "", $picSize_wide, $picSize_height, $pos1[0], $pos1[1],$DS_SETFOREGROUND,$WS_EX_TOOLWINDOW)

  101.   _Vista_EnableBlurBehind($GUI, $MyArea)

  102.   $GUI_Y = 58;按鈕及文字高度

  103.   $Button_2 = GUICtrlCreateButton ( "Install", 21, $picSize_height-$GUI_Y, 80);安裝按鈕
  104.     GUICtrlSetBkColor ( $Button_2, 0x00000)
  105.     GUICtrlSetColor ( $Button_2, 0xFFFFFF)
  106.     GUICtrlSetFont ( $Button_2, 10, 800)
  107.   $Button_1 = GUICtrlCreateButton ( "...", ($picSize_wide*0.17875)-33, $picSize_height-$GUI_Y, 25, 24);選擇安裝目錄按鈕
  108.     GUICtrlSetBkColor ( $Button_1, 0x00000)
  109.     GUICtrlSetColor ( $Button_1, 0xFFFFFF)
  110.     GUICtrlSetFont ( $Button_1, 10, 800)
  111.   $Input = GUICtrlCreateInput ( @ProgramFilesDir&$DirRoute, $picSize_wide*0.17875, $picSize_height-$GUI_Y, $picSize_wide*0.4975, 24);安裝路徑文字框
  112.     GUICtrlSetBkColor ( $Input, 0x00000)
  113.     GUICtrlSetColor ( $Input, 0x1260FF)
  114.     GUICtrlSetFont ( $Input, 10, 700)
  115.   $Button_3 = GUICtrlCreateButton ( "Exit", $picSize_wide*0.6875, $picSize_height-$GUI_Y, 80);離開按鈕
  116.     GUICtrlSetBkColor ( $Button_3, 0x00000)
  117.     GUICtrlSetColor ( $Button_3, 0xFFFFFF)
  118.     GUICtrlSetFont ( $Button_3, 10, 800)
  119.   $Button_4 = GUICtrlCreateButton ( "執行程式", 21, $picSize_height-$GUI_Y, 110);離開並執行程式按鈕
  120.     GUICtrlSetBkColor ( $Button_4, 0x00000)
  121.     GUICtrlSetColor ( $Button_4, 0xFFFFFF)
  122.     GUICtrlSetFont ( $Button_4, 10, 800)
  123.     GUICtrlSetState  ($Button_4, $GUI_HIDE);選擇安裝路徑按鈕
  124.   $Text = GUICtrlCreateLabel  ( $FormName, 21, $picSize_height-$GUI_Y-85, $picSize_wide-40, 75);安裝說明及文字
  125.     GUICtrlSetColor ( $Text, 0x5DCA27)
  126.     GUICtrlSetBkColor ( $Text, 0x00000)
  127.     GUICtrlSetFont ( $Text, 45, 800)
  128.   $Label = GUICtrlCreateLabel  ( "", 21, 10, $picSize_wide-40,  $picSize_height-$GUI_Y-85);安裝說明及文字
  129.     GUICtrlSetColor ( $Label, 0x1260FF)
  130.     GUICtrlSetBkColor ( $Label, 0x00000)
  131.     GUICtrlSetFont ( $Label, 20, 800)
  132.   $Day = GUICtrlCreateLabel  ( $LabelDay&" By "&$design, $picSize_wide*0.8, $picSize_height-$GUI_Y+2, 500);時間
  133.     GUICtrlSetBkColor ( $Day, 0x00000)
  134.     GUICtrlSetColor ( $Day, 0x1260FF)
  135.     GUICtrlSetFont ( $Day, 12, 800)
  136.   WinSetOnTop ($GUI,"",1)
  137.   GUISetState()

  138.   GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
  139.   GUIRegisterMsg($WM_MOVE, "WM_MOVE")
  140.   GUIRegisterMsg($WM_SIZE, "WM_MOVE")
  141. ElseIf $SHOW = 2 Then ;;; WINDOWS 7 MOD_2
  142.   Dim $Side[2] = [ "11", "11"];(寬)線寬 ; (高)線

  143.   FileCopy ($img,@ScriptDir&"\img\copypic.bmp")
  144.   _GDIPlus_Startup()
  145.   $hImage1 = _GDIPlus_ImageLoadFromFile($img)
  146.   Dim $picSize_wide = _GDIPlus_ImageGetWidth($hImage1)
  147.   Dim $picSize_height = _GDIPlus_ImageGetHeight($hImage1)
  148.   _GDIPlus_Shutdown()

  149.   Dim $Proportionality = $picSize_wide/$picSize_height;求出圖片比例
  150.   Dim $Size[2] = [$picSize_wide+($Side[0]*2)+28, ($picSize_wide/$Proportionality)+114+20+($Side[1]*2)];; 計算gui 寬高
  151.   Dim $frame = IniRead ($ini, "install", "Frame",10);; 載入 白邊 大小
  152.   Dim $MyArea[4] = [ 22+$frame, 22+$frame, $frame, 129+$frame];; 定義Aero 邊界

  153.   $GUI = GUICreate ( "", $Size[0], $Size[1], Default, Default, $DS_SETFOREGROUND)
  154.   _Vista_EnableBlurBehind ($GUI, $MyArea)
  155.   $GUI_Y = 58;按鈕及文字高度

  156.   $Button_2 = GUICtrlCreateButton ( "Install", 21, $Size[1]-$GUI_Y, 80);安裝按鈕
  157.     GUICtrlSetBkColor ( $Button_2, 0x00000)
  158.     GUICtrlSetColor ( $Button_2, 0xFFFFFF)
  159.     GUICtrlSetFont ( $Button_2, 10, 800)
  160.   $Button_1 = GUICtrlCreateButton ( "...", ($Size[0]*0.17875)-33, $Size[1]-$GUI_Y, 25, 24);選擇安裝目錄按鈕
  161.     GUICtrlSetBkColor ( $Button_1, 0x00000)
  162.     GUICtrlSetColor ( $Button_1, 0xFFFFFF)
  163.     GUICtrlSetFont ( $Button_1, 10, 800)
  164.   $Input = GUICtrlCreateInput ( @ProgramFilesDir&$DirRoute, $Size[0]*0.17875, $Size[1]-$GUI_Y, $Size[0]*0.4975, 24);安裝路徑文字框
  165.     GUICtrlSetBkColor ( $Input, 0x00000)
  166.     GUICtrlSetColor ( $Input, 0x1260FF)
  167.     GUICtrlSetFont ( $Input, 10, 700)
  168.   $Button_3 = GUICtrlCreateButton ( "Exit", $Size[0]*0.6875, $Size[1]-$GUI_Y, 80);離開按鈕
  169.     GUICtrlSetBkColor ( $Button_3, 0x00000)
  170.     GUICtrlSetColor ( $Button_3, 0xFFFFFF)
  171.     GUICtrlSetFont ( $Button_3, 10, 800)
  172.   $Button_4 = GUICtrlCreateButton ( "執行程式", 21, $Size[1]-$GUI_Y, 110);離開並執行程式按鈕
  173.     GUICtrlSetBkColor ( $Button_4, 0x00000)
  174.     GUICtrlSetColor ( $Button_4, 0xFFFFFF)
  175.     GUICtrlSetFont ( $Button_4, 10, 800)
  176.     GUICtrlSetState  ($Button_4, $GUI_HIDE);選擇安裝路徑按鈕
  177.   $Label = GUICtrlCreateLabel  ( $FormName, 21, $Size[1]-$GUI_Y-85, 759, 75);安裝說明及文字
  178.     GUICtrlSetColor ( $Label, 0x5DCA27)
  179.     GUICtrlSetBkColor ( $Label, 0x00000)
  180.     GUICtrlSetFont ( $Label, 45, 800)
  181.   $Day = GUICtrlCreateLabel  ( $LabelDay&" By "&$design, $Size[0]*0.8, $Size[1]-$GUI_Y+2, 145);時間
  182.     GUICtrlSetBkColor ( $Day, 0x00000)
  183.     GUICtrlSetColor ( $Day, 0x1260FF)
  184.     GUICtrlSetFont ( $Day, 12, 800)

  185.   GUICtrlCreatePic ( @ScriptDir&"\img\copypic.bmp", 22, 0, $picSize_wide,$picSize_height);插圖
  186.   GUISetState()
  187. Else ;; XP MOD
  188.   Dim $Point[2] = [ "11", "11"];四個尖角的長x寬
  189.   Dim $Side[2] = [ "11", "11"];(寬)線寬 ; (高)線

  190.   FileCopy ($img,@ScriptDir&"\img\copypic.bmp")
  191.   _GDIPlus_Startup()
  192.   $hImage1 = _GDIPlus_ImageLoadFromFile($img)
  193.   Global $picSize_wide = _GDIPlus_ImageGetWidth($hImage1)
  194.   Global $picSize_height = _GDIPlus_ImageGetHeight($hImage1)

  195.   _GDIPlus_Shutdown()
  196.   If  $picSize_wide < 758 Or  $picSize_height < 426 Then
  197.     MsgBox ( 16,"ERROR","圖片大小不得小於 758x426")
  198.     Exit
  199.   EndIf

  200.   Dim $Size[2] = [ $picSize_wide+($Side[0]*2)+20, $picSize_height+114+20+($Side[1]*2)]

  201.   $GUI = GUICreate ( $FormName, $Size[0], $Size[1], Default, Default, $WS_POPUP, $WS_EX_TOOLWINDOW)
  202.   GUISetBkColor(0x0000000)
  203.   $GUI_Y = 45;按鈕及文字高度
  204.   $Button_2 = GUICtrlCreateButton ( "Install", 21, $Size[1]-$GUI_Y, 80);安裝按鈕
  205.     GUICtrlSetBkColor ( $Button_2, 0x00000)
  206.     GUICtrlSetColor ( $Button_2, 0xFFFFFF)
  207.     GUICtrlSetFont ( $Button_2, 10, 800)
  208.   $Button_1 = GUICtrlCreateButton ( "...", ($Size[0]*0.17875)-33, $Size[1]-$GUI_Y, 25, 24);選擇安裝目錄按鈕
  209.     GUICtrlSetBkColor ( $Button_1, 0x00000)
  210.     GUICtrlSetColor ( $Button_1, 0xFFFFFF)
  211.     GUICtrlSetFont ( $Button_1, 10, 800)
  212.   $Input = GUICtrlCreateInput ( @ProgramFilesDir&$DirRoute, $Size[0]*0.17875, $Size[1]-$GUI_Y, $Size[0]*0.4975, 24);安裝路徑文字框
  213.     GUICtrlSetBkColor ( $Input, 0x00000)
  214.     GUICtrlSetColor ( $Input, 0x1590FF)
  215.     GUICtrlSetFont ( $Input, 12, 800)
  216.   $Button_3 = GUICtrlCreateButton ( "Exit", $Size[0]*0.6875, $Size[1]-$GUI_Y, 80);離開按鈕
  217.     GUICtrlSetBkColor ( $Button_3, 0x00000)
  218.     GUICtrlSetColor ( $Button_3, 0xFFFFFF)
  219.     GUICtrlSetFont ( $Button_3, 10, 800)
  220.   $Button_4 = GUICtrlCreateButton ( "執行程式", 21, $Size[1]-$GUI_Y, 110);離開並執行程式按鈕
  221.     GUICtrlSetBkColor ( $Button_4, 0x00000)
  222.     GUICtrlSetColor ( $Button_4, 0xFFFFFF)
  223.     GUICtrlSetFont ( $Button_4, 10, 800)
  224.     GUICtrlSetState  ($Button_4, $GUI_HIDE);選擇安裝路徑按鈕
  225.   $Label = GUICtrlCreateLabel  ( $FormName, 21, $Size[1]-115, 758, 65);安裝說明及文字
  226.     GUICtrlSetColor ( $Label, 0x5DCA27)
  227.     GUICtrlSetBkColor ( $Label, 0x00000)
  228.     GUICtrlSetFont ( $Label, 40, 800)
  229.   $Day = GUICtrlCreateLabel  ( $LabelDay&" By "&$design, $Size[0]*0.79375, $Size[1]-$GUI_Y+2, 149);時間
  230.     GUICtrlSetBkColor ( $Day, 0x00000)
  231.     GUICtrlSetColor ( $Day, 0x1590FF)
  232.     GUICtrlSetFont ( $Day, 12, 700)

  233.   ;-----------(四個角)-----------
  234.     GUICtrlCreatePic ( @ScriptDir&"\Other\Wallpaper_Top_Left.bmp", 0, 0, $Point[0], $Point[1]);左上
  235.     GUICtrlCreatePic ( @ScriptDir&"\Other\Wallpaper_Bottom_Left.bmp", 0, $Size[1]-$Point[1], $Point[0], $Point[1]);左下
  236.     GUICtrlCreatePic ( @ScriptDir&"\Other\Wallpaper_Top_Right.bmp", $Size[0]-$Point[0], 0, $Point[0], $Point[1]);右上
  237.     GUICtrlCreatePic ( @ScriptDir&"\Other\Wallpaper_Bottom_Right.bmp", $Size[0]-$Point[0], $Size[1]-$Point[1], $Point[0], $Point[1]);右下
  238.   ;-----------(邊框寬度判斷)-----------
  239.     GUICtrlCreatePic ( @ScriptDir&"\Other\Wallpaper_Top.bmp", $Point[0], 0, $Size[0]-($Point[0]*2), $Side[0]);上
  240.     GUICtrlCreatePic ( @ScriptDir&"\Other\wallpaper_bottom.bmp", $Point[0], $Size[1]-11, $Size[0]-($Point[0]*2), $Side[0]);下
  241.   ;-----------(邊框高度判斷)-----------
  242.     GUICtrlCreatePic ( @ScriptDir&"\Other\Wallpaper_Left.bmp", 0, $Point[1], $Side[1], $Size[1]-($Point[1]*2));左
  243.     GUICtrlCreatePic ( @ScriptDir&"\Other\Wallpaper_Right.bmp", $Size[0]-$Point[0], $Point[1], $Side[1], $Size[1]-($Point[1]*2));右

  244.   GUICtrlCreatePic ( @ScriptDir&"\img\copypic.bmp", $Point[0]+10, $Point[1]+10, $picSize_wide, $picSize_height);插
  245.   GUISetState()
  246. EndIf

  247. WinSetOnTop ($GUI,"",1)

  248. While 1
  249.   If  $SHOW = 1 Then SetTop();設定$GUI 永久為最上層
  250.   $nMsg = GUIGetMsg()
  251.   Switch $nMsg
  252.     Case $GUI_EVENT_CLOSE
  253.       ExitLoop
  254.     Case $Button_1
  255.       WinSetOnTop ( $GUI, "", 0)
  256.       $Var = FileSelectFolder( "請選擇安裝目錄", "", 1, @ProgramFilesDir)
  257.       WinWaitClose ( "瀏覽資料夾", "請選擇安裝目錄")
  258.       WinSetOnTop ( $GUI, "", 1)
  259.       If $Var = "" Then
  260.         GUICtrlSetData ( $Input, @ProgramFilesDir&$DirRoute)
  261.       Else
  262.         GUICtrlSetData ( $Input, $Var&$DirRoute)
  263.       EndIf
  264.     Case $Button_2
  265.       GUICtrlSetState ( $Button_1, $GUI_DISABLE)
  266.       GUICtrlSetState ( $Button_2, $GUI_DISABLE)
  267.       GUICtrlSetState ( $Input, $GUI_DISABLE)
  268. ;-----------(修改文字及字體)-----------
  269.       GUICtrlSetData ( $Label, "本安裝程式為一鍵安裝,安裝中請勿移動滑鼠及鍵盤以免產生錯誤 ...")
  270.       GUICtrlSetBkColor ( $Label, 0x00000)
  271.       If $SHOW = 1 Then
  272.         GUICtrlSetColor ( $Label, 0x1260FF)
  273.       Else
  274.         GUICtrlSetColor ( $Label, 0x1590FF)
  275.           GUICtrlSetFont ( $Label, 9, 800)
  276.       EndIf
  277. ;-----------(複製檔案)-----------
  278.       GUICtrlSetData ( $Label, "本安裝程式為一鍵安裝,安裝中請勿移動滑鼠及鍵盤以免產生錯誤。"&@CR&"複製檔案中 ...")
  279.         DirCreate (@ProgramsCommonDir&$DirRoute);建立新資料夾
  280.         DirCopy ( @ScriptDir&$DirRoute, GUICtrlRead ($Input), 1) ;複製檔案
  281.       GUICtrlSetData ( $Label, "本安裝程式為一鍵安裝,安裝中請勿移動滑鼠及鍵盤以免產生錯誤。"&@CR&"複製檔案 完成"&@CR&"建立捷徑中 ...")
  282.         FileCreateShortcut ( GUICtrlRead ($Input)&$exeName, @ProgramsCommonDir&$DirRoute&$FileName&".lnk");開始程式及裡建立捷徑
  283.         FileCreateShortcut ( GUICtrlRead ($Input)&$exeName, @DesktopDir&$FileName&".lnk");桌面建立捷徑
  284. ;-----------(中文化)----------- 選用
  285.       GUICtrlSetData ( $Label, "本安裝程式為一鍵安裝,安裝中請勿移動滑鼠及鍵盤以免產生錯誤。"&@CR&"複製檔案 完成"&@CR&"建立捷徑 完成,")
  286. ;~       Chs()
  287. ;-----------(安裝完成)-----------
  288.       GUICtrlSetData ( $Label, "本安裝程式為一鍵安裝,安裝中請勿移動滑鼠及鍵盤以免產生錯誤 ..."&@CR&"複製檔案 完成"&@CR&"建立捷徑 完成"&@CR&$FormName&" 安裝完成")
  289. ;-----------(修改顯示控件)-----------
  290.       GUICtrlSetState  ($Button_1, $GUI_HIDE);選擇安裝路徑按鈕
  291.       GUICtrlSetState  ($Button_2, $GUI_HIDE);開始安裝按鈕
  292.       GUICtrlSetState  ($Input, $GUI_HIDE);開始安裝按鈕
  293.       GUICtrlSetState  ($Button_4, $GUI_SHOW);開始安裝按鈕
  294.       If $SHOW = 1 Then
  295.         GUICtrlSetPos (  $Button_3, ($picSize_wide*0.17875), $picSize_height-$GUI_Y, 120)
  296.       Else
  297.         GUICtrlSetPos (  $Button_3, ($picSize_wide*0.17875), $Size[1]-$GUI_Y, 120)
  298.       EndIf
  299.       GUICtrlSetData ( $Button_3, "結束安裝")
  300.       GUICtrlSetState ( $Button_4, $GUI_FOCUS)
  301.     Case $Button_3
  302.       Exit
  303.     Case $Button_4
  304.       ShellExecute (GUICtrlRead ($Input)&$exeName)
  305.       Exit
  306.         EndSwitch
  307. WEnd


  308. Func SetTop();設定$GUI 永久為最上層
  309.   If $SHOW <> 2 Then
  310.     If Not WinActive  ($form1) Then WinActivate ($GUI)
  311.   EndIf
  312. EndFunc

  313. Func WM_MOVE($hWnd, $Msg, $wParam, $lParam)
  314.   $XY2 = WinGetPos($GUI)
  315.   WinMove($Form1, "", $XY2[0], $XY2[1])
  316. EndFunc

  317. Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
  318.   Switch $hWnd
  319.     Case $form1
  320.       Switch $iMsg
  321.         Case $WM_NCHITTEST
  322.             Return $HTCAPTION
  323.       EndSwitch
  324.   EndSwitch
  325.   Return $GUI_RUNDEFMSG
  326. EndFunc

  327. Func Error()
  328.   If FileExists ($ini) = 0 Then
  329.     MsgBox ( 16,"ERROR","找不到 Install.ini ")
  330.     Exit
  331.   EndIf

  332.   If FileExists ($img) = 0 Then
  333.     MsgBox ( 16,"ERROR","找不到圖片檔")
  334.     Exit
  335.   EndIf

  336.   If $SHOW = 0 Or $SHOW = 1 Then
  337.     If Not _WinAPI_DwmIsCompositionEnabled() Then
  338.       $SHOW = 3; 無法啟動DWM 開啟XP MOD
  339.     EndIf
  340.   EndIf

  341.   If $design = "" Then $design = "噹噹"

  342.   If $FormName = "" Or $exeName = "" Or $FileName = "" Or $DirRoute = "" Then
  343.     MsgBox (16,"ERROR","路徑、檔名不得為空白")
  344.     Exit
  345.   EndIf
  346. EndFunc

  347. Func _WinAPI_DwmIsCompositionEnabled()

  348.   Local $Ret = DllCall('dwmapi.dll', 'uint', 'DwmIsCompositionEnabled', 'int*', 0)

  349.   If @error Then
  350.     Return SetError(1, 0, 0)
  351.   Else
  352.     If $Ret[0] Then
  353.       Return SetError(1, $Ret[0], 0)
  354.     EndIf
  355.   EndIf
  356.   Return $Ret[1]
  357. EndFunc   ;==>_WinAPI_DwmIsCompositionEnabled

  358. Func _WinAPI_DwmGetColorizationColor()

  359.   Local $Ret = DllCall('dwmapi.dll', 'uint', 'DwmGetColorizationColor', 'dword*', 0, 'int*', 0)

  360.   If @error Then
  361.     Return SetError(1, 0, 0)
  362.   Else
  363.     If $Ret[0] Then
  364.       Return SetError(1, $Ret[0], 0)
  365.     EndIf
  366.   EndIf
  367.   Return SetError(0, $Ret[2], $Ret[1])
  368. EndFunc   ;==>_WinAPI_DwmGetColorizationColor

  369. Func _WinAPI_UpdateLayeredWindowEx($hWnd, $hBitmap, $iOpacity = 255, $fDelete = 0)

  370.   Local $Ret, $tSIZE, $tPOINT, $tBLENDFUNCTION, $hDC, $hDestDC, $hDestSv

  371.   $Ret = DllCall('user32.dll', 'hwnd', 'GetDC', 'hwnd', $hWnd)
  372.   $hDC = $Ret[0]
  373.   $Ret = DllCall('gdi32.dll', 'hwnd', 'CreateCompatibleDC', 'hwnd', $hDC)
  374.   $hDestDC = $Ret[0]
  375.   $Ret = DllCall('gdi32.dll', 'hwnd', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hBitmap)
  376.   $hDestSv = $Ret[0]
  377.   $tSIZE = _WinAPI_GetBitmapDimension($hBitmap)
  378.   $tPOINT = DllStructCreate($tagPOINT)
  379.   $tBLENDFUNCTION = DllStructCreate($tagBLENDFUNCTION)
  380.   DllStructSetData($tBLENDFUNCTION, 'Alpha', $iOpacity)
  381.   DllStructSetData($tBLENDFUNCTION, 'Format', 1)
  382.   $Ret = DllCall('user32.dll', 'int', 'UpdateLayeredWindow', 'hwnd', $hWnd, 'hwnd', $hDC, 'ptr', 0, 'ptr', DllStructGetPtr($tSIZE), 'hwnd', $hDestDC, 'ptr', DllStructGetPtr($tPOINT), 'dword', 0, 'ptr', DllStructGetPtr($tBLENDFUNCTION), 'dword', 0x02)
  383.   DllCall('user32.dll', 'int', 'ReleaseDC', 'hwnd', $hWnd, 'hwnd', $hDC)
  384.   DllCall('gdi32.dll', 'ptr', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hDestSv)
  385.   DllCall('gdi32.dll', 'int', 'DeleteDC', 'hwnd', $hDestDC)
  386.   If Not $Ret Then
  387.     Return SetError(1, 0, 0)
  388.   EndIf
  389.   If $fDelete Then
  390.     _WinAPI_DeleteObject($hBitmap)
  391.   EndIf
  392.   Return 1
  393. EndFunc   ;==>_WinAPI_UpdateLayeredWindowEx

  394. Func _WinAPI_GetBitmapDimension($hBitmap)
  395.   Global Const $tagBITMAP = 'long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;'
  396.     Local $tObj = DllStructCreate($tagBITMAP)
  397.   Local $Ret = DllCall('gdi32.dll', 'int', 'GetObject', 'int', $hBitmap, 'int', DllStructGetSize($tObj), 'ptr', DllStructGetPtr($tObj))

  398.   If (@error) Or (Not $Ret[0]) Then
  399.     Return SetError(1, 0, 0)
  400.   EndIf

  401.   Local $tSIZE = DllStructCreate($tagSIZE)

  402.   DllStructSetData($tSIZE, 1, DllStructGetData($tObj, 'bmWidth'))
  403.   DllStructSetData($tSIZE, 2, DllStructGetData($tObj, 'bmHeight'))

  404.   Return $tSIZE
  405. EndFunc   ;==>_WinAPI_GetBitmapDimension


  406. Func _Vista_EnableBlurBehind ($hWnd, $Area, $bColor = 0x000000)
  407.     $Struct = DllStructCreate ("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
  408.     $sStruct = DllStructCreate ("dword;int;ptr;int")
  409.   If IsArray ($Area) Then
  410.     DllStructSetData ($Struct, "cxLeftWidth", $Area[0])
  411.     DllStructSetData ($Struct, "cxRightWidth", $Area[1])
  412.     DllStructSetData ($Struct, "cyTopHeight", $Area[2])
  413.     DllStructSetData ($Struct, "cyBottomHeight", $Area[3])

  414.     GUISetBkColor ($bColor)
  415.     $Ret = DllCall ("dwmapi.dll", "long*", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($Struct))
  416.     If @error Then
  417.       Return 0
  418.     Else
  419.       Return $Ret
  420.     EndIf
  421.   Else
  422.     MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!")
  423.   EndIf
  424. EndFunc
複製代碼

本帖子中包含更多資源

您需要 登入 才可以下載或查看,沒有帳號?註冊

x

該用戶從未簽到

發表於 2014-12-29 09:13 | 顯示全部樓層
請問是下載附件和將代碼複製在組譯就可使用嗎?

使用道具

簽到天數: 9

該用戶今日未簽到

發表於 2015-8-22 17:28 | 顯示全部樓層
Thanks for sharing this installation tool.

使用道具

您需要登入後才可以回帖 登入 | 註冊

本版積分規則

Discuz! X

© 2009-2017 Microduo

快速回覆 返回頂部 返回列表