PasteColor

If you are currently developing portable freeware or planning to do so, use this forum to discuss technical implementation, seek out like-minded developers for partnership, or solicit interested users for beta testing.
Message
Author
billon
Posts: 842
Joined: Sat Jun 23, 2012 4:28 pm

PasteColor

#1 Post by billon »

Moderator note: this thread is split from it's original posting:


---

tproli, i don't know is that what you realy need, but may be it help you - Colors MiniLab (leelusoft.blogspot.com)-potable and stealth, and Pipette (sttmedia.com/pipette)-port'n'stealth too. Or ColorMan (cgs.vdsworld.com)-port'n'(i hope)stealth.

User avatar
tproli
Posts: 1172
Joined: Sat Sep 09, 2006 10:14 am
Location: Hungary
Contact:

Re: Portable Software that hasn't been developed?

#2 Post by tproli »

PasteColor
Color Copy Paste Tool for the Windows Color Picker
pastecolor-screenshot.png
PasteColor is a Windows color picker helper tool that helps you copy or paste color values easily.
Written in AutoIt.

More Information
Download

-----------------------------------------------

Thanks, but what I need is not a color picker. Many applications use the windows color picker and there is only a few solutions to replace it (e.g. http://www.joviancolorpicker.com/, but it's payware).

I can get a color by shift-clicking on a pixel in IrfanView. That puts the color in hex format in the clipboard. I would like to use this color data to quickly paste in the standard windows color picker (which has no option to input the hex color format).
Last edited by tproli on Tue May 07, 2013 1:12 pm, edited 5 times in total.

User avatar
tproli
Posts: 1172
Joined: Sat Sep 09, 2006 10:14 am
Location: Hungary
Contact:

Re: Portable Software that hasn't been developed?

#3 Post by tproli »

Update: I had some time to play and PasteColor (wip name) is in alpha/beta version:

http://rolandtoth.hu/files/PasteColor.zip

I got an issue with StringRegExp, I cannot make [:xdigit:] work properly. I needed to ensure that clipboard contents has only hex values (0-9, a-f, A-F), and if it is not the case, show an error message.

Code: Select all

Local $array = StringRegExp($color, '^[0-9a-fA-F]+$', 1)

If @error = 2 Then
    ShowError()
EndIf
If someone could look at it that would be great. The zip contains the source file, there you can see this in 46-50 (commented out).

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: Portable Software that hasn't been developed?

#4 Post by guinness »

AutoIt? I will have a look.

Edit: Is this what you are looking for >> http://www.autoitscript.com/forum/topic ... r-picking/

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: Portable Software that hasn't been developed?

#5 Post by guinness »

Sorry but why not use StringIsXDigit?

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: Portable Software that hasn't been developed?

#6 Post by guinness »

And here is the update to your SRE.

Code: Select all

ConsoleWrite('Return: ' & _IsHexColor('FF00FF') & @CRLF)
ConsoleWrite('Return: ' & _IsHexColor('FF00HH') & @CRLF)

Func _IsHexColor($bColor) ; By guinness, Returns True or False.
	Return (StringRegExp($bColor, '[0-9a-fA-F]{6}', 0) = 1 And StringLen($bColor) = 6)
EndFunc   ;==>_IsHexColor

User avatar
tproli
Posts: 1172
Joined: Sat Sep 09, 2006 10:14 am
Location: Hungary
Contact:

Re: Portable Software that hasn't been developed?

#7 Post by tproli »

StringXDigit could have been useful if I had known about it :)

Finally I used this:

Code: Select all

If StringRegExp($color, '\b[0-9a-fA-F]{6}\b', 0) = 0 Then
        ShowError()
    EndIf
The word boundaries ("\b") seems to eliminate the need of StringLen.

Thanks for your help!

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: Portable Software that hasn't been developed?

#8 Post by guinness »

I would say StringIsXDigit is a better option though. Oh, forgot about /b, SREs are tricky little things as you know, good thing they are universal in most programming languages, so you don't need to re-learn everytime.

User avatar
tproli
Posts: 1172
Joined: Sat Sep 09, 2006 10:14 am
Location: Hungary
Contact:

Re: Portable Software that hasn't been developed?

#9 Post by tproli »

I wonder if something like this would be possible to do in AutoIt:

Image

That is, an "extension" to the standard Windows color picker, that has two options: copy current color (from the Red-Green-Blue input fields), and to paste color on clipboard (if any). This would require the application to run in the background and be shown only if the color picker is visible - this can be tricky because it is not a separate application. I tried to figure out a unique handler for the color picker but with no success, they were different in different applications. This doesn't mean there's no such thing though :)

