Jump to content

WinSetTrans(255) vs. SetLayeredWindowAttributes(255)


 Share

Recommended Posts

Since I don't have the source code to AutoIt's WinSetTrans(), I can't figure out what is wrong with it.  So I built a robust test rig in the hope that someone else can figure it out and perhaps fix it.

The issue "appears" to occur only when setting a window's transparency to 255 (opaque) with WinSetTrans()... (that just happens to be a somewhat common setting) . [grin]
    - Can't RETRIEVE the transparency if it was set to 255 via WinSetTrans.
    - Whereas the SetLayeredWindowAttributes() API does not display an issue in this case.

Please see the details below...

I've attached two versions of the test script... one is "clean" and very readable... the other is instrumented with a very complete set of ConsoleWrite()s that will display all of the pertinent details of the issue itself.

I've also attached two full captures of the console output - one from a WinSetTrans() run and the other from a SetLayeredWindowAttributes().  Just to save you the trouble if it helps.

Bruce
 

; #==============================================================================================================================
; IMPORTANT NOTE:
; The GLOBAL [$Which_SetTrans_to_use] is used to determine WHICH VERSION of SetTransparency to test - AutoIt's or Window's API.
;    - You test one and then test the other by resetting the GLOBAL.
; #==============================================================================================================================
;
; #==============================================================================================================================
; Also reference conversation in:
;    WinGetTrans by Valik - AutoIt General Help and Support - AutoIt Forums
;   

;;;; CLEAN VERSION ;;;;
;
; #SCRIPT# ======================================================================================================================
; Title .........: beh_TEST__Window_Transparency.au3
; AutoIt Version : 3.3.14.2
; Language ......: English
; Description ...: AutoIt's WinSetTrans() vs. SetLayeredWindowAttributes() API
; Author(s) .....: Bruce Huber
; Modified ......: 2017-06-29
; #==================================
; # D:\PortableApps\AutoIt\beh__Projects\Iterate all Windows\beh_TEST__Window_Transparency.au3
; #==============================================================================================================================
; #==============================================================================================================================
; NOTE:
; The Global [$Which_SetTrans_to_use] can be set to determine which version of SetTransparency to test - AutoIt's or Window's API.
; #==============================================================================================================================
;
; #==============================================================================================================================
;  *****  AutoIt's WinSetTrans() vs. SetLayeredWindowAttributes() API  *****
; #==============================================================================================================================
; NOTE:
;   - Both functions ALWAYS return success codes when SETTING any transparency value [0-255].
;   - Transparency = 255 ... the issue is with RETRIEVING that transparency value when ** WinSetTrans() ** was used to set it.
; #==============================================================================================================================
; # -------------------------------------------
; SetLayeredWindowAttributes() API testing ...
; # -------------------------------------------
; After setting Transparency = 255 (opaque) - { via SetLayeredWindowAttributes() API } ...
;   - RETRIEVING a window's transparency settings - { via GetLayeredWindowAttributes() API } ...
;       - !!!!! ALWAYS SUCCEEDS !!!!!
;            #= GET =====================================
;            GetLayeredWindowAttributes() errors ...
;                DllCall(GetLayeredWindowAttributes()):
;                - Last ERROR Number:   0
;                - Last ERROR Message:  The operation completed successfully.
;            -----
;            SetLayeredWindowAttributes(): Returned array of values:
;                [0000] 1
;                [0001] 0x0000000001FB1680
;                [0002] 0
;                [0003] 255                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
;                [0004] 2
;            -----
;            SetLayeredWindowAttributes(): Return code:
;                ReturnArray[3] = 255      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
;            #-------------------------------------------
; #==============================================================================================================================
; # -------------------------------------------
; AutoIt WinSetTrans() testing ...
; # -------------------------------------------
; After setting Transparency = 255 (opaque) - { via WinSetTrans() API } ...
;   - RETRIEVING a window's transparency setting of 255 - { via GetLayeredWindowAttributes() API } ...
;       - !!!!! USUALLY FAILS !!!!! ... (API Error Number = 87 - and incorrect return values).
;            #= GET =====================================
;            GetLayeredWindowAttributes() errors ...
;                DllCall(GetLayeredWindowAttributes()):
;                - Last ERROR Number:   87
;                - Last ERROR Message:  The parameter is incorrect.
;            -----
;            WinGetTrans(): Returned array of values:
;                [0000] 0
;                [0001] 0x000000000157231C
;                [0002] 0
;                [0003] 0                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
;                [0004] 0
;            -----
;            WinGetTrans(): Return code:
;                ReturnArray[3] = 0      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
;            #--------------------------------------------
; #==============================================================================================================================
; Also reference conversation in:
;   WinGetTrans by Valik - AutoIt General Help and Support - AutoIt Forums
;   https://www.autoitscript.com/forum/topic/104121-wingettrans-by-valik/


;;; ======== Includes ==============================================
#include <WinAPI.au3>
#include <WinAPIConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIProc.au3>
;;; ================================================================


;;; ======== Globals ===============================================
; Used to determine which version of SetTransparency to use - AutoIt's or Window's API.
Global Const $AUTOIT_SetTrans = 1
Global Const $API_SetTrans = 2
Global $Which_SetTrans_to_use = $API_SetTrans
;
Global $view_SleepMS = 2000         ; How long do we give someone to see the new transparency level (in millisecs)?
;;; ================================================================



TEST__Window_Transparency()



