Joined: December 26th, 2005, 4:40 pm Posts: 8776
|
Quote: GetSysColor() Usage : GetSysColor(DisplayElement)
GetSysColor() Retrieves the current color of the specified display element and returns it as RGB Hexcode. Display elements are the parts of a window and the display that appear on the system display screen.
Edit: Function has been updated - Many thanks to Mr.Laszlo
Code: GetSysColor(d_element) { A_FI:=A_FormatInteger SetFormat, Integer, Hex BGR:=DllCall("GetSysColor" ,Int,d_element)+0x1000000 SetFormat,Integer,%A_FI% StringMid,R,BGR,8,2 StringMid,G,BGR,6,2 StringMid,B,BGR,4,2 RGB := R G B StringUpper,RGB,RGB Return RGB }
MSDN Reference : GetSysColor function.
Copy / Paste / Try example:
Code: ; Example to simulate a Tooltip Window
InfoText := GetSysColor(23) ; COLOR_INFOTEXT InfoWind := GetSysColor(24) ; COLOR_INFOBK
Gui, 99:-Caption +ToolWindow +AlwaysOnTop +Border Gui, 99:Margin, 2, 2 Gui, 99:Color, %InfoWind% Gui, 99:Add, Text, c%InfoText%, This is a Simulated`nTooltip - Goyyah!
CoordMode, Mouse, Screen MouseGetPos, X, Y Gui, 99:Show, x%X% y%Y%, AHK.Simulated.Tooltip.Window
Sleep 4000 ExitApp Return
GetSysColor(d_element) { A_FI:=A_FormatInteger SetFormat, Integer, Hex BGR:=DllCall("GetSysColor" ,Int,d_element)+0x1000000 SetFormat,Integer,%A_FI% StringMid,R,BGR,8,2 StringMid,G,BGR,6,2 StringMid,B,BGR,4,2 RGB := R G B StringUpper,RGB,RGB Return RGB }
The following are the Parameters to be used with GetSysColor(). Code: COLOR_3DDKSHADOW = 21 ; Dark shadow for three-dimensional display elements.
COLOR_3DFACE = 15 ; Face color for three-dimensional display elements ; and for dialog box backgrounds.
COLOR_3DHIGHLIGHT = 20 ; Highlight color for three-dimensional display elements ; (for edges facing the light source.)
COLOR_3DHILIGHT = 20 ; Highlight color for three-dimensional display elements ; (for edges facing the light source.)
COLOR_3DLIGHT = 22 ; Light color for three-dimensional display elements ; (for edges facing the light source.)
COLOR_3DSHADOW = 16 ; Shadow color for three-dimensional display elements ; (for edges facing away from the light source).
COLOR_ACTIVEBORDER = 10 ; Active window border.
COLOR_ACTIVECAPTION = 2 ; Active window title bar. Specifies the left side color ; in the color gradient of an active window's title bar ; if the gradient effect is enabled. ; Windows NT and Windows 95: This remark does not apply.
COLOR_APPWORKSPACE = 12 ; Background color of multiple document interface ; (MDI) applications.
COLOR_BACKGROUND = 1 ; Desktop.
COLOR_BTNFACE = 15 ; Face color for three-dimensional display elements and ; for dialog box backgrounds.
COLOR_BTNHIGHLIGHT = 20 ; Highlight color for three-dimensional display elements ; (for edges facing the light source.)
COLOR_BTNHILIGHT = 20 ; Highlight color for three-dimensional display elements ; (for edges facing the light source.)
COLOR_BTNSHADOW = 16 ; Shadow color for three-dimensional display elements ; (for edges facing away from the light source). COLOR_BTNTEXT = 18 ; Text on push buttons.
COLOR_CAPTIONTEXT = 9 ; Text in caption, size box, and scroll bar arrow box.
COLOR_DESKTOP = 1 ; Desktop.
COLOR_GRADIENTACTIVECAPTION = 27 ; See comment below.
/* Right side color in the color gradient of an active window's title bar. COLOR_ACTIVECAPTION specifies the left side color. Use SPI_GETGRADIENTCAPTIONS with the SystemParametersInfo function to determine whether the gradient effect is enabled. Windows NT and Windows 95: This value is not supported. */
COLOR_GRADIENTINACTIVECAPTION = 28 ; See comment below.
/* Right side color in the color gradient of an inactive window's title bar. COLOR_INACTIVECAPTION specifies the left side color. Windows NT and Windows 95: This value is not supported. */
COLOR_GRAYTEXT = 17 ; Grayed (disabled) text. This color is set to 0 if the ; current display driver does not support a solid gray ; color.
COLOR_HIGHLIGHT = 13 ; Item(s) selected in a control.
COLOR_HIGHLIGHTTEXT = 14 ; Text of item(s) selected in a control.
COLOR_HOTLIGHT = 26 ; Color for a hyperlink or hot-tracked item. ; Windows NT & Windows 95: This value is not supported.
COLOR_INACTIVEBORDER = 11 ; Inactive window border.
COLOR_INACTIVECAPTION = 3 ; See comment below.
/* Inactive window caption. Specifies the left side color in the color gradient of an inactive window's title bar if the gradient effect is enabled. Windows NT and Windows 95: This remark does not apply. */ COLOR_INACTIVECAPTIONTEXT = 19 ; Color of text in an inactive caption.
COLOR_INFOBK = 24 ; Background color for tooltip controls.
COLOR_INFOTEXT = 23 ; Text color for tooltip controls.
COLOR_MENU = 4 ; Menu background.
COLOR_MENUHILIGHT = 29 ; See comment below.
/* The color used to highlight menu items when the menu appears as a flat menu. See SystemParametersInfo.The highlighted menu item is outlined with COLOR_HIGHLIGHT. Windows 2000/NT & Windows Me/98/95: This value is not supported. */
COLOR_MENUBAR = 30 ; See comment below.
/* The background color for the menu bar when menus appear as flat menus. See SystemParametersInfo. However, COLOR_MENU continues to specify the background color of the menu popup. Windows 2000/NT and Windows Me/98/95: This value is not supported. */
COLOR_MENUTEXT = 7 ; Text in menus.
COLOR_SCROLLBAR = 0 ; Scroll bar gray area.
COLOR_WINDOW = 5 ; Window background.
COLOR_WINDOWFRAME = 6 ; Window frame.
COLOR_WINDOWTEXT = 8 ; Text in windows.
Edit: 2006-Jul-03 : Chris has already postedQuote: Short Version: 2007-Nov-20Code: GetSysColor( Dis=1, RGB=1, Pre="" ) { Static Hex := "123456789ABCDEF0" VarSetCapacity( TMV,4,0 ), NumPut(DllCall( "GetSysColor",Int,Dis), TMV ), Ptr:=&TMV-1 Loop 3 V%A_Index% := SubStr(Hex, (*++Ptr >> 4), 1) . SubStr(Hex, (*Ptr & 15), 1) Return Pre . ( RGB ? V1 V2 V3 : V3 V2 V1 ) } If RGB is false the returned hex will be BGRPre is prefix which maybe " 0x" or " #"
_________________ URLGet - Internet Explorer based Downloader StartEx - Portable Shortcut Link
Last edited by SKAN on February 21st, 2008, 3:30 pm, edited 6 times in total.
|
|