本帖最後由 rictirse 於 2014-9-14 00:11 編輯
AutoIt GUI 進階班 Aero Install
這個GUI 噹噹已經刻好,只需要使用ini 稍微設定一下就可以做出簡單又漂亮的自動安裝介面
請看DEMO 影片
code需要者自取
需要搭配 圖片包與ini 載點- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- #include <sendmessage.au3>
- #include <GuiEdit.au3>
- #Include <Date.au3>
- #include <GDIPlus.au3>
- #Region
- #AutoIt3Wrapper_icon=C:NewDang.ico;; 設定 icon 路徑
- #AutoIt3Wrapper_Compression=5 ;; 壓縮等級
- #AutoIt3Wrapper_Res_Comment=Aero Install
- #AutoIt3Wrapper_Res_Description=Aero Install
- #AutoIt3Wrapper_Res_Fileversion=2.3.0.0 ;; 版本代號
- #AutoIt3Wrapper_Res_LegalCopyright=噹噹 ;; 作者
- #EndRegion
- Global $ini = @ScriptDir&"install.ini"
- If IniRead ($ini, "install", "IconHide", 0) = 1 Then AutoItSetOption ( "TrayIconHide", 1)
- ;-----------(隨機選圖)-----------
- Dim $i = 0, $file[100];;; 預設圖片最大數量 100
- Dim $ImgRoute = @ScriptDir&IniRead ($ini, "install", "ImgRoute","")
- FileDelete (@ScriptDir&"imgcopypic.bmp");; 刪除暫存圖片
- $search = FileFindFirstFile($ImgRoute&"*.BMP")
- If $search = -1 Then
- MsgBox(0, "錯誤", "找不到圖片")
- Exit
- EndIf
- While 1
- $i += 1
- $file[$i] = FileFindNextFile($search)
- If @error Then ExitLoop
- $file[0] = $i
- WEnd
- FileClose($search)
- $numimg = Random ( 1, $file[0], 1)
- Global $img = $ImgRoute&$file[$numimg]
- ;~ MsgBox ( 0, $numimg, $img);顯示抽到哪張圖
- ;-----------(隨機選圖)-----------
- Global $FormName = IniRead ($ini, "install", "FormName","")
- Global $exeName = IniRead ($ini, "install", "exeName","")
- Global $FileName = IniRead ($ini, "install", "FileName","")
- Global $DirRoute = IniRead ($ini, "install", "DirRoute","")
- Global $LabelDay = IniRead ($ini, "install", "LabelDay","")
- Global $Design = IniRead ($ini, "install", "Design","")
- ; 0 = 自動判斷OS 如果是 W7 會隨機選 MOD 1 or 2
- ; 1 = 強制W7 MOD_1
- ; 2 = 強制W7 MOD_2
- ; 3 = 強制XP MOD ;預設=2 非 0或 1 其餘返回值皆為2
- Global $MOD = IniRead ($ini, "install", "MOD", 3)
- If $MOD = 0 Then
- If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Then
- If Random() < 0.5 Then
- Global $SHOW = 1;W7 MOD_1
- Else
- Global $SHOW = 2;W7 MOD_2
- Endif
- Else
- Global $SHOW = 3;XP MOD
- EndIf
- ElseIf $MOD = 1 Then
- Global $SHOW = 1;W7 MOD_1
- ElseIf $MOD = 2 Then
- Global $SHOW = 2;W7 MOD_2
- Else
- Global $SHOW = 3;XP MOD
- EndIf
- Error()
- If $SHOW = 1 Then ;; WINDOWS 7 MOD_1
- Dim $MyArea[4] = [9999,9999,9999,9999]
- $_alpha=_WinAPI_DwmGetColorizationColor( )
- $CtrlBkColor="0X"&Hex(BitAND($_alpha,0xFFFFFF),6)
- $_alpha="0X"&Hex($_alpha)
- _GDIPlus_Startup()
- $hImage1 = _GDIPlus_ImageLoadFromFile($img)
- Dim $picSize_wide = _GDIPlus_ImageGetWidth($hImage1)
- Dim $picSize_height = _GDIPlus_ImageGetHeight($hImage1)
- Dim $alpha = IniRead ($ini, "install", "alpha", 255)
- If $alpha = "" Then $alpha = 255
- If $alpha > 255 Or $alpha < 0 Then $alpha = 255 ;設定alpha值 alpha = 0 全透明, alpha = 255 不透明, 預設255
- If $picSize_wide < 758 Or $picSize_height < 426 Then
- MsgBox ( 16,"ERROR","圖片大小不得小於 758x426")
- Exit
- EndIf
- $hBitmap1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1)
- $hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1)
- $hHBITMAP = _WinAPI_CreateBitmap($picSize_wide, $picSize_height, 1, 32)
- $hCDC = _WinAPI_CreateCompatibleDC(0)
- _WinAPI_SelectObject($hCDC, $hHBITMAP)
- $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hCDC)
- _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $picSize_wide, $picSize_height)
- _WinAPI_DeleteObject($hImage)
- _GDIPlus_GraphicsDispose($hGraphic)
- _WinAPI_DeleteDC($hCDC)
- $form1 = GUICreate($FormName,$picSize_wide, $picSize_height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
- _WinAPI_UpdateLayeredWindowEx($form1, $hHBITMAP, $alpha, 1)
- _GDIPlus_ImageDispose($hImage1)
- _WinAPI_DeleteObject($hBitmap1)
- _GDIPlus_Shutdown()
- WinSetOnTop ($form1,"",1)
- GUISetState()
- $pos1=WinGetPos($form1,"")
- $GUI = GUICreate ( "", $picSize_wide, $picSize_height, $pos1[0], $pos1[1],$DS_SETFOREGROUND,$WS_EX_TOOLWINDOW)
- _Vista_EnableBlurBehind($GUI, $MyArea)
- $GUI_Y = 58;按鈕及文字高度
- $Button_2 = GUICtrlCreateButton ( "Install", 21, $picSize_height-$GUI_Y, 80);安裝按鈕
- GUICtrlSetBkColor ( $Button_2, 0x00000)
- GUICtrlSetColor ( $Button_2, 0xFFFFFF)
- GUICtrlSetFont ( $Button_2, 10, 800)
- $Button_1 = GUICtrlCreateButton ( "...", ($picSize_wide*0.17875)-33, $picSize_height-$GUI_Y, 25, 24);選擇安裝目錄按鈕
- GUICtrlSetBkColor ( $Button_1, 0x00000)
- GUICtrlSetColor ( $Button_1, 0xFFFFFF)
- GUICtrlSetFont ( $Button_1, 10, 800)
- $Input = GUICtrlCreateInput ( @ProgramFilesDir&$DirRoute, $picSize_wide*0.17875, $picSize_height-$GUI_Y, $picSize_wide*0.4975, 24);安裝路徑文字框
- GUICtrlSetBkColor ( $Input, 0x00000)
- GUICtrlSetColor ( $Input, 0x1260FF)
- GUICtrlSetFont ( $Input, 10, 700)
- $Button_3 = GUICtrlCreateButton ( "Exit", $picSize_wide*0.6875, $picSize_height-$GUI_Y, 80);離開按鈕
- GUICtrlSetBkColor ( $Button_3, 0x00000)
- GUICtrlSetColor ( $Button_3, 0xFFFFFF)
- GUICtrlSetFont ( $Button_3, 10, 800)
- $Button_4 = GUICtrlCreateButton ( "執行程式", 21, $picSize_height-$GUI_Y, 110);離開並執行程式按鈕
- GUICtrlSetBkColor ( $Button_4, 0x00000)
- GUICtrlSetColor ( $Button_4, 0xFFFFFF)
- GUICtrlSetFont ( $Button_4, 10, 800)
- GUICtrlSetState ($Button_4, $GUI_HIDE);選擇安裝路徑按鈕
- $Text = GUICtrlCreateLabel ( $FormName, 21, $picSize_height-$GUI_Y-85, $picSize_wide-40, 75);安裝說明及文字
- GUICtrlSetColor ( $Text, 0x5DCA27)
- GUICtrlSetBkColor ( $Text, 0x00000)
- GUICtrlSetFont ( $Text, 45, 800)
- $Label = GUICtrlCreateLabel ( "", 21, 10, $picSize_wide-40, $picSize_height-$GUI_Y-85);安裝說明及文字
- GUICtrlSetColor ( $Label, 0x1260FF)
- GUICtrlSetBkColor ( $Label, 0x00000)
- GUICtrlSetFont ( $Label, 20, 800)
- $Day = GUICtrlCreateLabel ( $LabelDay&" By "&$design, $picSize_wide*0.8, $picSize_height-$GUI_Y+2, 500);時間
- GUICtrlSetBkColor ( $Day, 0x00000)
- GUICtrlSetColor ( $Day, 0x1260FF)
- GUICtrlSetFont ( $Day, 12, 800)
- WinSetOnTop ($GUI,"",1)
- GUISetState()
- GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
- GUIRegisterMsg($WM_MOVE, "WM_MOVE")
- GUIRegisterMsg($WM_SIZE, "WM_MOVE")
- ElseIf $SHOW = 2 Then ;;; WINDOWS 7 MOD_2
- Dim $Side[2] = [ "11", "11"];(寬)線寬 ; (高)線
- FileCopy ($img,@ScriptDir&"imgcopypic.bmp")
- _GDIPlus_Startup()
- $hImage1 = _GDIPlus_ImageLoadFromFile($img)
- Dim $picSize_wide = _GDIPlus_ImageGetWidth($hImage1)
- Dim $picSize_height = _GDIPlus_ImageGetHeight($hImage1)
- _GDIPlus_Shutdown()
- Dim $Proportionality = $picSize_wide/$picSize_height;求出圖片比例
- Dim $Size[2] = [$picSize_wide+($Side[0]*2)+28, ($picSize_wide/$Proportionality)+114+20+($Side[1]*2)];; 計算gui 寬高
- Dim $frame = IniRead ($ini, "install", "Frame",10);; 載入 白邊 大小
- Dim $MyArea[4] = [ 22+$frame, 22+$frame, $frame, 129+$frame];; 定義Aero 邊界
- $GUI = GUICreate ( "", $Size[0], $Size[1], Default, Default, $DS_SETFOREGROUND)
- _Vista_EnableBlurBehind ($GUI, $MyArea)
- $GUI_Y = 58;按鈕及文字高度
- $Button_2 = GUICtrlCreateButton ( "Install", 21, $Size[1]-$GUI_Y, 80);安裝按鈕
- GUICtrlSetBkColor ( $Button_2, 0x00000)
- GUICtrlSetColor ( $Button_2, 0xFFFFFF)
- GUICtrlSetFont ( $Button_2, 10, 800)
- $Button_1 = GUICtrlCreateButton ( "...", ($Size[0]*0.17875)-33, $Size[1]-$GUI_Y, 25, 24);選擇安裝目錄按鈕
- GUICtrlSetBkColor ( $Button_1, 0x00000)
- GUICtrlSetColor ( $Button_1, 0xFFFFFF)
- GUICtrlSetFont ( $Button_1, 10, 800)
- $Input = GUICtrlCreateInput ( @ProgramFilesDir&$DirRoute, $Size[0]*0.17875, $Size[1]-$GUI_Y, $Size[0]*0.4975, 24);安裝路徑文字框
- GUICtrlSetBkColor ( $Input, 0x00000)
- GUICtrlSetColor ( $Input, 0x1260FF)
- GUICtrlSetFont ( $Input, 10, 700)
- $Button_3 = GUICtrlCreateButton ( "Exit", $Size[0]*0.6875, $Size[1]-$GUI_Y, 80);離開按鈕
- GUICtrlSetBkColor ( $Button_3, 0x00000)
- GUICtrlSetColor ( $Button_3, 0xFFFFFF)
- GUICtrlSetFont ( $Button_3, 10, 800)
- $Button_4 = GUICtrlCreateButton ( "執行程式", 21, $Size[1]-$GUI_Y, 110);離開並執行程式按鈕
- GUICtrlSetBkColor ( $Button_4, 0x00000)
- GUICtrlSetColor ( $Button_4, 0xFFFFFF)
- GUICtrlSetFont ( $Button_4, 10, 800)
- GUICtrlSetState ($Button_4, $GUI_HIDE);選擇安裝路徑按鈕
- $Label = GUICtrlCreateLabel ( $FormName, 21, $Size[1]-$GUI_Y-85, 759, 75);安裝說明及文字
- GUICtrlSetColor ( $Label, 0x5DCA27)
- GUICtrlSetBkColor ( $Label, 0x00000)
- GUICtrlSetFont ( $Label, 45, 800)
- $Day = GUICtrlCreateLabel ( $LabelDay&" By "&$design, $Size[0]*0.8, $Size[1]-$GUI_Y+2, 145);時間
- GUICtrlSetBkColor ( $Day, 0x00000)
- GUICtrlSetColor ( $Day, 0x1260FF)
- GUICtrlSetFont ( $Day, 12, 800)
- GUICtrlCreatePic ( @ScriptDir&"imgcopypic.bmp", 22, 0, $picSize_wide,$picSize_height);插圖
- GUISetState()
- Else ;; XP MOD
- Dim $Point[2] = [ "11", "11"];四個尖角的長x寬
- Dim $Side[2] = [ "11", "11"];(寬)線寬 ; (高)線
- FileCopy ($img,@ScriptDir&"imgcopypic.bmp")
- _GDIPlus_Startup()
- $hImage1 = _GDIPlus_ImageLoadFromFile($img)
- Global $picSize_wide = _GDIPlus_ImageGetWidth($hImage1)
- Global $picSize_height = _GDIPlus_ImageGetHeight($hImage1)
- _GDIPlus_Shutdown()
- If $picSize_wide < 758 Or $picSize_height < 426 Then
- MsgBox ( 16,"ERROR","圖片大小不得小於 758x426")
- Exit
- EndIf
- Dim $Size[2] = [ $picSize_wide+($Side[0]*2)+20, $picSize_height+114+20+($Side[1]*2)]
- $GUI = GUICreate ( $FormName, $Size[0], $Size[1], Default, Default, $WS_POPUP, $WS_EX_TOOLWINDOW)
- GUISetBkColor(0x0000000)
- $GUI_Y = 45;按鈕及文字高度
- $Button_2 = GUICtrlCreateButton ( "Install", 21, $Size[1]-$GUI_Y, 80);安裝按鈕
- GUICtrlSetBkColor ( $Button_2, 0x00000)
- GUICtrlSetColor ( $Button_2, 0xFFFFFF)
- GUICtrlSetFont ( $Button_2, 10, 800)
- $Button_1 = GUICtrlCreateButton ( "...", ($Size[0]*0.17875)-33, $Size[1]-$GUI_Y, 25, 24);選擇安裝目錄按鈕
- GUICtrlSetBkColor ( $Button_1, 0x00000)
- GUICtrlSetColor ( $Button_1, 0xFFFFFF)
- GUICtrlSetFont ( $Button_1, 10, 800)
- $Input = GUICtrlCreateInput ( @ProgramFilesDir&$DirRoute, $Size[0]*0.17875, $Size[1]-$GUI_Y, $Size[0]*0.4975, 24);安裝路徑文字框
- GUICtrlSetBkColor ( $Input, 0x00000)
- GUICtrlSetColor ( $Input, 0x1590FF)
- GUICtrlSetFont ( $Input, 12, 800)
- $Button_3 = GUICtrlCreateButton ( "Exit", $Size[0]*0.6875, $Size[1]-$GUI_Y, 80);離開按鈕
- GUICtrlSetBkColor ( $Button_3, 0x00000)
- GUICtrlSetColor ( $Button_3, 0xFFFFFF)
- GUICtrlSetFont ( $Button_3, 10, 800)
- $Button_4 = GUICtrlCreateButton ( "執行程式", 21, $Size[1]-$GUI_Y, 110);離開並執行程式按鈕
- GUICtrlSetBkColor ( $Button_4, 0x00000)
- GUICtrlSetColor ( $Button_4, 0xFFFFFF)
- GUICtrlSetFont ( $Button_4, 10, 800)
- GUICtrlSetState ($Button_4, $GUI_HIDE);選擇安裝路徑按鈕
- $Label = GUICtrlCreateLabel ( $FormName, 21, $Size[1]-115, 758, 65);安裝說明及文字
- GUICtrlSetColor ( $Label, 0x5DCA27)
- GUICtrlSetBkColor ( $Label, 0x00000)
- GUICtrlSetFont ( $Label, 40, 800)
- $Day = GUICtrlCreateLabel ( $LabelDay&" By "&$design, $Size[0]*0.79375, $Size[1]-$GUI_Y+2, 149);時間
- GUICtrlSetBkColor ( $Day, 0x00000)
- GUICtrlSetColor ( $Day, 0x1590FF)
- GUICtrlSetFont ( $Day, 12, 700)
- ;-----------(四個角)-----------
- GUICtrlCreatePic ( @ScriptDir&"OtherWallpaper_Top_Left.bmp", 0, 0, $Point[0], $Point[1]);左上
- GUICtrlCreatePic ( @ScriptDir&"OtherWallpaper_Bottom_Left.bmp", 0, $Size[1]-$Point[1], $Point[0], $Point[1]);左下
- GUICtrlCreatePic ( @ScriptDir&"OtherWallpaper_Top_Right.bmp", $Size[0]-$Point[0], 0, $Point[0], $Point[1]);右上
- GUICtrlCreatePic ( @ScriptDir&"OtherWallpaper_Bottom_Right.bmp", $Size[0]-$Point[0], $Size[1]-$Point[1], $Point[0], $Point[1]);右下
- ;-----------(邊框寬度判斷)-----------
- GUICtrlCreatePic ( @ScriptDir&"OtherWallpaper_Top.bmp", $Point[0], 0, $Size[0]-($Point[0]*2), $Side[0]);上
- GUICtrlCreatePic ( @ScriptDir&"Otherwallpaper_bottom.bmp", $Point[0], $Size[1]-11, $Size[0]-($Point[0]*2), $Side[0]);下
- ;-----------(邊框高度判斷)-----------
- GUICtrlCreatePic ( @ScriptDir&"OtherWallpaper_Left.bmp", 0, $Point[1], $Side[1], $Size[1]-($Point[1]*2));左
- GUICtrlCreatePic ( @ScriptDir&"OtherWallpaper_Right.bmp", $Size[0]-$Point[0], $Point[1], $Side[1], $Size[1]-($Point[1]*2));右
- GUICtrlCreatePic ( @ScriptDir&"imgcopypic.bmp", $Point[0]+10, $Point[1]+10, $picSize_wide, $picSize_height);插
- GUISetState()
- EndIf
- WinSetOnTop ($GUI,"",1)
- While 1
- If $SHOW = 1 Then SetTop();設定$GUI 永久為最上層
- $nMsg = GUIGetMsg()
- Switch $nMsg
- Case $GUI_EVENT_CLOSE
- ExitLoop
- Case $Button_1
- WinSetOnTop ( $GUI, "", 0)
- $Var = FileSelectFolder( "請選擇安裝目錄", "", 1, @ProgramFilesDir)
- WinWaitClose ( "瀏覽資料夾", "請選擇安裝目錄")
- WinSetOnTop ( $GUI, "", 1)
- If $Var = "" Then
- GUICtrlSetData ( $Input, @ProgramFilesDir&$DirRoute)
- Else
- GUICtrlSetData ( $Input, $Var&$DirRoute)
- EndIf
- Case $Button_2
- GUICtrlSetState ( $Button_1, $GUI_DISABLE)
- GUICtrlSetState ( $Button_2, $GUI_DISABLE)
- GUICtrlSetState ( $Input, $GUI_DISABLE)
- ;-----------(修改文字及字體)-----------
- GUICtrlSetData ( $Label, "本安裝程式為一鍵安裝,安裝中請勿移動滑鼠及鍵盤以免產生錯誤 ...")
- GUICtrlSetBkColor ( $Label, 0x00000)
- If $SHOW = 1 Then
- GUICtrlSetColor ( $Label, 0x1260FF)
- Else
- GUICtrlSetColor ( $Label, 0x1590FF)
- GUICtrlSetFont ( $Label, 9, 800)
- EndIf
- ;-----------(複製檔案)-----------
- GUICtrlSetData ( $Label, "本安裝程式為一鍵安裝,安裝中請勿移動滑鼠及鍵盤以免產生錯誤。"&@CR&"複製檔案中 ...")
- DirCreate (@ProgramsCommonDir&$DirRoute);建立新資料夾
- DirCopy ( @ScriptDir&$DirRoute, GUICtrlRead ($Input), 1) ;複製檔案
- GUICtrlSetData ( $Label, "本安裝程式為一鍵安裝,安裝中請勿移動滑鼠及鍵盤以免產生錯誤。"&@CR&"複製檔案 完成"&@CR&"建立捷徑中 ...")
- FileCreateShortcut ( GUICtrlRead ($Input)&$exeName, @ProgramsCommonDir&$DirRoute&$FileName&".lnk");開始程式及裡建立捷徑
- FileCreateShortcut ( GUICtrlRead ($Input)&$exeName, @DesktopDir&$FileName&".lnk");桌面建立捷徑
- ;-----------(中文化)----------- 選用
- GUICtrlSetData ( $Label, "本安裝程式為一鍵安裝,安裝中請勿移動滑鼠及鍵盤以免產生錯誤。"&@CR&"複製檔案 完成"&@CR&"建立捷徑 完成,")
- ;~ Chs()
- ;-----------(安裝完成)-----------
- GUICtrlSetData ( $Label, "本安裝程式為一鍵安裝,安裝中請勿移動滑鼠及鍵盤以免產生錯誤 ..."&@CR&"複製檔案 完成"&@CR&"建立捷徑 完成"&@CR&$FormName&" 安裝完成")
- ;-----------(修改顯示控件)-----------
- GUICtrlSetState ($Button_1, $GUI_HIDE);選擇安裝路徑按鈕
- GUICtrlSetState ($Button_2, $GUI_HIDE);開始安裝按鈕
- GUICtrlSetState ($Input, $GUI_HIDE);開始安裝按鈕
- GUICtrlSetState ($Button_4, $GUI_SHOW);開始安裝按鈕
- If $SHOW = 1 Then
- GUICtrlSetPos ( $Button_3, ($picSize_wide*0.17875), $picSize_height-$GUI_Y, 120)
- Else
- GUICtrlSetPos ( $Button_3, ($picSize_wide*0.17875), $Size[1]-$GUI_Y, 120)
- EndIf
- GUICtrlSetData ( $Button_3, "結束安裝")
- GUICtrlSetState ( $Button_4, $GUI_FOCUS)
- Case $Button_3
- Exit
- Case $Button_4
- ShellExecute (GUICtrlRead ($Input)&$exeName)
- Exit
- EndSwitch
- WEnd
- Func SetTop();設定$GUI 永久為最上層
- If $SHOW <> 2 Then
- If Not WinActive ($form1) Then WinActivate ($GUI)
- EndIf
- EndFunc
- Func WM_MOVE($hWnd, $Msg, $wParam, $lParam)
- $XY2 = WinGetPos($GUI)
- WinMove($Form1, "", $XY2[0], $XY2[1])
- EndFunc
- Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
- Switch $hWnd
- Case $form1
- Switch $iMsg
- Case $WM_NCHITTEST
- Return $HTCAPTION
- EndSwitch
- EndSwitch
- Return $GUI_RUNDEFMSG
- EndFunc
- Func Error()
- If FileExists ($ini) = 0 Then
- MsgBox ( 16,"ERROR","找不到 Install.ini ")
- Exit
- EndIf
- If FileExists ($img) = 0 Then
- MsgBox ( 16,"ERROR","找不到圖片檔")
- Exit
- EndIf
- If $SHOW = 0 Or $SHOW = 1 Then
- If Not _WinAPI_DwmIsCompositionEnabled() Then
- $SHOW = 3; 無法啟動DWM 開啟XP MOD
- EndIf
- EndIf
- If $design = "" Then $design = "噹噹"
- If $FormName = "" Or $exeName = "" Or $FileName = "" Or $DirRoute = "" Then
- MsgBox (16,"ERROR","路徑、檔名不得為空白")
- Exit
- EndIf
- EndFunc
- Func _WinAPI_DwmIsCompositionEnabled()
- Local $Ret = DllCall('dwmapi.dll', 'uint', 'DwmIsCompositionEnabled', 'int*', 0)
- If @error Then
- Return SetError(1, 0, 0)
- Else
- If $Ret[0] Then
- Return SetError(1, $Ret[0], 0)
- EndIf
- EndIf
- Return $Ret[1]
- EndFunc ;==>_WinAPI_DwmIsCompositionEnabled
- Func _WinAPI_DwmGetColorizationColor()
- Local $Ret = DllCall('dwmapi.dll', 'uint', 'DwmGetColorizationColor', 'dword*', 0, 'int*', 0)
- If @error Then
- Return SetError(1, 0, 0)
- Else
- If $Ret[0] Then
- Return SetError(1, $Ret[0], 0)
- EndIf
- EndIf
- Return SetError(0, $Ret[2], $Ret[1])
- EndFunc ;==>_WinAPI_DwmGetColorizationColor
- Func _WinAPI_UpdateLayeredWindowEx($hWnd, $hBitmap, $iOpacity = 255, $fDelete = 0)
- Local $Ret, $tSIZE, $tPOINT, $tBLENDFUNCTION, $hDC, $hDestDC, $hDestSv
- $Ret = DllCall('user32.dll', 'hwnd', 'GetDC', 'hwnd', $hWnd)
- $hDC = $Ret[0]
- $Ret = DllCall('gdi32.dll', 'hwnd', 'CreateCompatibleDC', 'hwnd', $hDC)
- $hDestDC = $Ret[0]
- $Ret = DllCall('gdi32.dll', 'hwnd', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hBitmap)
- $hDestSv = $Ret[0]
- $tSIZE = _WinAPI_GetBitmapDimension($hBitmap)
- $tPOINT = DllStructCreate($tagPOINT)
- $tBLENDFUNCTION = DllStructCreate($tagBLENDFUNCTION)
- DllStructSetData($tBLENDFUNCTION, 'Alpha', $iOpacity)
- DllStructSetData($tBLENDFUNCTION, 'Format', 1)
- $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)
- DllCall('user32.dll', 'int', 'ReleaseDC', 'hwnd', $hWnd, 'hwnd', $hDC)
- DllCall('gdi32.dll', 'ptr', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hDestSv)
- DllCall('gdi32.dll', 'int', 'DeleteDC', 'hwnd', $hDestDC)
- If Not $Ret Then
- Return SetError(1, 0, 0)
- EndIf
- If $fDelete Then
- _WinAPI_DeleteObject($hBitmap)
- EndIf
- Return 1
- EndFunc ;==>_WinAPI_UpdateLayeredWindowEx
- Func _WinAPI_GetBitmapDimension($hBitmap)
- Global Const $tagBITMAP = 'long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;'
- Local $tObj = DllStructCreate($tagBITMAP)
- Local $Ret = DllCall('gdi32.dll', 'int', 'GetObject', 'int', $hBitmap, 'int', DllStructGetSize($tObj), 'ptr', DllStructGetPtr($tObj))
- If (@error) Or (Not $Ret[0]) Then
- Return SetError(1, 0, 0)
- EndIf
- Local $tSIZE = DllStructCreate($tagSIZE)
- DllStructSetData($tSIZE, 1, DllStructGetData($tObj, 'bmWidth'))
- DllStructSetData($tSIZE, 2, DllStructGetData($tObj, 'bmHeight'))
- Return $tSIZE
- EndFunc ;==>_WinAPI_GetBitmapDimension
- Func _Vista_EnableBlurBehind ($hWnd, $Area, $bColor = 0x000000)
- $Struct = DllStructCreate ("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
- $sStruct = DllStructCreate ("dword;int;ptr;int")
- If IsArray ($Area) Then
- DllStructSetData ($Struct, "cxLeftWidth", $Area[0])
- DllStructSetData ($Struct, "cxRightWidth", $Area[1])
- DllStructSetData ($Struct, "cyTopHeight", $Area[2])
- DllStructSetData ($Struct, "cyBottomHeight", $Area[3])
- GUISetBkColor ($bColor)
- $Ret = DllCall ("dwmapi.dll", "long*", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($Struct))
- If @error Then
- Return 0
- Else
- Return $Ret
- EndIf
- Else
- MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!")
- EndIf
- EndFunc
複製代碼 |