Rawox Posted July 17, 2009 Share Posted July 17, 2009 (edited) I tried to create an image at a transparent GUI but it doesn't work :S I am sure the file is located in the folder expandcollapse popup#include <GuiConstants.au3> #include <WindowsConstants.au3> $Title = "Test" HotKeySet("{ESC}", "QuitApp") GUICreate ( $Title, @DesktopWidth+20, @DesktopHeight+20, -10, -10, BitOr ( $DS_SETFOREGROUND, $WS_POPUPWINDOW, $WS_EX_TOPMOST ) ) GUISetBkColor ( 0x000000 ) WinSetTrans ( $Title, "", 180 ) GUISetState ( @SW_SHOW ) $Main_Gui = GUICreate("", @DesktopWidth+20, @DesktopHeight+20, -10, -10, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $But1 = GUICtrlCreateButton(" Exit ", 100, 100, 80, 21) $Logo = GUICtrlCreatePic ( @ScriptDir & "\img\logo.png", 50, 50, 300, 200 ) GUISetControlsVisible($Main_Gui) GUISetState() While 1 If GUIGetMsg() = $But1 Then Exit WEnd Func GUISetControlsVisible($hWnd) Local $aClassList, $aM_Mask, $aCtrlPos, $aMask $aClassList = StringSplit(_WinGetClassListEx($hWnd), @LF) $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0) For $i = 1 To UBound($aClassList) - 1 $aCtrlPos = ControlGetPos($hWnd, '', $aClassList[$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 Func _WinGetClassListEx($sTitle) Local $sClassList = WinGetClassList($sTitle) Local $aClassList = StringSplit($sClassList, @LF) Local $sRetClassList = "", $sHold_List = "|" Local $aiInHold, $iInHold For $i = 1 To UBound($aClassList) - 1 If $aClassList[$i] = "" Then ContinueLoop If StringRegExp($sHold_List, "\|" & $aClassList[$i] & "~(\d+)\|") Then $aiInHold = StringRegExp($sHold_List, ".*\|" & $aClassList[$i] & "~(\d+)\|.*", 1) $iInHold = Number($aiInHold[UBound($aiInHold)-1]) If $iInHold = 0 Then $iInHold += 1 $aClassList[$i] &= "~" & $iInHold + 1 $sHold_List &= $aClassList[$i] & "|" $sRetClassList &= $aClassList[$i] & @LF Else $aClassList[$i] &= "~1" $sHold_List &= $aClassList[$i] & "|" $sRetClassList &= $aClassList[$i] & @LF EndIf Next Return StringReplace(StringStripWS($sRetClassList, 3), "~", "") EndFunc Func QuitApp() Exit EndFunc Edited July 17, 2009 by Rawox Link to comment Share on other sites More sharing options...
Authenticity Posted July 17, 2009 Share Posted July 17, 2009 GUICtrlCreatePic() doesn't work with png images as far as I know but you can use Yashied's library to overcome this limitation:expandcollapse popup#include <GuiConstants.au3> #include <Icons.au3> #include <WindowsConstants.au3> $Title = "Test" HotKeySet("{ESC}", "QuitApp") $hGUI = GUICreate ($Title, @DesktopWidth+20, @DesktopHeight+20, -10, -10, BitOr($DS_SETFOREGROUND, $WS_POPUPWINDOW), $WS_EX_TOPMOST) GUISetBkColor (0x000000) WinSetTrans ($hGUI, "", 180) GUISetState () $Main_Gui = GUICreate("", @DesktopWidth+20, @DesktopHeight+20, -10, -10, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) $But1 = GUICtrlCreateButton(" Exit ", 100, 100, 80, 21) $Logo = GUICtrlCreatePic ("", 50, 50, 300, 200 ) _SetImage($Logo, @ScriptDir & "\img\logo.png") GUISetControlsVisible($Main_Gui) GUISetState() Do Until GUIGetMsg() = $But1 Func GUISetControlsVisible($hWnd) Local $aClassList, $aM_Mask, $aCtrlPos, $aMask $aClassList = StringSplit(_WinGetClassListEx($hWnd), @LF) $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0) For $i = 1 To UBound($aClassList) - 1 $aCtrlPos = ControlGetPos($hWnd, '', $aClassList[$i]) If IsArray($aCtrlPos) Then $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) EndIf Next DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aM_Mask[0], "int", 1) EndFunc Func _WinGetClassListEx($sTitle) Local $sClassList = WinGetClassList($sTitle) Local $aClassList = StringSplit($sClassList, @LF) Local $sRetClassList = "", $sHold_List = "|" Local $aiInHold, $iInHold For $i = 1 To UBound($aClassList) - 1 If $aClassList[$i] = "" Then ContinueLoop If StringRegExp($sHold_List, "\|" & $aClassList[$i] & "~(\d+)\|") Then $aiInHold = StringRegExp($sHold_List, ".*\|" & $aClassList[$i] & "~(\d+)\|.*", 1) $iInHold = Number($aiInHold[UBound($aiInHold)-1]) If $iInHold = 0 Then $iInHold += 1 $aClassList[$i] &= "~" & $iInHold + 1 $sHold_List &= $aClassList[$i] & "|" $sRetClassList &= $aClassList[$i] & @LF Else $aClassList[$i] &= "~1" $sHold_List &= $aClassList[$i] & "|" $sRetClassList &= $aClassList[$i] & @LF EndIf Next Return StringReplace(StringStripWS($sRetClassList, 3), "~", "") EndFunc Func QuitApp() Exit EndFunc Link to comment Share on other sites More sharing options...
Rawox Posted July 17, 2009 Author Share Posted July 17, 2009 (edited) Ok, It didn't made my day I am using an transparent picture, and now?? Edited July 17, 2009 by Rawox Link to comment Share on other sites More sharing options...
Authenticity Posted July 17, 2009 Share Posted July 17, 2009 (edited) Doesn't work is very dull, can you tell what you wanted to achieve and what happened instead? Edited July 17, 2009 by Authenticity Link to comment Share on other sites More sharing options...
Rawox Posted July 17, 2009 Author Share Posted July 17, 2009 Doesn't work is very dull, can you tell what you wanted to achieve and what happened instead?The example you gave me works with non-transparent pictures but I am trying to use an transparent PNG file and it doesn't show the transparency in that way, is that clear enough? Link to comment Share on other sites More sharing options...
martin Posted July 17, 2009 Share Posted July 17, 2009 The example you gave me works with non-transparent pictures but I am trying to use an transparent PNG file and it doesn't show the transparency in that way, is that clear enough? This example by Yashied might help. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Yashied Posted July 17, 2009 Share Posted July 17, 2009 Ahh it does not work, Ohh... You have not thought about that, not all will run your code. You should be more correct to ask a question. This example you can see (or find) a few days ago. Basically, everything here is what you need. expandcollapse popup#Include <GDIPlus.au3> #Include <GUIConstantsEx.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Global Const $sPng = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & '\Examples\GUI\Advanced\Images\Torus.png' _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sPng) $hMain = GUICreate('Test', 250, 250, 400, 400) GUISetBkColor(0xF0B7FD) $Button = GUICtrlCreateButton('OK', 93, 216, 70, 23) GUISetState() $hPopup = GUICreate('', 193, 184, 400 + 45 + 3, 400 + 28 + 29, BitOR($WS_DISABLED, $WS_POPUP), $WS_EX_LAYERED, $hMain) GUISetState() GUIRegisterMsg($WM_MOVE, "WM_MOVE") $Timer = TimerInit() $Trans = 255 $Direction = -1 $Step = 5 $TimeOut = 30 Do If TimerDiff($Timer) > $TimeOut Then $Trans += $Step * $Direction If $Direction > 0 Then If $Trans > 255 Then $Trans = 255 $Direction = -1 EndIf Else If $Trans < 0 Then $Trans = 0 $Direction = +1 EndIf EndIf _SetBitmap($hPopup, $hImage, $Trans) $Timer = TimerInit() EndIf Until GUIGetMsg() = -3 _GDIPlus_Shutdown() Func _SetBitmap($hWnd, $hImage, $iOpacity) 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($hWnd, $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 Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam) Switch $hWnd Case $hMain WinMove($hPopup, '', BitAND($lParam, 0xFFFF) + 45, BitShift($lParam, 16) + 28) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOVE My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Yashied Posted July 17, 2009 Share Posted July 17, 2009 This example by Yashied might help.I duplicated it here. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Rawox Posted July 17, 2009 Author Share Posted July 17, 2009 Well. I don't think I get it, but I think I have another solution for now, first I'm going to sleep. Thanks anyway You guys rock! Link to comment Share on other sites More sharing options...
Yashied Posted July 17, 2009 Share Posted July 17, 2009 I don't think I get it, but I think I have another solution for now, first I'm going to sleep.Good night. Morning wiser than the evening (or something like that). My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
martin Posted July 17, 2009 Share Posted July 17, 2009 Good night. Morning wiser than the evening (or something like that). From the last verse of "the Ryhme of the Ancient Mariner" by Samuel ColeridgeHe went like one that hath been stunned, And is of sense forlorn : A sadder and a wiser man, He rose the morrow morn. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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