DllCall("User32.dll", "bool", "SetProcessDPIAware") ; Get Real Screen Resolution because 4k
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>
_GDIPlus_Startup()
Global $g_hWnd = WinActivate("[CLASS:MozillaWindowClass]") ; Just Firefox with a white website
Sleep(500) ; Adjust the sleep time as necessary
Global $aWinPos = WinGetPos($g_hWnd)
Local $hGDIBmap = _ScreenCapture_Capture("", $aWinPos[0], $aWinPos[1], $aWinPos[0] + $aWinPos[2], $aWinPos[1] + $aWinPos[3]) ; Create a GDI bitmap
Local $hGDIPlusBmp = _GDIPlus_BitmapCreateFromHBITMAP($hGDIBmap) ; Convert GDI bitmap to GDI+ bitmap
_WinAPI_DeleteObject($hGDIBmap) ; Release GDI bitmap resource
; Get image dimensions
$iWidth = _GDIPlus_ImageGetWidth($hGDIPlusBmp)
$iHeight = _GDIPlus_ImageGetHeight($hGDIPlusBmp)
; Create a new GDI+ bitmap with alpha channel support
$hGDIPlusBmpNew = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
; Create Graphics from the new bitmap
$hGraphics = _GDIPlus_ImageGetGraphicsContext($hGDIPlusBmpNew)
$hIA = _GDIPlus_ImageAttributesCreate()
Global $aRemapTable[2][2]
$aRemapTable[0][0] = 1
$aRemapTable[1][0] = 0xFFFFFFFF
$aRemapTable[1][1] = 0x00000000
_GDIPlus_ImageAttributesSetRemapTable($hIA, $aRemapTable)
_GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hGDIPlusBmp, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA)
_GDIPlus_ImageAttributesDispose($hIA)
; Save the modified image as PNG with transparency
_GDIPlus_ImageSaveToFile($hGDIPlusBmpNew, @ScriptDir & "\modified_screenshot.png")
; Release resources
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_ImageDispose($hGDIPlusBmp)
_GDIPlus_ImageDispose($hGDIPlusBmpNew)
_GDIPlus_Shutdown()
works for me