James Posted July 7, 2008 Posted July 7, 2008 (edited) Hi all,With lots of thanks to weaponx who showed me, StructureConstants.au3 and realised that I had my DllCall mixed up and monoceres for showing me how to create a structure, I present to you AutoIt3 and Aero Glass! Komalo for the original DWMEnableBlurBehind and BrettF for another structure issue.Four functions:_Vista_ApplyGlass($hWnd) - Applies the glass effect to the whole GUI_Vista_ApplyGlassArea($hWnd, $Area) - Applies glass to an area (array) on the GUI_Vista_EnableBlurBehind - Blurs the background of a GUI (still effects controls, need to fix)_Vista_ICE - Returns 1 if DWM is enabled, otherwise 0expandcollapse popup#include <GUIConstants.au3> $Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;") $sStruct = DllStructCreate("dword;int;ptr;int") Global $MyArea[4] = [50, 50, 50, 50] $GUI = GUICreate("Windows Vista DWM", 243, 243) $Apply = GUICtrlCreateButton("Apply", 80, 104, 83, 25, 0) $ICE = GUICtrlCreateButton("DWM Check", 80, 134, 83, 25, 0) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $Apply ;_Vista_ApplyGlass($GUI) ;_Vista_EnableBlurBehind($GUI) _Vista_EnableBlurBehind($GUI) Case $ICE If _Vista_ICE() Then MsgBox(0, "_Vista_ICE", "DWM is enabled!") Else MsgBox(0, "_Vista_ICE", "DWM is NOT enabled!") EndIf EndSwitch WEnd ; #FUNCTION#;=============================================================================== ; ; Name...........: _Vista_ApplyGlass ; Description ...: Applys glass effect to a window ; Syntax.........: _Vista_ApplyGlass($hWnd, [$bColor) ; Parameters ....: $hWnd - Window handle: ; $bColor - Background color ; Return values .: Success - No return ; Failure - Returns 0 ; Author ........: James Brooks ; Modified.......: ; Remarks .......: Thanks to weaponx! ; Related .......: ; Link ..........; ; Example .......; Yes ; ;;========================================================================================== Func _Vista_ApplyGlass($hWnd, $bColor = 0x000000) If @OSVersion <> "WIN_VISTA" Then MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!") Exit Else GUISetBkColor($bColor); Must be here! $Ret = DllCall("dwmapi.dll", "long", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "long*", DllStructGetPtr($Struct)) If @error Then Return 0 SetError(1) Else Return $Ret EndIf EndIf EndFunc ;==>_Vista_ApplyGlass ; #FUNCTION#;=============================================================================== ; ; Name...........: _Vista_ApplyGlassArea ; Description ...: Applys glass effect to a window area ; Syntax.........: _Vista_ApplyGlassArea($hWnd, $Area, [$bColor) ; Parameters ....: $hWnd - Window handle: ; $Area - Array containing area points ; $bColor - Background color ; Return values .: Success - No return ; Failure - Returns 0 ; Author ........: James Brooks ; Modified.......: ; Remarks .......: Thanks to monoceres! ; Related .......: ; Link ..........; ; Example .......; Yes ; ;;========================================================================================== Func _Vista_ApplyGlassArea($hWnd, $Area, $bColor = 0x000000) If @OSVersion <> "WIN_VISTA" Then MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!") Exit Else 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); Must be here! $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 EndIf EndFunc ;==>_Vista_ApplyGlassArea ; #FUNCTION#;=============================================================================== ; ; Name...........: _Vista_EnableBlurBehind ; Description ...: Enables the blur effect on the provided window handle. ; Syntax.........: _Vista_EnableBlurBehind($hWnd) ; Parameters ....: $hWnd - Window handle: ; Return values .: Success - No return ; Failure - Returns 0 ; Author ........: James Brooks ; Modified.......: ; Remarks .......: Thanks to komalo ; Related .......: ; Link ..........; ; Example .......; Yes ; ;;========================================================================================== Func _Vista_EnableBlurBehind($hWnd, $bColor = 0x000000) If @OSVersion <> "WIN_VISTA" Then MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!") Exit Else Const $DWM_BB_ENABLE = 0x00000001 DllStructSetData($sStruct, 1, $DWM_BB_ENABLE) DllStructSetData($sStruct, 2, "1") DllStructSetData($sStruct, 4, "1") GUISetBkColor($bColor); Must be here! $Ret = DllCall("dwmapi.dll", "int", "DwmEnableBlurBehindWindow", "hwnd", $hWnd, "ptr", DllStructGetPtr($sStruct)) If @error Then Return 0 Else Return $Ret EndIf EndIf EndFunc ;==>_Vista_EnableBlurBehind ; #FUNCTION#;=============================================================================== ; ; Name...........: _Vista_ICE ; Description ...: Returns 1 if DWM is enabled or 0 if not ; Syntax.........: _Vista_ICE() ; Parameters ....: ; Return values .: Success - Returns 1 ; Failure - Returns 0 ; Author ........: James Brooks ; Modified.......: ; Remarks .......: Thanks to BrettF ; Related .......: ; Link ..........; ; Example .......; Yes ; ;;========================================================================================== Func _Vista_ICE() $ICEStruct = DllStructCreate("int;") $Ret = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($ICEStruct)) If @error Then Return 0 Else Return DllStructGetData($ICEStruct, 1) EndIf EndFunc ;==>_Vista_ICEJames Edited August 30, 2009 by JamesBrooks mLipok 1 Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
MerkurAlex Posted July 7, 2008 Posted July 7, 2008 (edited) this line If @OSTYPE < "WIN_VISTA" Then should be If @OSTYPE <> "WIN_VISTA" Then not a big deal but i figured i would let you know muttley Edited July 7, 2008 by MerkurAlex [quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]
monoceres Posted July 7, 2008 Posted July 7, 2008 Very nice muttley I had no idea that this was possible Broken link? PM me and I'll send you the file!
Skrip Posted July 7, 2008 Posted July 7, 2008 I am on XP so this will not work..can we get a higher quality image preview, please? [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]
James Posted July 7, 2008 Author Posted July 7, 2008 this line If @OSTYPE < "WIN_VISTA" Then should be If @OSTYPE <> "WIN_VISTA" Then not a big deal but i figured i would let you know When I originally had that it wouldn't work full stop. Very nice muttley I had no idea that this was possible Heh, I have had the idea for a while, I just found how to do it I am on XP so this will not work..can we get a higher quality image preview, please?I only have Paint at the moment, the button comes out like that either way. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
James Posted July 7, 2008 Author Posted July 7, 2008 This is really nice muttley Good job Say thank you to weaponx as well Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
DexterMorgan Posted July 7, 2008 Posted July 7, 2008 Say thank you to weaponx as well muttleyI dont usually give in to peer pressure but okay... LOLThanks WeaponX code
weaponx Posted July 7, 2008 Posted July 7, 2008 I have never used Vista, but how is this different from the default look of your gui? Is it just plain by default?
James Posted July 7, 2008 Author Posted July 7, 2008 I have never used Vista, but how is this different from the default look of your gui? Is it just plain by default?No, there is like a glossy glass effect. Maybe search YouTube for some videos. I would post a screenshot, but I haven't installed Photoshop yet. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
AdmiralAlkex Posted July 7, 2008 Posted July 7, 2008 I have never used Vista, but how is this different from the default look of your gui? Is it just plain by default?If you look at his DllCall it should be obviousReturn DllCall($dll, "long", "DwmExtendFrameIntoClientArea", "hwnd",$hWnd , "long*", DllStructGetPtr($tMargins)) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
James Posted July 7, 2008 Author Posted July 7, 2008 After I have finished all the glass effects, my next job is the Task Dialogs! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
damian666 Posted July 7, 2008 Posted July 7, 2008 do you guys know this doesnt work on vista home basic? i think it needs premium or ultimate for that guys, but on my pc it looks cool muttley Damian666 and proud of it!!!
AdmiralAlkex Posted July 7, 2008 Posted July 7, 2008 (edited) do you guys know this doesnt work on vista home basic?i think it needs premium or ultimate for that guys, but on my pc it looks cool muttleyDamian666Ofcourse it DOESN'T work, whoever told you otherwise is either ignorant or stupid. (or both)Edit: And it's Home Premium that is the minimum requirement. Link1, Link2 Edited July 7, 2008 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
damian666 Posted July 7, 2008 Posted July 7, 2008 ok cool just letting you know man muttley thanx again for this nice script. damian666 and proud of it!!!
Valik Posted July 7, 2008 Posted July 7, 2008 Did you bother to think about this line of code? If Not @OSTYPE = "WIN_VISTA" Then @OSTYPE returns a string which you force to bool with the Not keyword. Since it was a non-empty string it's converted to boolean True which is then inverted producing boolean False. You then compare boolean False to the string "WIN_VISTA". As was mentioned, the correct operator is <>. Or if you're going to use Not then you need to use parenthesis to group it, although using Not is just extra code that doesn't need to exist.
James Posted July 8, 2008 Author Posted July 8, 2008 Did you bother to think about this line of code? If Not @OSTYPE = "WIN_VISTA" Then @OSTYPE returns a string which you force to bool with the Not keyword. Since it was a non-empty string it's converted to boolean True which is then inverted producing boolean False. You then compare boolean False to the string "WIN_VISTA". As was mentioned, the correct operator is <>. Or if you're going to use Not then you need to use parenthesis to group it, although using Not is just extra code that doesn't need to exist.OK, well I can change the way it checks in a snap, I just didn't think about doing it before. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
LIMITER Posted July 8, 2008 Posted July 8, 2008 Can you make only a portion to be glass and the rest to be normal, like in the picture below ? (the portion marked with red) Cheers,L|M|TER
James Posted July 8, 2008 Author Posted July 8, 2008 That is my next job muttleyTo-do:Fix client area bugFunction to select certain area(s)Add parameter to change glass colour Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
monoceres Posted July 8, 2008 Posted July 8, 2008 I just found that for me @OS_TYPE returns WIN32_NT, I am running Vista Home Premium.That is because @OS_TYPE returns the windows family the user is running, not the current version of windows.Try @OS_Version instead muttley Broken link? PM me and I'll send you the file!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now