; #FUNCTION# ====================================================================================================================
; Author ........: Bruce Huber
; Modified.......:
; #==============================================================================================================================
Func TEST__Window_Transparency()
    Local $getWinLong
    Local $setWinLong
    Local $aPos
    Local $wgetRet
    Local $wsetRet
    Local $window_PID
    Local $hWnd = "No hWnd found"
    Local $aFullWinList
    Local $tmp_hWnd
    Local $i
    ; Launch a new Notepad instance.
    $window_PID = Run("notepad.exe")

    ; Wait n seconds to guarantee the creation of the new window is completed ...
    ; Otherwise, the window won't be in WinList() before we start searching for it.
    Sleep(2000)

    ; Use $window_PID to find our Notepad's window handle.
    ; RESEARCH:
    ;   ??? Should we check ONLY for Visible windows in a production app ... ???
    ;   ??? Can invisible child windows have the same PID as the parent ???
    $aFullWinList = WinList()                               ; Search the list of all windows.
    For $i = 1 To $aFullWinList[0][0]
        $tmp_hWnd = $aFullWinList[$i][1]                    ; Retrieve the handle for the next APP Window.
        If $window_PID = WinGetProcess( $tmp_hWnd) Then     ; Compare our Notepad PID to this window's PID.
            $hWnd = $tmp_hWnd                               ; Got a match ... so this is our Notepad's hWnd.
            ExitLoop                                        ; Found our hWnd ... done looking.
        EndIf
    Next
    If $hWnd = "No hWnd found" Then
        ; Terminate our window's process - (since we don't have an hWnd to close it with).
        _WinAPI_TerminateProcess($window_PID)
        Exit
    EndIf
    ;
    ;
    ; #==============================================================================================================================
    If $Which_SetTrans_to_use = $API_SetTrans Then
        ; MSDN: In order to use GetLayeredWindowAttributes() to retrieve a window's current transparency value ...
        ;
        ; ONE TIME per window:
        ;   1. Call API's GetWindowLong and SetWindowLong to set $WS_EX_LAYERED on the window.
        ;   2. Call API SetWindowPos (via AutoIt's WinMove) to make SetWindowLong take effect.
        ;       a. You don't have to actually move the window - you just have to make the call.
        ; Before making the first call to GetLayeredWindowAttributes():
        ;   3. Call SetLayeredWindowAttributes() to set the initial transparency of the window.
        ;
        ; Now free to call GetLayeredWindowAttributes() and SetLayeredWindowAttributes() as necessary.
        $getWinLong = _WinAPI_GetWindowLong ( $hWnd, $GWL_EXSTYLE )                                 ; Retrieve current Extended Window Styles.
        $getWinLong = BitOR($WS_EX_LAYERED, $getWinLong)                                            ; BitOR() those current styles with $WS_EX_LAYERED.
        $setWinLong = _WinAPI_SetWindowLong ( $hWnd, $GWL_EXSTYLE, $getWinLong )                    ; Set the window's Extended Styles with this new style value.
        ;
        beh_Center_Window( $hWnd)       ; One way to provide the WinMove() that we need to activate our SetWindowLong() settings.
        ;
        ;NOTE: Checked with Control Viewer to verify that $WS_EX_LAYERED style had been applied to the window.
    EndIf
    ; #==============================================================================================================================

    ; In the following tests of transparency SETs and GETs:
    ;   If AUTOIT's WinSetTrans() is used to set a window's transparency level = 255 ...
    ;   A following "Get" of the window's transparency settings is usually NOT successful.

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 205)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 100)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 0)              ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 175)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 255)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 183)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 255)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    ; Close the window using the handle we got from WinList().
    WinClose($hWnd)
EndFunc   ;==> TEST__Window_Transparency()


; #FUNCTION# ====================================================================================================================
; Author ........: Bruce Huber
; Modified.......:
; #==============================================================================================================================
Func beh_Win_SET_Trans($hWnd, $txt="", $transparency=255)
    Local $WinSetRet
    ;
    ;
    Select
        Case $Which_SetTrans_to_use = $AUTOIT_SetTrans
            $WinSetRet = WinSetTrans($hWnd, "", $transparency)      ;SET = [0-255]
        Case $Which_SetTrans_to_use = $API_SetTrans
            $WinSetRet = DllCall( "user32.dll" , "bool", "SetLayeredWindowAttributes", "hwnd", $hWnd, "dword", 0, "byte", $transparency, "dword", $LWA_ALPHA )
        ;Case Else
    EndSelect
    ;
    ;
    If $Which_SetTrans_to_use = $AUTOIT_SetTrans Then
        Return $WinSetRet           ; From AutoIt's WinSetTrans()
    Else
        Return $WinSetRet[0]        ; From SetLayeredWindowAttributes() API
    EndIf
EndFunc ;==> beh_Win_SET_Trans()


; #FUNCTION# ====================================================================================================================
; Author ........: Bruce Huber
; Modified.......:
; #==============================================================================================================================
Func beh_Win_GET_Trans($hWnd)
    Local $aWinGetRet
    Local $pbAlpha = 0
    Local $pdwFlags = 0
    Local $j
    ;
    ;
    $aWinGetRet = DllCall("user32.dll", "int", "GetLayeredWindowAttributes", "hwnd", $hWnd, "ulong_ptr", Null, "byte*", $pbAlpha, "dword*", $pdwFlags)
    ;
    ;
    If @error Or ($aWinGetRet[0] <> 0) Then
        Return -1               ; Error.
    Else
        Return $aWinGetRet[3]   ; Return the retrieved Window Transparency value.
    EndIf
EndFunc ;==> beh_Win_GET_Trans()


