bootybay Posted November 22, 2017 Share Posted November 22, 2017 (edited) When changing the window transparency, the background transparency is completely lost. In the base example from the AutoIt Help you can move merlin across the screen without the white box around him since it's transparent. Now I wanted to add a fade in and fade out function (TransUp, TransDown) to make the example 2 a little more spooky: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $g_hGui, $g_aGuiPos, $g_hPic, $g_aPicPos, $trans = 0 Example() Func Example() $g_hGui = GUICreate("test transparentpic", 200, 100) $g_hPic = GUICreate("", 68, 71, 10, 20, $WS_POPUp, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $g_hGui) GUICtrlCreatePic("..\GUI\merlin.gif", 0, 0, 0, 0) GUISetState(@SW_SHOW, $g_hPic) GUISetState(@SW_SHOW, $g_hGui) HotKeySet("{ESC}", "Main") HotKeySet("{Left}", "Left") HotKeySet("{Right}", "Right") HotKeySet("{Down}", "Down") HotKeySet("{Up}", "Up") HotKeySet("{PGUP}", "TransUp") HotKeySet("{PGDN}", "TransDown") $g_aPicPos = WinGetPos($g_hPic) $g_aGuiPos = WinGetPos($g_hGui) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd HotKeySet("{ESC}") HotKeySet("{Left}") HotKeySet("{Right}") HotKeySet("{Down}") HotKeySet("{Up}") EndFunc ;==>Example Func Main() $g_aGuiPos = WinGetPos($g_hGui) WinMove($g_hGui, "", $g_aGuiPos[0] + 10, $g_aGuiPos[1] + 10) EndFunc ;==>Main Func Left() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0] - 10, $g_aPicPos[1]) EndFunc ;==>Left Func Right() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0] + 10, $g_aPicPos[1]) EndFunc ;==>Right Func Down() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0], $g_aPicPos[1] + 10) EndFunc ;==>Down Func Up() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0], $g_aPicPos[1] - 10) EndFunc ;==>Up Func TransUp() $trans -= 15 If $trans < 15 Then $trans = 15 If $trans > 255 Then $trans = 255 WinSetTrans($g_hPic, "", $trans) EndFunc Func TransDown() $trans += 15 If $trans < 0 Then $trans = 0 If $trans > 255 Then $trans = 255 WinSetTrans($g_hPic, "", $trans) EndFunc It fades in and out but now you see the white box around merlin. I sadly can't think of a workaround. I tried changing $g_hGUI and $g_hPic both and in different orders with no effect. This is very important to me. Please guide me! Edited November 22, 2017 by bootybay Link to comment Share on other sites More sharing options...
argumentum Posted November 24, 2017 Share Posted November 24, 2017 Try this out https://www.autoitscript.com/forum/topic/190926-solved-gdi-transparence-problem-by-image-overlapping/?do=findComment&comment=1370883 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
argumentum Posted November 25, 2017 Share Posted November 25, 2017 or... expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;~ gone to ;~ https://www.autoitscript.com/wiki/Snippets_(_GUI_)#Animate_Display ;~ for simplicity Global $g_hGui, $g_aGuiPos, $g_hPic, $g_aPicPos, $trans = 0, $iPic, $hPic Example() Func Example() $g_hGui = GUICreate("test Animate Display", 200, 100) WinSetTrans($g_hGui, "", 150) ; i know, not needed. $g_hPic = GUICreate("", 68, 71, 10, 20, $WS_POPUp, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $g_hGui) $iPic = GUICtrlCreatePic(StringLeft(@AutoItExe,StringInStr(@AutoItExe,"\", 0, -1)) & "Examples\GUI\merlin.gif",0,0,0,0) $hPic = GUICtrlGetHandle($iPic) GUISetState(@SW_SHOW, $g_hPic) GUISetState(@SW_SHOW, $g_hGui) HotKeySet("{ESC}", "Main") HotKeySet("{Left}", "Left") HotKeySet("{Right}", "Right") HotKeySet("{Down}", "Down") HotKeySet("{Up}", "Up") HotKeySet("{PGUP}", "TransUp") HotKeySet("{PGDN}", "TransDown") $g_aPicPos = WinGetPos($g_hPic) $g_aGuiPos = WinGetPos($g_hGui) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($g_hPic) GUIDelete($g_hGui) ExitLoop EndSwitch WEnd HotKeySet("{ESC}") HotKeySet("{Left}") HotKeySet("{Right}") HotKeySet("{Down}") HotKeySet("{Up}") EndFunc ;==>Example Func Main() $g_aGuiPos = WinGetPos($g_hGui) WinMove($g_hGui, "", $g_aGuiPos[0] + 10, $g_aGuiPos[1] + 10) EndFunc ;==>Main Func Left() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0] - 10, $g_aPicPos[1]) EndFunc ;==>Left Func Right() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0] + 10, $g_aPicPos[1]) EndFunc ;==>Right Func Down() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0], $g_aPicPos[1] + 10) EndFunc ;==>Down Func Up() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0], $g_aPicPos[1] - 10) EndFunc ;==>Up Func TransUp() ;~ $trans -= 15 ;~ If $trans < 15 Then $trans = 15 ;~ If $trans > 255 Then $trans = 255 ;~ WinSetTrans($g_hPic, "", $trans) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $g_hPic, "int", 1000, "long", 0x00050010) ; fade-in EndFunc Func TransDown() ;~ $trans += 15 ;~ If $trans < 0 Then $trans = 0 ;~ If $trans > 255 Then $trans = 255 ;~ WinSetTrans($g_hPic, "", $trans) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $g_hPic, "int", 1000, "long", 0x00040010) ; fade-out EndFunc junkew 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
junkew Posted November 26, 2017 Share Posted November 26, 2017 Extended @argumentum example with drag/mouse movement expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;~ gone to ;~ https://www.autoitscript.com/wiki/Snippets_(_GUI_)#Animate_Display ;~ for simplicity Global $g_hGui, $g_aGuiPos, $g_hPic, $g_aPicPos, $trans = 0, $iPic, $hPic Example() Func Example() local $dragMerlin=false $g_hGui = GUICreate("test Animate Display", 200, 100) WinSetTrans($g_hGui, "", 150) ; i know, not needed. $g_hPic = GUICreate("", 68, 71, 10, 20, $WS_POPUp, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $g_hGui) $iPic = GUICtrlCreatePic(StringLeft(@AutoItExe,StringInStr(@AutoItExe,"\", 0, -1)) & "Examples\GUI\merlin.gif",0,0,0,0) $hPic = GUICtrlGetHandle($iPic) GUISetState(@SW_SHOW, $g_hPic) GUISetState(@SW_SHOW, $g_hGui) HotKeySet("{ESC}", "Main") HotKeySet("{Left}", "Left") HotKeySet("{Right}", "Right") HotKeySet("{Down}", "Down") HotKeySet("{Up}", "Up") HotKeySet("{PGUP}", "TransUp") HotKeySet("{PGDN}", "TransDown") $g_aPicPos = WinGetPos($g_hPic) $g_aGuiPos = WinGetPos($g_hGui) ; Loop until the user exits. While 1 ;~ consolewrite(@autoitexe) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($g_hPic) GUIDelete($g_hGui) ExitLoop case $GUI_EVENT_PRIMARYDOWN $dragMerlin=True case $GUI_EVENT_MOUSEMOVE if $dragMerlin then winmove($g_hPic, "", mousegetpos(0)-32,mousegetpos(1)) EndIf case $GUI_EVENT_PRIMARYUP $dragMerlin=false EndSwitch WEnd HotKeySet("{ESC}") HotKeySet("{Left}") HotKeySet("{Right}") HotKeySet("{Down}") HotKeySet("{Up}") EndFunc ;==>Example Func Main() $g_aGuiPos = WinGetPos($g_hGui) WinMove($g_hGui, "", $g_aGuiPos[0] + 10, $g_aGuiPos[1] + 10) EndFunc ;==>Main Func Left() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0] - 10, $g_aPicPos[1]) EndFunc ;==>Left Func Right() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0] + 10, $g_aPicPos[1]) EndFunc ;==>Right Func Down() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0], $g_aPicPos[1] + 10) EndFunc ;==>Down Func Up() $g_aPicPos = WinGetPos($g_hPic) WinMove($g_hPic, "", $g_aPicPos[0], $g_aPicPos[1] - 10) EndFunc ;==>Up Func TransUp() ;~ $trans -= 15 ;~ If $trans < 15 Then $trans = 15 ;~ If $trans > 255 Then $trans = 255 ;~ WinSetTrans($g_hPic, "", $trans) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $g_hPic, "int", 1000, "long", 0x00050010) ; fade-in EndFunc Func TransDown() ;~ $trans += 15 ;~ If $trans < 0 Then $trans = 0 ;~ If $trans > 255 Then $trans = 255 ;~ WinSetTrans($g_hPic, "", $trans) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $g_hPic, "int", 1000, "long", 0x00040010) ; fade-out EndFunc FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets 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