xeroTechnologiesLLC Posted March 15, 2012 Share Posted March 15, 2012 (edited) I've been looking through the forums for about 3 days now, reviewing various 'transparency' methods such as parent/child GUI manipulation, etc. None of them are really TRUE transparency methods. My problem that I ran into with the parent/child gui method was that if the user defines their font to the transparency color - the font becomes transparent...the bkg to the transparency color - the program becomes entirely transparent. We tried a few other various methods recommended to make a Form, not the controls, just the form, true transparent. So far I have not found a method to do this. Unless I am searching for the wrong keywords, is there no native transparency methods in AutoIT? The current program I am attempting to develop hinges on 2 things, transparency and scrolling items in an Arc style, which I haven't figured out how to do either, so I'm just wondering if there was a direct way to do true transparency in AutoIT. And before someone perceives it as such , I do not mean this to be a bash against AutoIT, simply just asking a question. Edited April 7, 2012 by xeroTechnologiesLLC Link to comment Share on other sites More sharing options...
BrewManNH Posted March 15, 2012 Share Posted March 15, 2012 Here's one way of doing it:#include <GUIConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global Const $MainGUI = GUICreate("Media Player", 434, 434, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0x808080) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseMG") GUICtrlCreatePic("cdrom.bmp", 0, 0, 0, 0) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() While 1 Sleep(10) WEnd Func CloseMG() Exit EndFuncUse this file for the background image. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 15, 2012 Moderators Share Posted March 15, 2012 xeroTechnologiesLLC, Here are a couple of ways to make transparent GUIs. This one has visible controls: expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> $Main_Gui = GUICreate("", 400, 400, 20, 20, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $But1 = GUICtrlCreateButton(" Exit ", 100, 100, 80, 21) ; Must be within GUI window $Vol_Up_ID = GUICtrlCreateButton("Vol Up", 300, 200, 80, 30) $Vol_Dn_ID = GUICtrlCreateButton("Vol Down", 300, 230, 80, 30) GUISetControlsVisible($Main_Gui) GUISetState() While 1 If GUIGetMsg() = $But1 Then Exit WEnd Func GUISetControlsVisible($hWnd) Local $aM_Mask, $aCtrlPos, $aMask $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0) $aLastID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", GUICtrlGetHandle(-1)) For $i = 3 To $aLastID[0] $aCtrlPos = ControlGetPos($hWnd, '', $i) If Not IsArray($aCtrlPos) Then ContinueLoop $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", _ "long", $aCtrlPos[0], _ "long", $aCtrlPos[1], _ "long", $aCtrlPos[0] + $aCtrlPos[2], _ "long", $aCtrlPos[1] + $aCtrlPos[3]) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2) Next DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aM_Mask[0], "int", 1) EndFunc And this one has visible text: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> #include <sendmessage.au3> ;Global Const $LWA_ALPHA = 0x2 ;Global Const $LWA_COLORKEY = 0x1 HotKeySet("ESC", "_Exit") $hGUI = GUICreate("Test", 500, 500, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xABCDEF) GUICtrlCreateLabel("Click on the text to drag this transparent GUI" & @CRLF & "Press ESC to exit", 10, 10) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hGUI, $WM_SYSCOMMAND, 0xF012, 0) EndSwitch WEnd Func _Exit() Exit EndFunc I hope they prove useful. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
UEZ Posted March 15, 2012 Share Posted March 15, 2012 (edited) Here another example with GDI+: expandcollapse popup#include <guiconstantsex.au3> #include <windowsconstants.au3> #include <gdiplus.au3> Global $hGUI, $hImage, $hGraphic, $hImage Global Const $SC_DRAGMOVE = 0xF012 _GDIPlus_Startup() ; Load PNG image $hImage = _GDIPlus_ImageLoadFromFile(StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUITorus.png")) $iWidth = _GDIPlus_ImageGetWidth($hImage) $iHeight = _GDIPlus_ImageGetHeight($hImage) ; Create GUI $hGUI = GUICreate("Show PNG", $iWidth, $iHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST) $hGUI_child = GUICreate("", $iWidth, $iHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_MDICHILD, $hGUI) $hButton = GUICtrlCreateButton("Exit", $iWidth * 2 / 3, $iHeight * 2 / 3, 40, 40) GUISetBkColor(0xFFFFFF, $hGUI_child) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI_child) SetTransparentBitmap($hGUI, $hImage) _WinAPI_SetLayeredWindowAttributes($hGUI_child, 0xFFFFFF, 0xFF) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI_child) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2) DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hGraphic, "int", 3) _GDIPlus_GraphicsDrawString($hGraphic, "GDI+ Full Transparency", 0, $iHeight / 2 - 20, "Arial", 12) GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") GUIRegisterMsg($WM_PAINT, "WM_PAINT") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $hButton GUIRegisterMsg($WM_LBUTTONDOWN, "") GUIRegisterMsg($WM_PAINT, "") _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) ExitLoop EndSwitch WEnd Func WM_PAINT($hWnd, $msg, $wParam, $lParam) _GDIPlus_GraphicsDrawString($hGraphic, "GDI+ Full Transparency", 0, $iHeight / 2 - 20, "Arial", 12) Return "GUI_RUNDEFMSG" EndFunc Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetTransparentBitmap Tested on Win7 x64! Br, UEZ Edited March 15, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
xeroTechnologiesLLC Posted March 15, 2012 Author Share Posted March 15, 2012 /sigh/ I have so far to learn... lol So taking Melba's example: #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> $Main_Gui = GUICreate("", 400, 400, 20, 20, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $But1 = GUICtrlCreateButton(" Exit ", 100, 100, 80, 21) ; Must be within GUI window $Vol_Up_ID = GUICtrlCreateButton("Vol Up", 300, 200, 80, 30) $Vol_Dn_ID = GUICtrlCreateButton("Vol Down", 300, 230, 80, 30) GUISetControlsVisible($Main_Gui) GUISetState() While 1 If GUIGetMsg() = $But1 Then Exit WEnd Func GUISetControlsVisible($hWnd) Local $aM_Mask, $aCtrlPos, $aMask $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0) $aLastID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", GUICtrlGetHandle(-1)) For $i = 3 To $aLastID[0] $aCtrlPos = ControlGetPos($hWnd, '', $i) If Not IsArray($aCtrlPos) Then ContinueLoop $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", _ "long", $aCtrlPos[0], _ "long", $aCtrlPos[1], _ "long", $aCtrlPos[0] + $aCtrlPos[2], _ "long", $aCtrlPos[1] + $aCtrlPos[3]) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2) Next DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aM_Mask[0], "int", 1) EndFunc ..am I understanding it correctly that it's basically creating a mask over the form? I don't really get DLLCalls I guess. My math is... horrible at best so I'm not really getting the usage in it, but I will continue to research that further down the line. But if I understand this correctly... GUISetControlsVisible function will mask the form no matter the size/layout so... .. in theory if I had to use this same function on say 3 or 4 gui's in 1 program the $hWnd would go back to when i called the function and hide the appropriate form that i note in the function call...right? GUISetControlsVisible($Main_Gui) GUISetControlsVisible($Main_Gui1) GUISetControlsVisible($Main_Gui2) etc... Link to comment Share on other sites More sharing options...
xeroTechnologiesLLC Posted March 15, 2012 Author Share Posted March 15, 2012 Oh, and thank you both very much for the input - saving the examples in my code archive. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 15, 2012 Moderators Share Posted March 15, 2012 xeroTechnologiesLLC, That script is only a very rough example of how to mask the GUI that i found on the forum a long time ago - it would need a fair bit of work to get it up to a reasonable standard - a lot of the code could be much better written usine the current version of Autoit. We could probably even hide the DLL calls just for you! Using this for several GUIs in the same script woudl nto be simple - it is pretty much hardwired to a single GUI as it stands. Again it would take a fair amount of work to develop - putting controls into arrays would probably be a good place to start. But do not let me put you off - go ahead and try! You know where we are if you run into difficulties. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
xeroTechnologiesLLC Posted March 15, 2012 Author Share Posted March 15, 2012 Melba,We could probably even hide the DLL calls just for you! - putting controls into arrays would probably be a good place to start.The other main developer and I had been discussing this for some time and before I go too much further on this project we will most assuredly have to.Now for the other hard part... scrolling items in an arc. ... is the thread I started seeking help on that and I'll manage that topic there.Thank you again for all the help! Link to comment Share on other sites More sharing options...
Belini Posted March 16, 2012 Share Posted March 16, 2012 Melba23 and UEZ congratulations for codes posted, will be very helpful to me. My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ 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