; #FUNCTION# ====================================================================================================================
; Author ........: Bruce Huber
; Modified.......:
; #==============================================================================================================================
Func beh_ConsoleWrite( $dbgTXT = "")
    ; ConsoleWrite() output needs a @CRLF appended if you want the next output on a new line in the console.
    ; I append @CRLFs here - rather than writing ConsoleWrite("literal" & @CRLF).everywhere.
    ; If you want to concatenate some outputs - just use standard ConsoleWrite() without the @CRLF.
    $dbgTXT &= @CRLF
    ConsoleWrite( $dbgTXT)
EndFunc   ;==> beh_ConsoleWrite()


; #FUNCTION# ====================================================================================================================
; Author ........: Bruce Huber
; Modified.......:
; #==============================================================================================================================
Func beh_Center_Window( $hWnd, $txt = "", $width = Default, $height = Default)
    Local $aPos
    Local $x
    Local $y
    ;
    $aPos = WinGetPos( $hWnd, $txt)
    If Not ( $width = Default) Then $aPos[2] = $width
    If Not ( $height = Default) Then $aPos[3] = $height
    $x = ( @DesktopWidth / 2) - ( $aPos[2] / 2)
    $y = ( @DesktopHeight / 2) - ( $aPos[3] / 2)
    Return WinMove( $hWnd, $txt, $x, $y, $aPos[2], $aPos[3])
EndFunc   ;==> beh_Center_Window()
;;;;; LOTS of ConsoleWrite()s version ;;;;;

; #SCRIPT# ======================================================================================================================
; Title .........: beh_TEST__Window_Transparency__(with_ConsoleWrite_results).au3
; AutoIt Version : 3.3.14.2
; Language ......: English
; Description ...: AutoIt's WinSetTrans() vs. SetLayeredWindowAttributes() API
; Author(s) .....: Bruce Huber
; Modified ......: 2017-06-29
; #==================================
; # D:\PortableApps\AutoIt\beh__Projects\Iterate all Windows\beh_TEST__Window_Transparency__(with_ConsoleWrite_results).au3
; #==============================================================================================================================
; #==============================================================================================================================
; IMPORTANT NOTE:
; The GLOBAL [$Which_SetTrans_to_use] is used to determine WHICH VERSION of SetTransparency to test - AutoIt's or Window's API.
;   - You test one and then test the other by resetting the GLOBAL.
; #==============================================================================================================================
;
; #==============================================================================================================================
;  *****  AutoIt's WinSetTrans() vs. SetLayeredWindowAttributes() API  *****
; #==============================================================================================================================
; NOTE:
;   - Both functions ALWAYS return success codes when SETTING any transparency value [0-255].
;   - Transparency = 255 ... the issue is with RETRIEVING that transparency value when ** WinSetTrans() ** was used to set it.
; #==============================================================================================================================
; # -------------------------------------------
; SetLayeredWindowAttributes() API testing ...
; # -------------------------------------------
; After setting Transparency = 255 (opaque) - { via SetLayeredWindowAttributes() API } ...
;   - RETRIEVING a window's transparency settings - { via GetLayeredWindowAttributes() API } ...
;       - !!!!! ALWAYS SUCCEEDS !!!!!
;            #= GET =====================================
;            GetLayeredWindowAttributes() errors ...
;                DllCall(GetLayeredWindowAttributes()):
;                - Last ERROR Number:   0
;                - Last ERROR Message:  The operation completed successfully.
;            -----
;            SetLayeredWindowAttributes(): Returned array of values:
;                [0000] 1
;                [0001] 0x0000000001FB1680
;                [0002] 0
;                [0003] 255                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
;                [0004] 2
;            -----
;            SetLayeredWindowAttributes(): Return code:
;                ReturnArray[3] = 255      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
;            #-------------------------------------------
; #==============================================================================================================================
; # -------------------------------------------
; AutoIt WinSetTrans() testing ...
; # -------------------------------------------
; After setting Transparency = 255 (opaque) - { via WinSetTrans() API } ...
;   - RETRIEVING a window's transparency setting of 255 - { via GetLayeredWindowAttributes() API } ...
;       - !!!!! USUALLY FAILS !!!!! ... (API Error Number = 87 - and incorrect return values).
;            #= GET =====================================
;            GetLayeredWindowAttributes() errors ...
;                DllCall(GetLayeredWindowAttributes()):
;                - Last ERROR Number:   87
;                - Last ERROR Message:  The parameter is incorrect.
;            -----
;            WinGetTrans(): Returned array of values:
;                [0000] 0
;                [0001] 0x000000000157231C
;                [0002] 0
;                [0003] 0                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
;                [0004] 0
;            -----
;            WinGetTrans(): Return code:
;                ReturnArray[3] = 0      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
;            #--------------------------------------------
; #==============================================================================================================================
; Also reference conversation in:
;   WinGetTrans by Valik - AutoIt General Help and Support - AutoIt Forums
;   https://www.autoitscript.com/forum/topic/104121-wingettrans-by-valik/


;;; ======== Includes ==============================================
#include <WinAPI.au3>
#include <WinAPIConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIProc.au3>
;;; ================================================================


;;; ======== Globals ===============================================
; Used to determine which version of SetTransparency to use - AutoIt's or Window's API.
Global Const $AUTOIT_SetTrans = 1
Global Const $API_SetTrans = 2
Global $Which_SetTrans_to_use = $AUTOIT_SetTrans
;
Global $view_SleepMS = 2000         ; How long do we give someone to see the new transparency level (in millisecs)?
;;; ================================================================



TEST__Window_Transparency()



