nend Posted October 12, 2014 Share Posted October 12, 2014 Hello, I've use this script I found in the help file. I works greate. But.... I've I change a user on windows and go back to the user where I start this script the transparantie goes black. Before It looks like this: After it look like this: It there a sollution for this? This is the script I used: expandcollapse popup#include <APIThemeConstants.au3> #include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <WinAPIGdi.au3> #include <WinAPITheme.au3> #include <WindowsConstants.au3> If Not _WinAPI_DwmIsCompositionEnabled() Then MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.') Exit EndIf OnAutoItExitRegister('OnAutoItExit') ; Create GUI Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 240, 240) GUICtrlCreateIcon(@ScriptDir & '\Extras\Soccer.ico', 0, 88, 68, 64, 64) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel('', 70, 130, 100, 30) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState(-1, $GUI_DISABLE) Global $g_hLabel = GUICtrlGetHandle(-1) GUISetBkColor(0) ; Register label window proc Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam') Local $pDll = DllCallbackGetPtr($g_hDll) Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $pDll) ; Create the "sheet of glass" effect for the entire window. You must call this function whenever DWM composition is toggled. _WinAPI_DwmExtendFrameIntoClientArea($hForm) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _DrawText($hDC, $sText, $tRECT) ; Original idea by Authenticity Local $iWidth = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1) Local $iHeight = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2) Local $tDTTOPTS = DllStructCreate($tagDTTOPTS) DllStructSetData($tDTTOPTS, 'Size', DllStructGetSize($tDTTOPTS)) DllStructSetData($tDTTOPTS, 'Flags', BitOR($DTT_TEXTCOLOR, $DTT_GLOWSIZE, $DTT_COMPOSITED)) DllStructSetData($tDTTOPTS, 'clrText', 0x0000C0) DllStructSetData($tDTTOPTS, 'GlowSize', 12) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateDIB($iWidth, -$iHeight) Local $hSv1 = _WinAPI_SelectObject($hMemDC, $hBitmap) Local $hFont = _WinAPI_CreateFont(26, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Segoe Script') Local $hSv2 = _WinAPI_SelectObject($hMemDC, $hFont) $tRECT = _WinAPI_CreateRect(0, 0, $iWidth, $iHeight) Local $hTheme = _WinAPI_OpenThemeData($hForm, 'Globals') _WinAPI_DrawThemeTextEx($hTheme, 0, 0, $hMemDC, $sText, $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER), $tDTTOPTS) _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_CloseThemeData($hTheme) _WinAPI_SelectObject($hMemDC, $hSv1) _WinAPI_DeleteObject($hBitmap) _WinAPI_SelectObject($hMemDC, $hSv2) _WinAPI_DeleteObject($hFont) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_DrawText Func _WinProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_PAINT Local $tPAINTSTRUCT Local $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT) _DrawText($hDC, 'Soccer', _WinAPI_GetClientRect($hWnd)) _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT) Return 0 EndSwitch Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Func OnAutoItExit() _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc) DllCallbackFree($g_hDll) EndFunc ;==>OnAutoItExit Link to comment Share on other sites More sharing options...
Solution UEZ Posted October 12, 2014 Solution Share Posted October 12, 2014 (edited) Try this: expandcollapse popup#include <APIThemeConstants.au3> #include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <WinAPIGdi.au3> #include <WinAPISys.au3> #include <WinAPITheme.au3> #include <WindowsConstants.au3> If Not _WinAPI_DwmIsCompositionEnabled() Then MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.') Exit EndIf OnAutoItExitRegister('OnAutoItExit') ; Create GUI Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 240, 240) GUICtrlCreateIcon(@ScriptDir & '\Extras\Soccer.ico', 0, 88, 68, 64, 64) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel('', 70, 130, 100, 30) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState(-1, $GUI_DISABLE) Global $g_hLabel = GUICtrlGetHandle(-1) GUISetBkColor(0) ; Register label window proc Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam') Local $pDll = DllCallbackGetPtr($g_hDll) Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $pDll) ; Create the "sheet of glass" effect for the entire window. You must call this function whenever DWM composition is toggled. _WinAPI_DwmExtendFrameIntoClientArea($hForm) Local $hEventProc = DllCallbackRegister('_EventProc', 'none', 'ptr;dword;hwnd;long;long;dword;dword') Local $hEventHook = _WinAPI_SetWinEventHook($EVENT_SYSTEM_DESKTOPSWITCH, $EVENT_SYSTEM_DESKTOPSWITCH, DllCallbackGetPtr($hEventProc)) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _DrawText($hDC, $sText, $tRECT) ; Original idea by Authenticity Local $iWidth = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1) Local $iHeight = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2) Local $tDTTOPTS = DllStructCreate($tagDTTOPTS) DllStructSetData($tDTTOPTS, 'Size', DllStructGetSize($tDTTOPTS)) DllStructSetData($tDTTOPTS, 'Flags', BitOR($DTT_TEXTCOLOR, $DTT_GLOWSIZE, $DTT_COMPOSITED)) DllStructSetData($tDTTOPTS, 'clrText', 0x0000C0) DllStructSetData($tDTTOPTS, 'GlowSize', 12) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateDIB($iWidth, -$iHeight) Local $hSv1 = _WinAPI_SelectObject($hMemDC, $hBitmap) Local $hFont = _WinAPI_CreateFont(26, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Segoe Script') Local $hSv2 = _WinAPI_SelectObject($hMemDC, $hFont) $tRECT = _WinAPI_CreateRect(0, 0, $iWidth, $iHeight) Local $hTheme = _WinAPI_OpenThemeData($hForm, 'Globals') _WinAPI_DrawThemeTextEx($hTheme, 0, 0, $hMemDC, $sText, $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER), $tDTTOPTS) _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_CloseThemeData($hTheme) _WinAPI_SelectObject($hMemDC, $hSv1) _WinAPI_DeleteObject($hBitmap) _WinAPI_SelectObject($hMemDC, $hSv2) _WinAPI_DeleteObject($hFont) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_DrawText Func _WinProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_PAINT Local $tPAINTSTRUCT Local $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT) _DrawText($hDC, 'Soccer', _WinAPI_GetClientRect($hWnd)) _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT) Return 0 EndSwitch Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Func OnAutoItExit() _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc) DllCallbackFree($g_hDll) _WinAPI_UnhookWinEvent($hEventHook) DllCallbackFree($hEventProc) EndFunc ;==>OnAutoItExit Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadId, $iEventTime) #forceref $hEventHook, $iObjectID, $iChildID, $iThreadId, $iEventTime Switch $iEvent Case $EVENT_SYSTEM_DESKTOPSWITCH _WinAPI_DwmExtendFrameIntoClientArea($hForm) EndSwitch EndFunc ;==>_EventProcJust select "Switch User" and come back to your desktop. _EventProc function should be started and the class window should be repainted.Br,UEZ Edited October 12, 2014 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...
nend Posted October 13, 2014 Author Share Posted October 13, 2014 Thanks UEZ, It works perfect! 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