Jump to content

Recommended Posts

Posted

Goal: The modern File Explorer in Windows 11 has a Details pane and the command bar which are both Xaml Islands / WinRT / something. Due to the design of those, it is impossible to add Mica, blur or transparency to those sections of File Explorer.

There is something that I am testing. Have File Explorer running first with the Details pane open. Then run:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration

Global $aArray, $sClassName, $hWndExplorer

$aArray = WinList()
For $n = 1 To $aArray[0][0]        
    $sClassName = _WinAPI_GetClassName($aArray[$n][1])
    ; get handle for File Explorer
    If $sClassName = "CabinetWClass" Then $hWndExplorer = $aArray[$n][1]
Next

Local $hGUI = GUICreate("The external process 3", 350, 220)

Local $idButton_Add = GUICtrlCreateButton("Add $WS_EX_LAYERED and attributes" & @crlf & _
    "To DetailsPaneHwndHostClass in Explorer", 25, 40, 300, 100, 0x2000) ; $BS_MULTILINE = 0x2000

GUISetState(@SW_SHOW, $hGUI)

Local $nMsg
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop

        Case $idButton_Add
                ;Local $hControl2 = ControlGetHandle($hWndExternal, "", "[CLASS:Microsoft.UI.Content.DesktopChildSiteBridge]")
                Local $hControl = ControlGetHandle($hWndExplorer, "", "[CLASS:DetailsPaneHwndHostClass]")

                ;WinSetTrans($hControl, "", 100)

                __WinAPI_Set_Window_Style($hControl, $WS_EX_LAYERED, _
                    ($nMsg = $idButton_Add ? True : False), _ ; add or remove...
                    True) ; True = ...the extended style

                
                _WinAPI_SetLayeredWindowAttributes($hControl, 0x00191919, 120)

                Local $iTransColor, $iAlpha
                                        Local $iInfo = _WinAPI_GetLayeredWindowAttributes($hControl, $iTransColor, $iAlpha)
                                        MsgBox($MB_SYSTEMMODAL, 'Layered GUI', "Button on layered Window Clicked" & @CRLF & "Information about this window: " & @CRLF & _
                                                        "Transparent Color: " & $iTransColor & @CRLF & _
                                                        "Alpha Value: " & $iAlpha & @CRLF & _
                                                        "LWA_COLORKEY: " & (BitAND($iInfo, $LWA_COLORKEY) = $LWA_COLORKEY) & @CRLF & _
                                                        "LWA_ALPHA: " & (BitAND($iInfo, $LWA_ALPHA) = $LWA_ALPHA))
    EndSwitch
WEnd

;===========================================
Func __WinAPI_Set_Window_Style($hWnd, $i_Style, $b_Add, $b_exStyle = False) ; compacted code (from Kafu's original)

    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    Local $iIndex = $b_exStyle ? $GWL_EXSTYLE : $GWL_STYLE ; $iIndex as named by msdn & help file
    Local $i_Style_Old = _WinAPI_GetWindowLong($hWnd, $iIndex)

    If $b_Add Then
        If BitAND($i_Style_Old, $i_Style) Then Return ; style already applied
        _WinAPI_SetWindowLong($hWnd, $iIndex, BitOR($i_Style_Old, $i_Style))
    Else ; remove
        If Not BitAND($i_Style_Old, $i_Style) Then Return ; style not set
        _WinAPI_SetWindowLong($hWnd, $iIndex, BitXOR($i_Style_Old, $i_Style))
    EndIf

    Local $iRet = _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOZORDER)) ; +++
    If Not $iRet Then MsgBox($MB_TOPMOST, "_WinAPI_SetWindowPos", "Error = " & _WinAPI_GetLastError() & "   Message = " & _WinAPI_GetLastErrorMessage())

EndFunc   ;==>__WinAPI_Set_Window_Style

 

This script is modified from something that @pixelsearch shared in another thread. I am using it to add the WS_EX_LAYERED extended style to the Details pane of Explorer successfully. Then using _WinAPI_SetLayeredWindowAttributes to set some transparency.

Unfortunately it does transparency on the whole Details pane. My hope was that it would add transparency to the dark background (0x191919) and leave the text and images alone. But clearly it is more complicated.

If anybody has any ideas, please let me know. Thank you for your time.

Posted

After spending too much time on this, I am pretty convinced now that this is not going to be possible without somehow modifying the WinRT components. Unfortunately that is something that I have no experience with. So I will likely have to move on for now.

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
  • Recently Browsing   0 members

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