; #FUNCTION# ====================================================================================================================
; Author ........: Bruce Huber
; Modified.......:
; #==============================================================================================================================
Func TEST__Window_Transparency()
    Local $getWinLong
    Local $setWinLong
    Local $aPos
    Local $wgetRet
    Local $wsetRet
    Local $window_PID
    Local $hWnd = "No hWnd found"
    Local $aFullWinList
    Local $tmp_hWnd
    Local $i
                            ;#D----------------------------------------------------------------------------
                            Local $dbgTXT
                            ;
                            ;;;beh_ConsoleWrite("DBGVIEWCLEAR")     ; Remember to add DBGVIEWCLEAR to your DebugView [Include] FILTER so we can clear its log window.
                            beh_ConsoleWrite("")                    ; Blank output line.
                            beh_ConsoleWrite("")                    ; Blank output line.
                            beh_ConsoleWrite("#= INIT ====================================")
                            ;#D----------------------------------------------------------------------------
    ; Launch a new Notepad instance.
    $window_PID = Run("notepad.exe")
                            ;#D----------------------------------------------------------------------------
                            $dbgTXT = "$window_PID = " & $window_PID
                            beh_ConsoleWrite($dbgTXT)
                            ;#D----------------------------------------------------------------------------

    ; Wait n seconds to guarantee the creation of the new window is completed ...
    ; Otherwise, the window won't be in WinList() before we start searching for it.
    Sleep(2000)

    ; Use $window_PID to find our Notepad's window handle.
    ; RESEARCH:
    ;   ??? Should we check ONLY for Visible windows in a production app ... ???
    ;   ??? Can invisible child windows have the same PID as the parent ???
    $aFullWinList = WinList()                               ; Search the list of all windows.
    For $i = 1 To $aFullWinList[0][0]
        $tmp_hWnd = $aFullWinList[$i][1]                    ; Retrieve the handle for the next APP Window.
        If $window_PID = WinGetProcess( $tmp_hWnd) Then     ; Compare our Notepad PID to this window's PID.
            $hWnd = $tmp_hWnd                               ; Got a match ... so this is our Notepad's hWnd.
                            ;#D----------------------------------------------------------------------------
                            $dbgTXT = "Found the window's $hWnd from its ProcessID:"
                            beh_ConsoleWrite($dbgTXT)
                            $dbgTXT = "     hWnd = " & $hWnd
                            beh_ConsoleWrite($dbgTXT)
                            ;#D----------------------------------------------------------------------------
            ExitLoop                                        ; Found our hWnd ... done looking.
        EndIf
    Next
    If $hWnd = "No hWnd found" Then
                            ;#D----------------------------------------------------------------------------
                            $dbgTXT = "Dangit! ... we ran through the whole WinList() without matching our $window_PID"
                            beh_ConsoleWrite($dbgTXT)
                            $dbgTXT = "Our Notepad instance probably took too long to show up before the Sleep() timed out."
                            beh_ConsoleWrite($dbgTXT)
                            $dbgTXT = "Exiting ..."
                            beh_ConsoleWrite($dbgTXT)
                            ;#D----------------------------------------------------------------------------
        ; Terminate our window's process - (since we don't have an hWnd to close it with).
        _WinAPI_TerminateProcess($window_PID)
        Exit
    EndIf
    ;
                            ;#D----------------------------------------------------------------------------
                            beh_ConsoleWrite("#===========================================")
                            beh_ConsoleWrite("")                    ; Blank output line.
                            beh_ConsoleWrite("")                    ; Blank output line.
                            ;#D----------------------------------------------------------------------------
    ;
    ; #==============================================================================================================================
    If $Which_SetTrans_to_use = $API_SetTrans Then
        ; MSDN: In order to use GetLayeredWindowAttributes() to retrieve a window's current transparency value ...
        ;
        ; ONE TIME per window:
        ;   1. Call API's GetWindowLong and SetWindowLong to set $WS_EX_LAYERED on the window.
        ;   2. Call API SetWindowPos (via AutoIt's WinMove) to make SetWindowLong take effect.
        ;       a. You don't have to actually move the window - you just have to make the call.
        ; Before making the first call to GetLayeredWindowAttributes():
        ;   3. Call SetLayeredWindowAttributes() to set the initial transparency of the window.
        ;
        ; Now free to call GetLayeredWindowAttributes() and SetLayeredWindowAttributes() as necessary.
                            ;#D----------------------------------------------------------------------------
                            beh_ConsoleWrite("#= SetLayeredWindowAttributes() ============")
                            ;
                            $dbgTXT = "NOTE: DOC:"
                            beh_ConsoleWrite($dbgTXT)
                            $dbgTXT = "    - GetLayeredWindowAttributes() can only be called if SetLayeredWindowAttributes() has been called on the window."
                            beh_ConsoleWrite($dbgTXT)
                            ;#D----------------------------------------------------------------------------
        $getWinLong = _WinAPI_GetWindowLong ( $hWnd, $GWL_EXSTYLE )                                 ; Retrieve current Extended Window Styles.
                            ;#D----------------------------------------------------------------------------
                            $dbgTXT = "Used GetWindowLong() to retrieve the window's Extended Styles:"
                            beh_ConsoleWrite($dbgTXT)
                            $dbgTXT = "    Return code = " & "0x" & Hex($getWinLong)
                            beh_ConsoleWrite($dbgTXT)
                            ;#D----------------------------------------------------------------------------
        $getWinLong = BitOR($WS_EX_LAYERED, $getWinLong)                                            ; BitOR() those current styles with $WS_EX_LAYERED.
                            ;#D----------------------------------------------------------------------------
                            $dbgTXT = "    BitOR($WS_EX_LAYERED, CurrentExtendedStyles) = " & "0x" & Hex($getWinLong)
                            beh_ConsoleWrite($dbgTXT)
                            ;#D----------------------------------------------------------------------------
        $setWinLong = _WinAPI_SetWindowLong ( $hWnd, $GWL_EXSTYLE, $getWinLong )                    ; Set the window's Extended Styles with this new style value.
                            ;#D----------------------------------------------------------------------------
                            $dbgTXT = "Used SetWindowLong() to make sure $WS_EX_LAYERED is set on the window:"
                            beh_ConsoleWrite($dbgTXT)
                            $dbgTXT = "    Expected return code is the set of extended styles that was in place before the SetWindowLong() ..."
                            beh_ConsoleWrite($dbgTXT)
                            $dbgTXT = "    Return code = " & "0x" & Hex($setWinLong)
                            beh_ConsoleWrite($dbgTXT)
                            ;#D----------------------------------------------------------------------------
        ;
        beh_Center_Window( $hWnd)       ; One way to provide the WinMove() that we need to activate our SetWindowLong() settings.
        ;
        ;NOTE: Checked with Control Viewer to verify that $WS_EX_LAYERED style had been applied to the window.
                            ;#D----------------------------------------------------------------------------
                            beh_ConsoleWrite("#===========================================")
                            beh_ConsoleWrite("")                    ; Blank output line.
                            beh_ConsoleWrite("")                    ; Blank output line.
                            ;#D----------------------------------------------------------------------------
    EndIf
    ; #==============================================================================================================================

    ; In the following tests of transparency SETs and GETs:
    ;   If AUTOIT's WinSetTrans() is used to set a window's transparency level = 255 ...
    ;   A following "Get" of the window's transparency settings is usually NOT successful.

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 205)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 100)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 0)              ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 175)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 255)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 183)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    $wsetRet = beh_Win_SET_Trans($hWnd, "", 255)            ;SET Transparency
    $wgetRet = beh_Win_GET_Trans($hWnd)                     ;GET
    Sleep($view_SleepMS)                                    ;... look at the window ...

    ; Close the window using the handle we got from WinList().
    WinClose($hWnd)
                        ;#D----------------------------------------------------------------------------
                        beh_ConsoleWrite("DONE ... TEST__Window_Transparency.au3")
                        ;
                        beh_ConsoleWrite("")                    ; Blank output line.
                        ;#D----------------------------------------------------------------------------