I also wonder why aren't these features built-in to the OS.

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: Portable Software that hasn't been developed?

#10 Post by guinness »

Why not have a look at _ChooseColor in the help file.

User avatar
tproli
Posts: 1172
Joined: Sat Sep 09, 2006 10:14 am
Location: Hungary
Contact:

Re: Portable Software that hasn't been developed?

#11 Post by tproli »

I don't think you got it. There are applications that use the built-in windows color picker. There's no way to change it.

Think about customizing color in applications, e.g. the font color in Total Commander:

Image

In such cases you don't have an option to use a 3rd party picker.

Problem is when you need to input a specific color:

- it is not convenient to type 3 times up to 3 digit numbers to the R-G-B fields
- you have your color only in hex format: you cannot enter it
- you would like to copy a color that you just selected: no such feature, you have to memorize R-G-B digits

See this discussion:
http://superuser.com/questions/342921/i ... lor-picker

User avatar
webfork
Posts: 10836
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: Portable Software that hasn't been developed?

#12 Post by webfork »

tproli wrote:you would like to copy a color that you just selected: no such feature, you have to memorize R-G-B digits
The closest thing (and still quite far) I've seen is ArsClip form entry mode (paste item 1 {tab} paste item 2 {tab} paste item 3 and that would only work for a set number of colors that you prep in advance. I couldn't find anything on setting the default colors.

If you find something for this, I'm also interested. Would make some of the presentation work I do go a lot faster.

User avatar
tproli
Posts: 1172
Joined: Sat Sep 09, 2006 10:14 am
Location: Hungary
Contact:

Re: Portable Software that hasn't been developed?

#13 Post by tproli »

If you find something for this, I'm also interested.
The PasteColor I made does this. Currently supports hex color as input (e.g. #0099FF) and pastes the corresponding rgb values to the color picker. It could be easily modified to accept rgb as input (0,153,255).

The copy functionality would also be easy to add.

In this demo the clipboard has "#0099FF", then I moved the cursor to the "Red" input field and hit a hotkey (ctrl+shift+P), that launched PasteColor (I made a regular Windows shortcut and set this hotkey). PasteColor then converts the hex value to rgb and pastes in the fields (sends Red-TAB-Green-TAB-Blue just like ArsClip).

Image

So the functionality is practically ready but if I could make a panel that is visible each time the color picker pops up, that would simplify its usage (would be more user-friendly).

User avatar
tproli
Posts: 1172
Joined: Sat Sep 09, 2006 10:14 am
Location: Hungary
Contact:

Re: Portable Software that hasn't been developed?

#14 Post by tproli »

Here is an update:

http://rolandtoth.hu/files/PasteColor.zip

Usage
1. Assign a hotkey to PasteColor.exe (e.g. create a shortcut and set a hotkey)
2. Put the cursor in the "Red" field of the Windows color picker and invoke PasteColor's hotkey
3. In the pop-up input box enter the hex color value. You can use 3 or 6 digit value with or without the hash mark. The input box is pre-filled with clipboard data.

Changes
- added input box for hex color input: ability to enter custom hex color or cancel the process

I don't plan new features unless someone asks for them. Perhaps adding RGB input, that may come handy.

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: Portable Software that hasn't been developed?

#15 Post by guinness »

I know I missed the mark on your problem, so I thought I would provide you with this function which might be of use to you.

Code: Select all

ConsoleWrite('Return True: ' & _IsHexColor('FF00FF') & @CRLF)
ConsoleWrite('Return False: ' & _IsHexColor('FF00HH') & @CRLF)
ConsoleWrite('Return True: ' & _IsHexColor('0xFF00FF') & @CRLF)
ConsoleWrite('Return False: ' & _IsHexColor('0xFF00HH') & @CRLF)
ConsoleWrite('Return True: ' & _IsHexColor('#FF0000') & @CRLF)
ConsoleWrite('Return False: ' & _IsHexColor('#FF00J0') & @CRLF)

; Accepts the following formats:
; 0xFFFFFF
; FFFFFF
; #FFFFFF
Func _IsHexColor($bColor) ; By guinness, Returns True or False.
	Return StringRegExp($bColor, '\b(0x|#)?[0-9a-fA-F]{6}\b', 0) = 1
EndFunc   ;==>_IsHexColor

Post Reply