pintas Posted May 24, 2019 Share Posted May 24, 2019 I've been trying to make a transparent splash PNG image. Looked everywhere on the forum, and every example i found doesn't seem to work anymore. Is there an 'easy' way to perform this? Link to comment Share on other sites More sharing options...
careca Posted May 24, 2019 Share Posted May 24, 2019 #include <File.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <WinAPIGdi.au3> #include <ScreenCapture.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <AutoItConstants.au3> #include <WindowsConstants.au3> Global Const $AC_SRC_ALPHA = 1 Global $GUI, $hGraphic, $hGraphic2, $hImage, $hImageR $GUI = GUICreate('IPMA', 100, 100, 300, 300, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0xABCDEF) GUISetState(@SW_SHOW, $GUI) _GDIPlus_Startup() _WinAPI_SetLayeredWindowAttributes($GUI, 0xABCDEF, 220) ;0xABCDEF 0xFFFFFF 0x000000 _SetGraphics(0, 0) Sleep(3000) Func _SetGraphics($x, $y) $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir&'\test.png') $hImageR = _GDIPlus_ImageResize($hImage, 100, 100, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) $hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($GUI) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hImageR, $x, $y, 75, 75) _GDIPlus_ImageDispose($hImage) _GDIPlus_BitmapDispose($hImageR) _GDIPlus_GraphicsDispose($hGraphic2) EndFunc ;==>_SetGraphics Nevermind the includes it was copy paste. pintas and Subz 2 Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Subz Posted May 24, 2019 Share Posted May 24, 2019 Here is another example: The following code is based upon one of the old scripts that I used years ago, just retested and it worked fine in Windows 10 x64 after a couple of modifications due to AutoIt changes: All credit Lod3n and Gary Frost expandcollapse popup#NoTrayIcon #include <GDIPlus.au3> #include <GuiComboBox.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 Global Const $ULW_ALPHA = 2 ;~ Load PNG file as GDI bitmap _GDIPlus_Startup() Global $g_sBGImage = "C:\Program Files (x86)\AutoIt3\Examples\GUI\Torus.png" Global $g_hBGImage = _GDIPlus_ImageLoadFromFile($g_sBGImage) ;~ Extract image width and height from PNG Global $g_iWidth = _GDIPlus_ImageGetWidth($g_hBGImage) Global $g_iHeight = _GDIPlus_ImageGetHeight($g_hBGImage) ;~ Create Layered Window Global $g_hMainGui = GUICreate("lod3n launcher", $g_iWidth, $g_iHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($g_hMainGui, $g_hBGImage, 255) ;~ Register Notification Messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() WinSetOnTop($g_hMainGui, "", 1) ;~ Create child MDI Gui window to hold controls Global $g_hControlGui = GUICreate("ControlGUI", $g_iWidth, $g_iHeight + 40, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $g_hMainGui) ;~ The following image just needs to be a solid colour ;~ This allows you to drag the window/image GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\Advanced\Images\Blue.bmp", 0, 0, $g_iWidth, $g_iHeight + 40) GUICtrlCreateLabel("Floating Image", 10, $g_iHeight + 10, $g_iWidth - 20, 20, $SS_CENTER) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0x000000) GUICtrlSetFont(-1, 12, 800) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete($g_hControlGui) ;~ Release Resources _WinAPI_DeleteObject($g_hBGImage) _GDIPlus_Shutdown() ; ==================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $g_hMainGui) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST ; ==================================================================================================== ; SetBitMap ; ==================================================================================================== Func SetBitmap($hGUI, $g_hBGImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_hBGImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($g_hBGImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($g_hBGImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap pintas 1 Link to comment Share on other sites More sharing options...
pintas Posted May 25, 2019 Author Share Posted May 25, 2019 3 hours ago, Subz said: Here is another example: The following code is based upon one of the old scripts that I used years ago, just retested and it worked fine in Windows 10 x64 after a couple of modifications due to AutoIt changes: All credit Lod3n and Gary Frost expandcollapse popup#NoTrayIcon #include <GDIPlus.au3> #include <GuiComboBox.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 Global Const $ULW_ALPHA = 2 ;~ Load PNG file as GDI bitmap _GDIPlus_Startup() Global $g_sBGImage = "C:\Program Files (x86)\AutoIt3\Examples\GUI\Torus.png" Global $g_hBGImage = _GDIPlus_ImageLoadFromFile($g_sBGImage) ;~ Extract image width and height from PNG Global $g_iWidth = _GDIPlus_ImageGetWidth($g_hBGImage) Global $g_iHeight = _GDIPlus_ImageGetHeight($g_hBGImage) ;~ Create Layered Window Global $g_hMainGui = GUICreate("lod3n launcher", $g_iWidth, $g_iHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($g_hMainGui, $g_hBGImage, 255) ;~ Register Notification Messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() WinSetOnTop($g_hMainGui, "", 1) ;~ Create child MDI Gui window to hold controls Global $g_hControlGui = GUICreate("ControlGUI", $g_iWidth, $g_iHeight + 40, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $g_hMainGui) ;~ The following image just needs to be a solid colour ;~ This allows you to drag the window/image GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\Advanced\Images\Blue.bmp", 0, 0, $g_iWidth, $g_iHeight + 40) GUICtrlCreateLabel("Floating Image", 10, $g_iHeight + 10, $g_iWidth - 20, 20, $SS_CENTER) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0x000000) GUICtrlSetFont(-1, 12, 800) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete($g_hControlGui) ;~ Release Resources _WinAPI_DeleteObject($g_hBGImage) _GDIPlus_Shutdown() ; ==================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $g_hMainGui) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST ; ==================================================================================================== ; SetBitMap ; ==================================================================================================== Func SetBitmap($hGUI, $g_hBGImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_hBGImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($g_hBGImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($g_hBGImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap Thanks! I actually tried this one, but couldn't fix it. Thank you both so much. This solved my problem. Link to comment Share on other sites More sharing options...
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