EndFunc   ;==> TEST__Window_Transparency()


; #FUNCTION# ====================================================================================================================
; Author ........: Bruce Huber
; Modified.......:
; #==============================================================================================================================
Func beh_Win_SET_Trans($hWnd, $txt="", $transparency=255)
    Local $WinSetRet
    ;
                        ;#D----------------------------------------------------------------------------
                        Local $dbgTXT
                        ;
                        beh_ConsoleWrite("#= SET =====================================")
                        ; NOTEPAD.EXE is our TEST window target ...
                        ;   So write the transparency level to its child EDIT control window.
                        ControlSetText($hWnd, "", "Edit1", $transparency & " = Transparency value")
                        ;#D----------------------------------------------------------------------------
    ;
    Select
        Case $Which_SetTrans_to_use = $AUTOIT_SetTrans
                        ;#D----------------------------------------------------------------------------
                        $dbgTXT = "** Calling AUTOIT'S WINSETTRANS() ** ... {instead of SetLayeredWindowAttributes() API}:"
                        beh_ConsoleWrite($dbgTXT)
                        ;#D----------------------------------------------------------------------------
            $WinSetRet = WinSetTrans($hWnd, "", $transparency)      ;SET = [0-255]
        Case $Which_SetTrans_to_use = $API_SetTrans
                        ;#D----------------------------------------------------------------------------
                        $dbgTXT = "** Calling SetLayeredWindowAttributes() API ** ... {instead of AutoIt's WinSetTrans()}:"
                        beh_ConsoleWrite($dbgTXT)
                        ;#D----------------------------------------------------------------------------
            $WinSetRet = DllCall( "user32.dll" , "bool", "SetLayeredWindowAttributes", "hwnd", $hWnd, "dword", 0, "byte", $transparency, "dword", $LWA_ALPHA )
        ;Case Else
    EndSelect
    ;
                        ;#D----------------------------------------------------------------------------
                        Select
                            Case $Which_SetTrans_to_use = $AUTOIT_SetTrans
                                $dbgTXT = "WinSetTrans:"
                                beh_ConsoleWrite($dbgTXT)
                                $dbgTXT = "    SET Transparency to: " & $transparency & "  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>"
                                beh_ConsoleWrite($dbgTXT)
                                $dbgTXT = "    Return code = " & $WinSetRet
                                beh_ConsoleWrite($dbgTXT)
                                $dbgTXT = "    (NOTE: WinSetTrans shows a SUCCESSFUL return code for all Transparency values of [0-255])"
                                beh_ConsoleWrite($dbgTXT)
                            Case $Which_SetTrans_to_use = $API_SetTrans
                                $dbgTXT = "SetLayeredWindowAttributes():"
                                beh_ConsoleWrite($dbgTXT)
                                $dbgTXT = "    SET Transparency to: " & $transparency & "  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>"
                                beh_ConsoleWrite($dbgTXT)
                                $dbgTXT = "    Return code = " & $WinSetRet[0]
                                beh_ConsoleWrite($dbgTXT)
                                $dbgTXT = "    (NOTE: SetLayeredWindowAttributes() shows a SUCCESSFUL return code for all Transparency values of [0-255])"
                                beh_ConsoleWrite($dbgTXT)
                            ;Case Else
                        EndSelect
                        ;#D----------------------------------------------------------------------------
    ;
    If $Which_SetTrans_to_use = $AUTOIT_SetTrans Then
        Return $WinSetRet           ; From AutoIt's WinSetTrans()
    Else
        Return $WinSetRet[0]        ; From SetLayeredWindowAttributes() API
    EndIf
