nend 44 Posted April 21, 2014 (edited) How can you get the active window title bar color from win8 so I can use it as a gui background. I tryd it with _WinAPI_GetSysColor but I just can get it to work. I found this script here on this form but it wont work for me. #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Color.au3> GUICreate("My GUI", 300, 200) $button = GUICtrlCreateButton("Test", 50, 50, 75, 23) $BGR = _WinAPI_GetSysColor($COLOR_ACTIVECAPTION);Active caption is blue GUICtrlCreateLabel("", 50, 100, 100, 20) GUICtrlSetBkColor(-1, _ColorBGRToRGB($BGR)) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _ColorBGRToRGB($BGR) Local $RGB = BitShift($BGR, -16) $RGB += BitAND($BGR, 0xff00) $RGB += BitShift($BGR, 16) Return BitAND($RGB, 0xffffff) EndFunc Is there someone know how to do this? Edited April 21, 2014 by nend Share this post Link to post Share on other sites
junkew 397 Posted April 21, 2014 Metro is Direct3D based, so except for the top level window, there aren't any HWNDs involved there However maybe with below you can resolve your question You can find out the process ID of an app, using EnumProcesses. After that FindWindowEx needs to be used in a particular manner as shown below to find the window. HWND GetProcessWindow( DWORD processId ) { // Now need to run a loop to get the correct window for process. bool bFound = false; HWND prevWindow = 0; while ( ! bFound ) { HWND desktopWindow = GetDesktopWindow(); if ( ! desktopWindow ) break; HWND nextWindow = FindWindowEx( desktopWindow, prevWindow, NULL, NULL ); if ( ! nextWindow ) break; // Check whether window belongs to the correct process. DWORD procId = -1; GetWindowThreadProcessId( nextWindow, &procId ); if ( procId == processId ) { // Add additional checks. In my case, I had to bring the window to front so these checks were necessary. wchar_t windowText[ 1024 ]; if ( IsWindowVisible( nextWindow ) && ! IsIconic( nextWindow ) && GetWindowText( nextWindow, ( LPWSTR )windowText, sizeof( windowText ) / sizeof( wchar_t ) ) && ! GetParent( nextWindow ) ) return nextWindow; } prevWindow = nextWindow; } return 0; } link FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Share this post Link to post Share on other sites
nend 44 Posted April 21, 2014 (edited) Metro is Direct3D based, so except for the top level window, there aren't any HWNDs involved there However maybe with below you can resolve your question You can find out the process ID of an app, using EnumProcesses. After that FindWindowEx needs to be used in a particular manner as shown below to find the window. HWND GetProcessWindow( DWORD processId ) { // Now need to run a loop to get the correct window for process. bool bFound = false; HWND prevWindow = 0; while ( ! bFound ) { HWND desktopWindow = GetDesktopWindow(); if ( ! desktopWindow ) break; HWND nextWindow = FindWindowEx( desktopWindow, prevWindow, NULL, NULL ); if ( ! nextWindow ) break; // Check whether window belongs to the correct process. DWORD procId = -1; GetWindowThreadProcessId( nextWindow, &procId ); if ( procId == processId ) { // Add additional checks. In my case, I had to bring the window to front so these checks were necessary. wchar_t windowText[ 1024 ]; if ( IsWindowVisible( nextWindow ) && ! IsIconic( nextWindow ) && GetWindowText( nextWindow, ( LPWSTR )windowText, sizeof( windowText ) / sizeof( wchar_t ) ) && ! GetParent( nextWindow ) ) return nextWindow; } prevWindow = nextWindow; } return 0; } link Thanks for your anwser. But I don't need the metro interface but the normal windows interface. I just need the title bar background from a window, even if there are no windows open. I thought it's mabey a registry key wich I can read out? For now I use pixelgetcolor and take the color from the taskbar but this is'nt the right way to do this. When there is a transparantie used for the taskbar the color is'nt right. Edited April 21, 2014 by nend Share this post Link to post Share on other sites
junkew 397 Posted April 21, 2014 You probably need this function DwmGetColorizationColor Not sure if its defined in AutoIT api but that should not be that hard FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Share this post Link to post Share on other sites
BrewManNH 1,304 Posted April 21, 2014 Go to HKCUControl PanelColors, ActiveTitle and GradientActiveTitle are the keys you want, at least in XP/Vista/7, not sure about 8, but it's a place to look. 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 Share this post Link to post Share on other sites
nend 44 Posted April 21, 2014 You probably need this function DwmGetColorizationColor Not sure if its defined in AutoIT api but that should not be that hard After longtime searching even on the registry at the key you sugested (those are not working at win8) I found the registry key. HKEY_CURRENT_USERSoftwareMicrosoftWindowsDWM", "ColorizationColor" This one works fine for me. Thanks for your help Share this post Link to post Share on other sites