johnmcloud Posted January 31, 2013 Share Posted January 31, 2013 If i comment out that line i can't add color to the titlebar, so what is the problem? The example is wrong? Link to comment Share on other sites More sharing options...
BrewManNH Posted January 31, 2013 Share Posted January 31, 2013 No clue what that line is supposed to be doing, but whatever it is, isn't working as expected. I was just commenting on your assertion that the dllcall was causing the problem. 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...
johnmcloud Posted January 31, 2013 Share Posted January 31, 2013 (edited) I think was DLLCall because i see the _WinAPI_SetSysColors in the autoit example. So, if it is in the autoit example must be working, and the only change to that code is the DLLCall The _WinAPI_SetSysColors without the DllCall("UxTheme.dll" etc. not work on both sistem i have tested, if i add it work but but have that strange behavior Myabe i'm wrong, i don't know, anyway don't work as expected Edited January 31, 2013 by johnmcloud Link to comment Share on other sites More sharing options...
johnmcloud Posted January 31, 2013 Share Posted January 31, 2013 (edited) Wait, i have found the error. The original post by GaryFrost have this WinAPI_SetSysColors: Func WinAPI_SetSysColors($vElements, $vColors) Local $isEArray = IsArray($vElements), $isCArray = IsArray($vColors) Local $iElementNum If Not $isCArray And Not $isEArray Then $iElementNum = 1 ElseIf $isCArray Or $isEArray Then If Not $isCArray Or Not $isEArray Then Return SetError(-1, -1, False) If UBound($vElements) <> UBound($vColors) Then Return SetError(-1, -1, False) $iElementNum = UBound($vElements) EndIf Local $tElements = DllStructCreate("int Element[" & $iElementNum & "]") Local $tColors = DllStructCreate("int NewColor[" & $iElementNum & "]") Local $pElements = DllStructGetPtr($tElements) Local $pColors = DllStructGetPtr($tColors) If Not $isEArray Then DllStructSetData($tElements, "Element", $vElements, 1) Else For $x = 0 To $iElementNum - 1 DllStructSetData($tElements, "Element", $vElements[$x], $x + 1) Next EndIf If Not $isCArray Then DllStructSetData($tColors, "NewColor", $vColors, 1) Else For $x = 0 To $iElementNum - 1 DllStructSetData($tColors, "NewColor", $vColors[$x], $x + 1) Next EndIf Local $iResults = DllCall("user32.dll", "int", "SetSysColors", "int", $iElementNum, "ptr", $pElements, "ptr", $pColors) If @error Then Return SetError(-1, -1, False) Return $iResults[0] <> 0 EndFunc ;==>_WinAPI_SetSysColors This is the _WinAPI_SetSysColor in autoit: Func _WinAPI_SetSysColors($vElements, $vColors) Local $isEArray = IsArray($vElements), $isCArray = IsArray($vColors) Local $iElementNum If Not $isCArray And Not $isEArray Then $iElementNum = 1 ElseIf $isCArray Or $isEArray Then If Not $isCArray Or Not $isEArray Then Return SetError(-1, -1, False) If UBound($vElements) <> UBound($vColors) Then Return SetError(-1, -1, False) $iElementNum = UBound($vElements) EndIf Local $tElements = DllStructCreate("int Element[" & $iElementNum & "]") Local $tColors = DllStructCreate("dword NewColor[" & $iElementNum & "]") If Not $isEArray Then DllStructSetData($tElements, "Element", $vElements, 1) Else For $x = 0 To $iElementNum - 1 DllStructSetData($tElements, "Element", $vElements[$x], $x + 1) Next EndIf If Not $isCArray Then DllStructSetData($tColors, "NewColor", $vColors, 1) Else For $x = 0 To $iElementNum - 1 DllStructSetData($tColors, "NewColor", $vColors[$x], $x + 1) Next EndIf Local $aResult = DllCall("user32.dll", "bool", "SetSysColors", "int", $iElementNum, "struct*", $tElements, "struct*", $tColors) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc ;==>_WinAPI_SetSysColors If i use the GaryFrost _GetSysColor i have the yellow notepad, but if i close the GUI everything goes to normal. It's possible to edit the GaryFrost _GetSysColor for work only on my gui instead of everyone? Anyway it's a good start at least, close the GUI remove the problem Edited January 31, 2013 by johnmcloud Link to comment Share on other sites More sharing options...
BrewManNH Posted January 31, 2013 Share Posted January 31, 2013 I only wanted to point out that you were wrong when you said the DllCall was causing the issue, when it's clear that it's not because it's been used by a lot of people before without any problem. Here's a quote from the MSDN site in regards to SetSysColorRemarksThe SetSysColors function sends a WM_SYSCOLORCHANGE message to all windows to inform them of the change in color. It also directs the system to repaint the affected portions of all currently visible windows. 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...
johnmcloud Posted January 31, 2013 Share Posted January 31, 2013 No, that was my mistake, it's not the DLLCall but the wrong _WinAPI_SetSysColor, i have just noticed Link to comment Share on other sites More sharing options...
johnmcloud Posted January 31, 2013 Share Posted January 31, 2013 Just for conclude this, the SetSysColors function sends a WM_SYSCOLORCHANGE message to all windows, right? But there isn't a way to prevent this? Maybe: 1) Usign a dummy or 2) We can't send directly the WM_SYSCOLORCHANGE to our GUI insted to use SetSysColors? So we can avoid the message to all window Do you guy think is possible or I'm delirious for the late hours? Link to comment Share on other sites More sharing options...
PhoenixXL Posted January 31, 2013 Share Posted January 31, 2013 (edited) I believe its a Bug that the colors arent changing back I did some debugging and guess what the debugging made the bug vanish (or maybe i forgot what i did ) Here is the code#include <WinAPI.au3> #include <Array.au3> #include <WindowsConstants.au3> Local $aElements[2] = [$COLOR_ACTIVECAPTION, $COLOR_WINDOW] ; Red and Yellow Local $aColors[2] = [255, 65535], $aSaveColors[2] $hGui = GUICreate("My GUI", 300, 200) $aSaveColors[0] = _WinAPI_GetSysColor($COLOR_ACTIVECAPTION) $aSaveColors[1] = _WinAPI_GetSysColor($COLOR_WINDOW) _ArrayDisplay($aSaveColors) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hGui, "wstr", 0, "wstr", 0) _WinAPI_SetSysColors($aElements, $aColors) GUISetState() Local $iTemp[2] = [_WinAPI_GetSysColor($COLOR_ACTIVECAPTION), _WinAPI_GetSysColor($COLOR_WINDOW)] _ArrayDisplay($iTemp) While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 ; $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd If _WinAPI_SetSysColors($aElements, $aSaveColors) Then MsgBox(0, 0, True) Local $iTemp[2] = [_WinAPI_GetSysColor($COLOR_ACTIVECAPTION), _WinAPI_GetSysColor($COLOR_WINDOW)] _ArrayDisplay($iTemp) This reverts the color back to normal Edited January 31, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
guinness Posted January 31, 2013 Share Posted January 31, 2013 Perhaps I missed it, but why would you need to change the titlebar colour? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
NassauSky Posted December 3, 2017 Share Posted December 3, 2017 (edited) Been a few years since this post was touched. Any chance the full code is still around. I got it to change the color of my GUI as the code above works. I just can't get the sample working where he ( @johnmcloud ) was able to change notepad's color yellow. Update: Arghhh I looked at it a bit more and realized it's changing the whole windows theme color for every cooperating windows program. I tested i by running the code above and opened notepad as the color theme was changed and noticed notepad text area was yellow. This isn't going to help me. I wanted to change an individual windows titlebar color as an alert so I tried the following: expandcollapse popup;From: https://www.autoitscript.com/forum/topic/120421-how-to-change-window-title-color/ #include <WinAPI.au3> #include <Array.au3> #include <WindowsConstants.au3> Local $aElements[2] = [$COLOR_ACTIVECAPTION, $COLOR_GRADIENTACTIVECAPTION] Local $aColors[2] = [DEC("FF"),DEC("FFFF")] ; Red and Yellow Local $aSaveColors[2] Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Run(@WindowsDir & "\Notepad.exe") Global $hGUI = WinWait("Notepad") ;$hGui = GUICreate("My GUI", 300, 200) $aSaveColors[0] = _WinAPI_GetSysColor($COLOR_ACTIVECAPTION) $aSaveColors[1] = _WinAPI_GetSysColor($COLOR_GRADIENTACTIVECAPTION) _ArrayDisplay($aSaveColors) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hGui, "wstr", 0, "wstr", 0) _WinAPI_SetSysColors($aElements, $aColors) GUISetState() Local $iTemp[2] = [_WinAPI_GetSysColor($COLOR_ACTIVECAPTION), _WinAPI_GetSysColor($COLOR_GRADIENTACTIVECAPTION)] _ArrayDisplay($iTemp) While 1 $Msg = GUIGetMsg() If NOT (WinExists($s_remoteMainTitle)) Then ;MsgBox(0,"Notice","Shutting down QbooksButtons, No remoteTitle found") ExitLoop EndIf ;~ Switch $Msg ;~ Case -3 ; $GUI_EVENT_CLOSE ;~ ExitLoop ;~ EndSwitch WEnd If _WinAPI_SetSysColors($aElements, $aSaveColors) Then MsgBox(0, 0, True) Local $iTemp[2] = [_WinAPI_GetSysColor($COLOR_ACTIVECAPTION), _WinAPI_GetSysColor($COLOR_GRADIENTACTIVECAPTION)] _ArrayDisplay($iTemp) but that didn't change notepads titlebar color. I'm still missing something so that I can just change one remote windows titlebar color. Edited December 4, 2017 by nassausky Update on research. 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