EndFunc ;==> beh_Win_SET_Trans()


; #FUNCTION# ====================================================================================================================
; Author ........: Bruce Huber
; Modified.......:
; #==============================================================================================================================
Func beh_Win_GET_Trans($hWnd)
    Local $aWinGetRet
    Local $pbAlpha = 0
    Local $pdwFlags = 0
    Local $j
    ;
                        ;#D----------------------------------------------------------------------------
                        Local $dbgTXT
                        Local $gleNum           ; WinAPI Get Last Error Number
                        Local $gleMsg           ; WinAPI Get Last Error Message
                        ;
                        beh_ConsoleWrite("#= GET =====================================")
                        ;#D----------------------------------------------------------------------------
    ;
    $aWinGetRet = DllCall("user32.dll", "int", "GetLayeredWindowAttributes", "hwnd", $hWnd, "ulong_ptr", Null, "byte*", $pbAlpha, "dword*", $pdwFlags)
    ;
                        ;#D----------------------------------------------------------------------------
                        $gleNum = _WinAPI_GetLastError( )
                        $gleMsg = _WinAPI_GetLastErrorMessage( )
                        ;
                        beh_ConsoleWrite("GetLayeredWindowAttributes() errors ...")
                        ;
                        $dbgTXT = "    DllCall(GetLayeredWindowAttributes()):"
                        beh_ConsoleWrite($dbgTXT)
                        $dbgTXT = "    - Last ERROR Number:   " & $gleNum
                        beh_ConsoleWrite($dbgTXT)
                        $dbgTXT = "    - Last ERROR Message:  " & $gleMsg
                        beh_ConsoleWrite($dbgTXT)
                        ;
                        ;
                        beh_ConsoleWrite("-----")
                        If $Which_SetTrans_to_use = $AUTOIT_SetTrans Then
                            $dbgTXT = "WinGetTrans(): Returned array of values:"
                            beh_ConsoleWrite($dbgTXT)
                        Else
                            $dbgTXT = "SetLayeredWindowAttributes(): Returned array of values:"
                            beh_ConsoleWrite($dbgTXT)
                        Endif
;                       ;
                        For $j = 0 To UBound( $aWinGetRet) - 1
                            $dbgTXT = "    [" & StringFormat( "%04d", $j) & "] "
                            If $j = 1 Then
                                $dbgTXT &= "0x" & Hex($aWinGetRet[$j])      ; Returned hWnd.
                            Else
                                $dbgTXT &= $aWinGetRet[$j]
                            EndIf
                            If $j = 3 Then
                                $dbgTXT &= "                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>"
                            EndIf
                            beh_ConsoleWrite($dbgTXT)
                        Next
                        ;
                        beh_ConsoleWrite("-----")
                        If $Which_SetTrans_to_use = $AUTOIT_SetTrans Then
                            $dbgTXT = "WinGetTrans(): Return code:"
                            beh_ConsoleWrite($dbgTXT)
                        Else
                            $dbgTXT = "SetLayeredWindowAttributes(): Return code:"
                            beh_ConsoleWrite($dbgTXT)
                        Endif
                        $dbgTXT = "    ReturnArray[3] = " & $aWinGetRet[3] & "      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>"
                        beh_ConsoleWrite($dbgTXT)
                        ;
                        beh_ConsoleWrite("#===========================================")
                        beh_ConsoleWrite("")                    ; Blank output line.
                        beh_ConsoleWrite("")                    ; Blank output line.
                        ;#D----------------------------------------------------------------------------
    ;
    If @error Or ($aWinGetRet[0] <> 0) Then
        Return -1               ; Error.
    Else
        Return $aWinGetRet[3]   ; Return the retrieved Window Transparency value.
    EndIf
EndFunc ;==> beh_Win_GET_Trans()


; #FUNCTION# ====================================================================================================================
; Author ........: Bruce Huber
; Modified.......:
; #==============================================================================================================================
Func beh_ConsoleWrite( $dbgTXT = "")
    ; ConsoleWrite() output needs a @CRLF appended if you want the next output on a new line in the console.
    ; I append @CRLFs here - rather than writing ConsoleWrite("literal" & @CRLF).everywhere.
    ; If you want to concatenate some outputs - just use standard ConsoleWrite() without the @CRLF.
    $dbgTXT &= @CRLF
    ConsoleWrite( $dbgTXT)
EndFunc   ;==> beh_ConsoleWrite()


; #FUNCTION# ====================================================================================================================
; Author ........: Bruce Huber
; Modified.......:
; #==============================================================================================================================
Func beh_Center_Window( $hWnd, $txt = "", $width = Default, $height = Default)
    Local $aPos
    Local $x
    Local $y
    ;
    $aPos = WinGetPos( $hWnd, $txt)
    If Not ( $width = Default) Then $aPos[2] = $width
    If Not ( $height = Default) Then $aPos[3] = $height
    $x = ( @DesktopWidth / 2) - ( $aPos[2] / 2)
    $y = ( @DesktopHeight / 2) - ( $aPos[3] / 2)
    Return WinMove( $hWnd, $txt, $x, $y, $aPos[2], $aPos[3])
