Kraggle Color Picker - high DPI friendly edition

Post your working scripts, libraries and tools for AHK v1.1 and older
thebunnyrules
Posts: 18
Joined: 29 Mar 2015, 04:31

Kraggle Color Picker - high DPI friendly edition

01 Jun 2017, 22:31

Original Script and App Written by Kraggle and Found Here:
https://autohotkey.com/board/topic/109855-color-picker/

Original Kraggle Color Picker did not support any Windows DPI over 100% and many of it's functionalities broke appart when ran even at 125%. I've modified the code so that it can run at DPIs of up to 200%.

Image

Copied from Kraggles Original post:

A Color Picker for those who are tired of opening programs like Photoshop every time they want a color
code. This not only has the capability of selecting millions of colors, but also has the convenience of
storing them for later use. After searching and only coming up with HTML Color Pickers, RGB sliders,
converters and massive programs that don't even store the colors I decided to make this one. I hope this
helps everyone else as much as it helps me.

Features

Nice looking user interface
Adjust saturation for many more colors
A halo marks where the last color was selected
Add colors through clicking on the color, or
Type the codes in to add that way
Store up to 60 colors
Change amount of storage slots for colors
Save or overwrite any slot
Show or hide saved colors
Just click to reload any saved color
Simply click to copy to clipboard
Attachments
Kraggle-Color-Picker-DPI-Edition-SOURCE.zip
(1.13 MiB) Downloaded 230 times
Kraggle-ColorPicker-DPI-friendly-x64.zip
(759.51 KiB) Downloaded 182 times
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Kraggle Color Picker - high DPI friendly edition

22 Jul 2019, 11:26

My thanks to Kraggle for the initial development of this script and to thebunnyrules for the DPI enhancement to it.

Although it's been a couple of years since this post, I only recently discovered this script. While testing it, I found two bugs that I think are worth reporting:

(1) RGB Color Copy builds up multiple RGB strings (Hex Color Copy works correctly). This is because the variable is not initialized at the CP_ClipRGB: label. The fix is this line before the Loop,3 line:

RGBCode:=""

(2) The call to enableGuiDrag occurs before ColorPicker is the active window. This can cause the script to crash, depending on where it's run from, such as this:

ColorPicker crash.png
ColorPicker crash.png (37.74 KiB) Viewed 1434 times

Finding this bug drove me bonkers. I wrote a program launcher called TrayLaunch. It runs programs via the selection of entries from the context menu of system tray icons. I never had any program fail to be launched by it...until ColorPicker! It would crash every time with the dialog shown above.

TrayLaunch was running ColorPicker from its source code, so I tried a compiled version of ColorPicker...no joy...same crash. I put in a MsgBox and determined that the reason is that both A_w and A_h are null at that point. I then put in WinGetTitle,Title,A in the enableGuiDrag function and a MsgBox showed that the active window title is also null, which is why the width and height are null.

Running the script from my file manager (Total Commander) worked fine, as did running it from Windows/File Explorer. I suspect that's why no one has reported the bug in the five years since Kraggle posted it.

Even though it worked when being launched from a file manager, the A_w and A_h values did not correspond to where ColorPicker was on the screen, but the real tell was that the active window title was the file manager, not ColorPicker. Light bulb!

My first fix for this was simple...hard-code values for A_w and A_h, since it isn't getting the ColorPicker width and height, anyway. What I really can't explain is that setting A_w=1000 and A_h=500 works, whereas setting A_w=100 and A_h=100 does not work. I don't have a clue on that one and I didn't try to figure out where the success/failure boundary is for width and height.

Anyway, then I did the real fix, which is to make sure that ColorPicker is the active window before calling enableGuiDrag, i.e., move these two lines:

enableGuiDrag("CP") ; Used to drag the window without borders
CP_Loaded := "Yes" ; Used to skip remaking the window

to AFTER the first Gui CP:Show line.

However, I still can't explain why enableGuiDrag works on the ColorPicker window even when ColorPicker is not the active window, as long as the active window (whatever it is) has an acceptable width (A_w) and height (A_h).

Modified script attached. Regards, Joe
Attachments
ColorPicker-DPI-friendly-JWfixes.ahk
ColorPicker with JW bug fixes
(21.23 KiB) Downloaded 118 times

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 60 guests