If you set the GUI background colour with GUISetBkColor() and happen to forget the colour you set it as, then why not try GUIGetBkColor() Function: #include-once
#include <WinAPIGdi.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........: GUIGetBkColor
; Description ...: Retrieves the RGB value of the GUI background.
; Syntax ........: GUIGetBkColor($hWnd)
; Parameters ....: $hWnd - A handle of the GUI.
; Return values .: Success - RGB value
; Failure - 0
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func GUIGetBkColor($hWnd)
Local $iColor = 0
If IsHWnd($hWnd) Then
Local $hDC = _WinAPI_GetDC($hWnd)
$iColor = _WinAPI_GetBkColor($hDC)
_WinAPI_ReleaseDC($hWnd, $hDC)
EndIf
Return $iColor
EndFunc ;==>GUIGetBkColor
Example use of Function: #include <MsgBoxConstants.au3>
#include 'GUIGetBkColor.au3'
Example()
Func Example()
Local $hGUI = GUICreate('GUIGetBkColor() Example', 500, 350)
GUISetState(@SW_SHOW, $hGUI)
Local $aColor = [0x0000FF, 0x8FFF9F, 0xEC4841, 0xB0E35D, 0x440BFD] ; Random colour array.
Local $iColor = 0
For $i = 0 To UBound($aColor) - 1
GUISetBkColor($aColor[$i])
Sleep(20)
$iColor = GUIGetBkColor($hGUI) ; Pass the GUI handle to the function.
MsgBox($MB_SYSTEMMODAL, '', 'Background Color: ' & _ConvertToHexFormat($aColor[$i]) & @CRLF & _
'GUIGetBkColor() Hex Format: ' & _ConvertToHexFormat($iColor) & @CRLF & _
'GUIGetBkColor() Returned: ' & $iColor, 0, $hGUI)
Next
GUIDelete($hGUI)
EndFunc ;==>Example
Func _ConvertToHexFormat($iColor)
Return Hex($iColor, 6)
EndFunc ;==>_ConvertToHexFormat