KaFu Posted November 16, 2015 Share Posted November 16, 2015 Hiho Forum :),for Win7 and Win8 _WinAPI_GetSysColor(15) seems to return the correct result for the default background color of a button. It seems this is not true for Win10 :(... can somebody with Win10 run the following sample code and post the console output? Much appreciated!Regardsexpandcollapse popup#include <Winapi.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $__Var[9] = [0, 0, 0, 0, 16385, 8388608, 1, 0, 0] For $i = 1 To 30 ConsoleWrite($i & @TAB & _WinAPI_GetSysColor($i) & @CRLF) Next GUICreate("My GUI") $c_Button = GUICtrlCreateButton("Test", 10, 10, 100, 30) GUISetState(@SW_SHOW) ConsoleWrite(@CRLF & GUICtrlGetBkColor(GUICtrlGetHandle($c_Button)) & @CRLF) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() ; #FUNCTION# ==================================================================================================================== ; Name ..........: GUICtrlGetBkColor ; Description ...: Retrieves the RGB value of the control background. ; Syntax ........: GUICtrlGetBkColor($hWnd) ; Parameters ....: $hWnd - Control ID/Handle to the control ; Return values .: Success - RGB value ; Failure - 0 ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func GUICtrlGetBkColor($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf Local $hDC = _WinAPI_GetDC($hWnd) Local $iColor = _WinAPI_GetPixel_Ex($hDC, 0, 0) _WinAPI_ReleaseDC($hWnd, $hDC) Return $iColor EndFunc ;==>GUICtrlGetBkColor Func _WinAPI_GetPixel_Ex($hDC, $iX, $iY) Local $Ret = DllCall('gdi32.dll', 'dword', 'GetPixel', 'hwnd', $hDC, 'int', $iX, 'int', $iY) If (@error) Or ($Ret[0] = 4294967295) Then Return SetError(1, 0, -1) EndIf Return __RGB_Ex($Ret[0]) EndFunc ;==>_WinAPI_GetPixel_Ex Func __RGB_Ex($iColor) If $__Var[6] Then $iColor = _WinAPI_SwitchColor_Ex($iColor) EndIf Return $iColor EndFunc ;==>__RGB_Ex Func _WinAPI_SwitchColor_Ex($iColor) Return BitOR(BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0x0000FF), -16), BitShift(BitAND($iColor, 0xFF0000), 16)) EndFunc ;==>_WinAPI_SwitchColor_Ex OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 16, 2015 Moderators Share Posted November 16, 2015 Here you go @KaFu--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop 1 0 2 13743257 3 14405055 4 15790320 5 16777215 6 6579300 7 0 8 0 9 0 10 11842740 11 16578548 12 11250603 13 16750899 14 16777215 15 15790320 16 10526880 17 7171437 18 0 19 0 20 16777215 21 6908265 22 14935011 23 0 24 14811135 25 0 26 13395456 27 15389113 28 15918295 29 16750899 30 15790320 15790320 +>10:32:28 AutoIt3.exe ended.rc:0 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
KaFu Posted November 16, 2015 Author Share Posted November 16, 2015 Now, that's strange, _WinAPI_GetSysColor(15) still seems to be the button background color, there has to be something different wrong in my script, thanks for testing! OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
KaFu Posted November 17, 2015 Author Share Posted November 17, 2015 Could anybody with Win10 re-run this and post the console output?expandcollapse popup#include <Winapi.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $__Var[9] = [0, 0, 0, 0, 16385, 8388608, 1, 0, 0] For $i = 1 To 30 ConsoleWrite($i & @TAB & _WinAPI_GetSysColor($i) & @CRLF) Next GUICreate("My GUI") $c_Button = GUICtrlCreateButton("Test", 10, 10, 100, 30) GUISetState(@SW_SHOW) ConsoleWrite(@CRLF) for $i = 0 to 10 ConsoleWrite($i & @tab & GUICtrlGetBkColorEx(GUICtrlGetHandle($c_Button),$i,$i) & @CRLF) Next While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() ; #FUNCTION# ==================================================================================================================== ; Name ..........: GUICtrlGetBkColor ; Description ...: Retrieves the RGB value of the control background. ; Syntax ........: GUICtrlGetBkColor($hWnd) ; Parameters ....: $hWnd - Control ID/Handle to the control ; Return values .: Success - RGB value ; Failure - 0 ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func GUICtrlGetBkColorEx($hWnd,$x,$y) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf Local $hDC = _WinAPI_GetDC($hWnd) Local $iColor = _WinAPI_GetPixel_Ex($hDC, $x, $y) _WinAPI_ReleaseDC($hWnd, $hDC) Return $iColor EndFunc ;==>GUICtrlGetBkColor Func _WinAPI_GetPixel_Ex($hDC, $iX, $iY) Local $Ret = DllCall('gdi32.dll', 'dword', 'GetPixel', 'hwnd', $hDC, 'int', $iX, 'int', $iY) If (@error) Or ($Ret[0] = 4294967295) Then Return SetError(1, 0, -1) EndIf Return __RGB_Ex($Ret[0]) EndFunc ;==>_WinAPI_GetPixel_Ex Func __RGB_Ex($iColor) If $__Var[6] Then $iColor = _WinAPI_SwitchColor_Ex($iColor) EndIf Return $iColor EndFunc ;==>__RGB_Ex Func _WinAPI_SwitchColor_Ex($iColor) Return BitOR(BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0x0000FF), -16), BitShift(BitAND($iColor, 0xFF0000), 16)) EndFunc ;==>_WinAPI_SwitchColor_Ex OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Trong Posted November 17, 2015 Share Posted November 17, 2015 Windows 10 x86 Pro1 02 137432573 144050554 157903205 167772156 65793007 08 09 010 1184274011 1657854812 1125060313 1675089914 1677721515 1579032016 1052688017 717143718 019 020 1677721521 690826522 1493501123 024 1481113525 026 1339545627 1538911328 1591829529 1675089930 157903200 157903201 113821892 148034253 148034254 148034255 148034256 148034257 148034258 148034259 1480342510 14803425>Exit code: 0 Time: 12.48 Regards, Link to comment Share on other sites More sharing options...
Danyfirex Posted November 17, 2015 Share Posted November 17, 2015 Hello. Here is my output. W10 x86expandcollapse popup1 0 2 13743257 3 14405055 4 15790320 5 16777215 6 6579300 7 0 8 0 9 0 10 11842740 11 16578548 12 11250603 13 16750899 14 16777215 15 15790320 16 10526880 17 7171437 18 0 19 0 20 16777215 21 6908265 22 14935011 23 0 24 14811135 25 0 26 13395456 27 15389113 28 15918295 29 16750899 30 15790320 0 15790320 1 11382189 2 14803425 3 14803425 4 14803425 5 14803425 6 14803425 7 14803425 8 14803425 9 14803425 10 14803425Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
KaFu Posted November 17, 2015 Author Share Posted November 17, 2015 So the border is still = _WinAPI_GetSysColor(15) = 15790320 ($i = 0), but the center is 14803425, damned themed buttons, have to think how to "reproduce" this...Thanks a lot for testing! OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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