EndFunc   ;==> beh_Center_Window()

 

AutoIt WinSetTrans() test - console output.txt

>"D:\PortableApps\PortableApps\01--non-PAF--AutoIt\SciTe\..\AutoIt3.exe" "D:\PortableApps\PortableApps\01--non-PAF--AutoIt\SciTe\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "D:\PortableApps\AutoIt\beh__Projects\Iterate all Windows\beh_TEST__Window_Transparency__(with_ConsoleWrite_results).au3" /UserParams    
+>21:40:53 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0   Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => D:\PortableApps\PortableApps\01--non-PAF--AutoIt\SciTe   UserDir => D:\PortableApps\PortableApps\01--non-PAF--AutoIt\SciTe\AutoIt3Wrapper
>Running AU3Check (3.3.14.2)  from:D:\PortableApps\PortableApps\01--non-PAF--AutoIt  input:D:\PortableApps\AutoIt\beh__Projects\Iterate all Windows\beh_TEST__Window_Transparency__(with_ConsoleWrite_results).au3
+>21:40:53 AU3Check ended.rc:0
>Running:(3.3.14.2):D:\PortableApps\PortableApps\01--non-PAF--AutoIt\autoit3_x64.exe "D:\PortableApps\AutoIt\beh__Projects\Iterate all Windows\beh_TEST__Window_Transparency__(with_ConsoleWrite_results).au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop

#= INIT ====================================
$window_PID = 10448
Found the window's $hWnd from its ProcessID:
     hWnd = 0x00000000006C0DE8
#===========================================


#= SET =====================================
** Calling AUTOIT'S WINSETTRANS() ** ... {instead of SetLayeredWindowAttributes() API}:
WinSetTrans:
    SET Transparency to: 205  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: WinSetTrans shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
WinGetTrans(): Returned array of values:
    [0000] 1
    [0001] 0x00000000006C0DE8
    [0002] 0
    [0003] 205                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
WinGetTrans(): Return code:
    ReturnArray[3] = 205      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling AUTOIT'S WINSETTRANS() ** ... {instead of SetLayeredWindowAttributes() API}:
WinSetTrans:
    SET Transparency to: 100  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: WinSetTrans shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
WinGetTrans(): Returned array of values:
    [0000] 1
    [0001] 0x00000000006C0DE8
    [0002] 0
    [0003] 100                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
WinGetTrans(): Return code:
    ReturnArray[3] = 100      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling AUTOIT'S WINSETTRANS() ** ... {instead of SetLayeredWindowAttributes() API}:
WinSetTrans:
    SET Transparency to: 0  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: WinSetTrans shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
WinGetTrans(): Returned array of values:
    [0000] 1
    [0001] 0x00000000006C0DE8
    [0002] 0
    [0003] 0                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
WinGetTrans(): Return code:
    ReturnArray[3] = 0      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling AUTOIT'S WINSETTRANS() ** ... {instead of SetLayeredWindowAttributes() API}:
WinSetTrans:
    SET Transparency to: 175  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: WinSetTrans shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
WinGetTrans(): Returned array of values:
    [0000] 1
    [0001] 0x00000000006C0DE8
    [0002] 0
    [0003] 175                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
WinGetTrans(): Return code:
    ReturnArray[3] = 175      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling AUTOIT'S WINSETTRANS() ** ... {instead of SetLayeredWindowAttributes() API}:
WinSetTrans:
    SET Transparency to: 255  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: WinSetTrans shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   87
    - Last ERROR Message:  The parameter is incorrect.
-----
WinGetTrans(): Returned array of values:
    [0000] 0
    [0001] 0x00000000006C0DE8
    [0002] 0
    [0003] 0                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 0
-----
WinGetTrans(): Return code:
    ReturnArray[3] = 0      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling AUTOIT'S WINSETTRANS() ** ... {instead of SetLayeredWindowAttributes() API}:
WinSetTrans:
    SET Transparency to: 183  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: WinSetTrans shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
WinGetTrans(): Returned array of values:
    [0000] 1
    [0001] 0x00000000006C0DE8
    [0002] 0
    [0003] 183                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
WinGetTrans(): Return code:
    ReturnArray[3] = 183      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling AUTOIT'S WINSETTRANS() ** ... {instead of SetLayeredWindowAttributes() API}:
WinSetTrans:
    SET Transparency to: 255  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: WinSetTrans shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   87
    - Last ERROR Message:  The parameter is incorrect.
-----
WinGetTrans(): Returned array of values:
    [0000] 0
    [0001] 0x00000000006C0DE8
    [0002] 0
    [0003] 0                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 0
-----
WinGetTrans(): Return code:
    ReturnArray[3] = 0      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


DONE ... TEST__Window_Transparency.au3

+>21:41:09 AutoIt3.exe ended.rc:0
+>21:41:09 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 16.98

 

SetLayeredWindowAttributes() API test - console output.txt

