WideBoyDixon Posted June 10, 2009 Posted June 10, 2009 Since color picking appears to be the hot topic, I knocked the following together to show another way that this could be done but this time for system colors. Would be great if Yashied (nudge nudge) could incorporate this into his excellent color picker! expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Misc.au3> Opt("MouseCoordMode", 2) ;Global $hWnd = GUICreate("System Colors", 200, 232, Default, Default, Default, $WS_EX_TOOLWINDOW) Global $hWnd = GUICreate("System Colors", 200, 232, Default, Default, $WS_POPUP) Global $hTip = GUICtrlGetHandle(GUICtrlCreateLabel("", 8, 200, 184, 24, _ BitOR($GUI_SS_DEFAULT_LABEL, $WS_BORDER, $SS_CENTER, $SS_CENTERIMAGE))) GUISetState() Global Const $NUMCOLORS = 36 Global $gaBrush[$NUMCOLORS] For $i = 0 To $NUMCOLORS - 1 If $i < 31 Then $gaBrush[$i] = _WinAPI_GetSysColorBrush($i) Else $gaBrush[$i] = _WinAPI_GetStockObject($WHITE_BRUSH) EndIf Next Global $gaNames[$NUMCOLORS] = ["Scrollbar", _ "Desktop", _ "Active Caption", _ "Inactive Caption", _ "Menu", _ "Window", _ "Window Frame", _ "Menu Text", _ "Window Text", _ "Caption Text", _ "Active Border", _ "Inactive Border", _ "Application Workspace", _ "Highlight", _ "Highlight Text", _ "3D Face", _ "3D Shadow", _ "Gray Text", _ "Button Text", _ "Inactive Caption Text", _ "3D Highlight", _ "3D Dark Shadow", _ "3D Light", _ "Information Text", _ "Information Background", _ "Unknown", _ "Hotlight", _ "Gradient Active Caption", _ "Gradient Inactive Caption", _ "Menu Highlight", _ "Menu Bar", _ "Unused", "Unused", "Unused", "Unused", "Unused"] Global $hDC = _WinAPI_GetDC($hWnd) Global $tRect = DllStructCreate($tagRECT) Global $hPen = _WinAPI_GetStockObject($BLACK_PEN) Global $hOldPen = _WinAPI_SelectObject($hDC, $hPen) For $i = 0 To $NUMCOLORS - 1 _DrawButton($i, True) Next Global $currentButton = -1, $mPos, $thisButton, $downButton = -2 While GUIGetMsg() <> -3 If WinActive($hWnd) Then $mPos = MouseGetPos() $thisButton = _GetButtonNumber($mPos[0], $mPos[1]) If $currentButton <> $thisButton Then If $currentButton <> -1 Then _DrawButton($currentButton, True) EndIf $currentButton = $thisButton If $thisButton >=0 Then _DrawButton($thisButton, False) _WinAPI_SetWindowText($hTip, $gaNames[$thisButton]) Else _WinAPI_SetWindowText($hTip, "") EndIf EndIf If _IsPressed("01") Then If $downButton = -2 Then $downButton = $thisButton Else If $thisButton = $downButton Then If $thisButton >= 0 Then ExitLoop EndIf $downButton = -2 EndIf Else $thisButton = -1 ExitLoop EndIf Sleep(10) WEnd _WinAPI_SelectObject($hDC, $hOldPen) _WinAPI_ReleaseDC($hWnd, $hDC) GUIDelete($hWnd) If $thisButton >= 0 Then MsgBox(64, "Selected Color", $thisButton & " : " & $gaNames[$thisButton]) EndIf Exit Func _GetButtonNumber($mouseX, $mouseY) Local $overButton = False, $x, $y, $i For $i = 0 To $NUMCOLORS - 1 $x = Mod($i, 6) * 32 + 8 $y = Int($i / 6) * 32 + 8 If $mouseX >= $x And $mouseX <= $x + 24 _ And $mouseY >= $y And $mouseY <= $y + 24 Then $overButton = True ExitLoop EndIf Next If $overButton Then Return $i Return -1 EndFunc Func _DrawButton($buttonIndex, $fSmall) Local $x = Mod($buttonIndex, 6) * 32 + 8 Local $y = Int($buttonIndex / 6) * 32 + 8 Local $hOldBrush = _WinAPI_SelectObject($hDC, $gaBrush[$buttonIndex]) If $fSmall Then DllStructSetData($tRect, 1, $x - 2) DllStructSetData($tRect, 2, $y - 2) DllStructSetData($tRect, 3, $x + 26) DllStructSetData($tRect, 4, $y + 26) _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $gaBrush[15]) DllCall("gdi32.dll", "int", "Rectangle", "hwnd", $hDC, _ "int", $x, "int", $y, "int", $x + 24, "int", $y + 24) Else DllCall("gdi32.dll", "int", "Rectangle", "hwnd", $hDC, _ "int", $x - 2, "int", $y - 2, "int", $x + 26, "int", $y + 26) EndIf _WinAPI_SelectObject($hDC, $hOldBrush) EndFunc WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
Yashied Posted June 10, 2009 Posted June 10, 2009 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
KaFu Posted June 10, 2009 Posted June 10, 2009 Hu, really nice ... I'll add it to COP too... if you don't complain .. Â OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13)Â BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16)Â ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
WideBoyDixon Posted June 10, 2009 Author Posted June 10, 2009 Any code that I post on the forum is considered by me to be "out there" and anyone can do with it as they please. I was looking again at COP the other day and started thinking about some enhancements but I don't have my notes to hand and I can't remember what they were. WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
KaFu Posted June 10, 2009 Posted June 10, 2009 Any code that I post on the forum is considered by me to be "out there" and anyone can do with it as they please. I was looking again at COP the other day and started thinking about some enhancements but I don't have my notes to hand and I can't remember what they were.Any comments are welcome , already proceeded to v 0.3.9 and currently Im trying to implement wraithdu's comments. And your function will definitly go into the next version ... Â OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13)Â BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16)Â ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
WideBoyDixon Posted June 10, 2009 Author Posted June 10, 2009 Any comments are welcome , already proceeded to v 0.3.9 and currently Im trying to implement wraithdu's comments. And your function will definitly go into the next version ... Note that it's just a prototype; it needs some work to be "release ready". For example, try hitting [Escape] when the mouse is over a color. If you need some help polishing it further then let me know and I'll help where I can. Regards, WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
Yashied Posted June 10, 2009 Posted June 10, 2009 Since color picking appears to be the hot topic, I knocked the following together to show another way that this could be done but this time for system colors. Would be great if Yashied (nudge nudge) could incorporate this into his excellent color picker!Incorporate what? In my UDF, you can define any palette itself, at its discretion. This is not a problem._GUIColorPicker_SetPalette() My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
WideBoyDixon Posted June 10, 2009 Author Posted June 10, 2009 Incorporate what? In my UDF, you can define any palette itself, at its discretion. This is not a problem._GUIColorPicker_SetPalette()I realise that but I thought it would be nice if, as well as the "Custom" button at the bottom, there could be a "System" button that allowed you to pick a system color. I'm thinking about other color picking implementations that also do this (e.g. in Visual Studio where you have "Custom", "Web" and "System"). It's not important; I may take a look at doing it myself if you don't mind?WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
Yashied Posted June 10, 2009 Posted June 10, 2009 Yes, you can play as you want. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
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