Jump to content

DwmEnableBlurBehindWindow using DllCall


Recommended Posts

Can anyone convert this http://msdn2.microsoft.com/en-us/library/aa969508.aspx into an autoit function?

I haven't used dllcall before, but so far i think DllCall("dwmapi.dll","int","DwmEnableBlurBehindWindow","hwnd",$var,.... is right, but i don't know what follows.

Link to comment
Share on other sites

what follows is a "ptr" to a DWM_BLURBEHIND structure, which you need to DllStructCreate beforehand.

so something on the lines of

$struct = DllStructCreate("ptr")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif
DllCall("dwmapi.dll","int","DwmEnableBlurBehindWindow","hwnd",$hWnd,"prt",DllStructGetPtr($struct))

only the struct relates to:

DWORD dwFlags;

BOOL fEnable;

HRGN hRgnBlur;

BOOL fTransitionOnMaximized;

Edited by EvAsion
Link to comment
Share on other sites

only the struct relates to:

DWORD dwFlags;

BOOL fEnable;

HRGN hRgnBlur;

BOOL fTransitionOnMaximized;

Which means

$struct = DllStructCreate("dword; int; ptr; int")

And of course you'll have to set the elements of the struct with DllStructSetData, using values according to MSDN specs.

"be smart, drink your wine"

Link to comment
Share on other sites

ok this is what i've done. i'm thinking that some of the values inside the structure are wrong. Also with ptr, is null "-1","0" or "". And i'm not sure, but is fTransitionOnMaximized automatic or something because its not used in the example of this function.

$Struct = DllStructCreate("dword;int;ptr;int")
DllStructSetData($Struct,1,BitAnd("DWM_BB_ENABLE","DWM_BB_BLURREGION"))
DllStructSetData($Struct,2,"1")
DllStructSetData($Struct,3,"")
;DllStructSetData($Struct,4,"")

MsgBox(0,"DllStruct","Struct Size: " & DllStructGetSize($Struct) & @CRLF & _
        "Struct pointer: " & DllStructGetPtr($Struct) & @CRLF & _
        "Data:" & @CRLF & _
        DllStructGetData($Struct,1) & @CRLF & _
        DllStructGetData($Struct,2) & @CRLF & _
        DllStructGetData($Struct,3) & @CRLF & _
        DllStructGetData($Struct,4))
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif
DllCall("dwmapi.dll","int","DwmEnableBlurBehindWindow","hwnd",$hWnd,"prt",DllStructGetPtr($Struct))
Link to comment
Share on other sites

Const $DWM_BB_ENABLE = 0x00000001
Const $DWM_BB_BLURREGION = 0x00000002
Const $DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004

$Struct = DllStructCreate("dword;int;ptr;int")
DllStructSetData($Struct,1,BitOr($DWM_BB_ENABLE,$DWM_BB_TRANSITIONONMAXIMIZED)) ;<- to combine, use BitOr (simply + also works), not BitAnd. And of course, these are not strings you're combining.
DllStructSetData($Struct,2,1)  ;<- not a string, but int.
DllStructSetData($Struct,4,1)
DllCall("dwmapi.dll","int","DwmEnableBlurBehindWindow","hwnd",$hWnd,"ptr",DllStructGetPtr($Struct)) ; <- was a typo "prt"

Null pointer is 0 (int, not string). But since upon creation all struct elements are already initialized as 0, there's no need for DllStructSetData($Struct,3,0).

Edited by Siao

"be smart, drink your wine"

Link to comment
Share on other sites

Wow. well.. it partly works. It makes text, selections and images transparent/blurred, but not the empty space of a gui(wheres theres no controls) which was what i was assuming it would do. It also doesn't blur at the same consistency as window borders and windows media player.

Const $DWM_BB_ENABLE = 0x00000001
Const $DWM_BB_BLURREGION = 0x00000002
Const $DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004


$hWnd = WinGetHandle("Test GUI")
$Struct = DllStructCreate("dword;int;ptr;int")
DllStructSetData($Struct,1,$DWM_BB_ENABLE)
DllStructSetData($Struct,2,"1")
DllStructSetData($Struct,4,"1")
$dll = DllOpen("dwmapi.dll")
DllCall($dll,"int","DwmEnableBlurBehindWindow","hwnd",$hWnd,"ptr",DllStructGetPtr($Struct))
If @error Then
    msgbox(0,"",@error)
EndIf
DllClose($dll)
Edited by EvAsion
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...