>"D:\PortableApps\PortableApps\01--non-PAF--AutoIt\SciTe\..\AutoIt3.exe" "D:\PortableApps\PortableApps\01--non-PAF--AutoIt\SciTe\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "D:\PortableApps\AutoIt\beh__Projects\Iterate all Windows\beh_TEST__Window_Transparency__(with_ConsoleWrite_results).au3" /UserParams    
+>21:47:33 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0   Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => D:\PortableApps\PortableApps\01--non-PAF--AutoIt\SciTe   UserDir => D:\PortableApps\PortableApps\01--non-PAF--AutoIt\SciTe\AutoIt3Wrapper
>Running AU3Check (3.3.14.2)  from:D:\PortableApps\PortableApps\01--non-PAF--AutoIt  input:D:\PortableApps\AutoIt\beh__Projects\Iterate all Windows\beh_TEST__Window_Transparency__(with_ConsoleWrite_results).au3
+>21:47:33 AU3Check ended.rc:0
>Running:(3.3.14.2):D:\PortableApps\PortableApps\01--non-PAF--AutoIt\autoit3_x64.exe "D:\PortableApps\AutoIt\beh__Projects\Iterate all Windows\beh_TEST__Window_Transparency__(with_ConsoleWrite_results).au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop


#= INIT ====================================
$window_PID = 5732
Found the window's $hWnd from its ProcessID:
     hWnd = 0x00000000041C1BA8
#===========================================


#= SetLayeredWindowAttributes() ============
NOTE: DOC:
    - GetLayeredWindowAttributes() can only be called if SetLayeredWindowAttributes() has been called on the window.
Used GetWindowLong() to retrieve the window's Extended Styles:
    Return code = 0x0000000000000110
    BitOR($WS_EX_LAYERED, CurrentExtendedStyles) = 0x00080110
Used SetWindowLong() to make sure $WS_EX_LAYERED is set on the window:
    Expected return code is the set of extended styles that was in place before the SetWindowLong() ...
    Return code = 0x0000000000000110
#===========================================


#= SET =====================================
** Calling SetLayeredWindowAttributes() API ** ... {instead of AutoIt's WinSetTrans()}:
SetLayeredWindowAttributes():
    SET Transparency to: 205  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: SetLayeredWindowAttributes() shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
SetLayeredWindowAttributes(): Returned array of values:
    [0000] 1
    [0001] 0x00000000041C1BA8
    [0002] 0
    [0003] 205                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
SetLayeredWindowAttributes(): Return code:
    ReturnArray[3] = 205      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling SetLayeredWindowAttributes() API ** ... {instead of AutoIt's WinSetTrans()}:
SetLayeredWindowAttributes():
    SET Transparency to: 100  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: SetLayeredWindowAttributes() shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
SetLayeredWindowAttributes(): Returned array of values:
    [0000] 1
    [0001] 0x00000000041C1BA8
    [0002] 0
    [0003] 100                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
SetLayeredWindowAttributes(): Return code:
    ReturnArray[3] = 100      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling SetLayeredWindowAttributes() API ** ... {instead of AutoIt's WinSetTrans()}:
SetLayeredWindowAttributes():
    SET Transparency to: 0  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: SetLayeredWindowAttributes() shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
SetLayeredWindowAttributes(): Returned array of values:
    [0000] 1
    [0001] 0x00000000041C1BA8
    [0002] 0
    [0003] 0                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
SetLayeredWindowAttributes(): Return code:
    ReturnArray[3] = 0      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling SetLayeredWindowAttributes() API ** ... {instead of AutoIt's WinSetTrans()}:
SetLayeredWindowAttributes():
    SET Transparency to: 175  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: SetLayeredWindowAttributes() shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
SetLayeredWindowAttributes(): Returned array of values:
    [0000] 1
    [0001] 0x00000000041C1BA8
    [0002] 0
    [0003] 175                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
SetLayeredWindowAttributes(): Return code:
    ReturnArray[3] = 175      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling SetLayeredWindowAttributes() API ** ... {instead of AutoIt's WinSetTrans()}:
SetLayeredWindowAttributes():
    SET Transparency to: 255  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: SetLayeredWindowAttributes() shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
SetLayeredWindowAttributes(): Returned array of values:
    [0000] 1
    [0001] 0x00000000041C1BA8
    [0002] 0
    [0003] 255                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
SetLayeredWindowAttributes(): Return code:
    ReturnArray[3] = 255      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling SetLayeredWindowAttributes() API ** ... {instead of AutoIt's WinSetTrans()}:
SetLayeredWindowAttributes():
    SET Transparency to: 183  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: SetLayeredWindowAttributes() shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
SetLayeredWindowAttributes(): Returned array of values:
    [0000] 1
    [0001] 0x00000000041C1BA8
    [0002] 0
    [0003] 183                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
SetLayeredWindowAttributes(): Return code:
    ReturnArray[3] = 183      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


#= SET =====================================
** Calling SetLayeredWindowAttributes() API ** ... {instead of AutoIt's WinSetTrans()}:
SetLayeredWindowAttributes():
    SET Transparency to: 255  <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    Return code = 1
    (NOTE: SetLayeredWindowAttributes() shows a SUCCESSFUL return code for all Transparency values of [0-255])
#= GET =====================================
GetLayeredWindowAttributes() errors ...
    DllCall(GetLayeredWindowAttributes()):
    - Last ERROR Number:   0
    - Last ERROR Message:  The operation completed successfully.
-----
SetLayeredWindowAttributes(): Returned array of values:
    [0000] 1
    [0001] 0x00000000041C1BA8
    [0002] 0
    [0003] 255                <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
    [0004] 2
-----
SetLayeredWindowAttributes(): Return code:
    ReturnArray[3] = 255      <<<<<<<<<< ( TRANSPARENCY ) >>>>>>>>>>
#===========================================


DONE ... TEST__Window_Transparency.au3

+>21:47:49 AutoIt3.exe ended.rc:0
+>21:47:49 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 17

 

Edited by cbruce
Added source code in-line - (thought it was too large before)
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...