It is currently Tue May 21, 2013 2:00 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 76 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Re: Portable Software that hasn't been developed?
PostPosted: Thu Sep 06, 2012 10:27 am 
Offline
User avatar

Joined: Sat Sep 09, 2006 10:14 am
Posts: 673
Location: Hungary
Thanks. One thing your IsHexColor function is missing is that there's also 3-digit hex colors, e.g. #40F (= #4400FF).


Top
 Profile  
 
 Post subject: Re: Portable Software that hasn't been developed?
PostPosted: Thu Sep 06, 2012 12:30 pm 
Offline
User avatar

Joined: Mon Aug 27, 2007 2:00 am
Posts: 3726
Easy :)

Code:
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)
ConsoleWrite('Return False: ' & _IsHexColor('#FF00') & @CRLF)
ConsoleWrite('Return True: ' & _IsHexColor('#FF0') & @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]{3}|[0-9a-fA-F]{6})\b', 0) = 1
EndFunc   ;==>_IsHexColor

_________________
Added 177 Applications: Portable and an AutoIt MVP
SoftwareSpot - Portable Apps


Top
 Profile  
 
 Post subject: Re: Portable Software that hasn't been developed?
PostPosted: Thu Sep 06, 2012 12:44 pm 
Offline
User avatar

Joined: Sat Sep 09, 2006 10:14 am
Posts: 673
Location: Hungary
Thanks. I'm done with the rgb input too but perhaps I will modify it a bit according to your script.

Here is my hex + rgb regex validation for the user input. Wasn't that easy :)

Code:
If StringRegExp($color, '\b[0-9a-fA-F]{6}\b|^(0*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])[, \s]\s*){2}(0*([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])([,]{1})?)\s*$', 0) = 0 Then
        ShowError()
    EndIf


The rgb part accepts leading zeros too, like "120, 245, 00010".


Top
 Profile  
 
 Post subject: Re: Portable Software that hasn't been developed?
PostPosted: Thu Sep 06, 2012 1:05 pm 
Offline
User avatar

Joined: Mon Aug 27, 2007 2:00 am
Posts: 3726
RegExp is fun! :mrgreen:

Edit: I will try to shorten it and post the update tomorrow. I enjoy improving my RegExp knowledge as I'm still new to it as you can see.

_________________
Added 177 Applications: Portable and an AutoIt MVP
SoftwareSpot - Portable Apps


Top
 Profile  
 
 Post subject: Re: Portable Software that hasn't been developed?
PostPosted: Thu Sep 06, 2012 1:16 pm 
Offline
User avatar

Joined: Sat Sep 09, 2006 10:14 am
Posts: 673
Location: Hungary
I added 0x0FFFFFF and 0x00FFFFFF color formats for input by adding

Code:
((0x0|0x00){1})?

to the beginning of the regex (+ doing string replace later).

I think I'm done with this, perhaps I will make a new function to copy rgb values from the color picker. That was enough of AutoIt for a while :)

Btw, I just noticed that your regex requires 0x or # in the beginning of the color string. Some applications put html hex values to the clipboard without the hash mark so I made it optional instead.


Top
 Profile  
 
 Post subject: Re: Portable Software that hasn't been developed?
PostPosted: Thu Sep 06, 2012 11:21 pm 
Offline
User avatar

Joined: Mon Aug 27, 2007 2:00 am
Posts: 3726
The hash (#) and 0x are optional as you can see from the example(s) I included with the snippet.

_________________
Added 177 Applications: Portable and an AutoIt MVP
SoftwareSpot - Portable Apps


Top
 Profile  
 
 Post subject: Re: Portable Software that hasn't been developed?
PostPosted: Fri Sep 07, 2012 12:37 pm 
Offline
User avatar

Joined: Sat Sep 09, 2006 10:14 am
Posts: 673
Location: Hungary
Sorry, you're right, must have been blind.

Here is the first release of PasteColor:

Image

Changes:
- added RGB input feature
- added copy color from Windows color picker feature (both in RGB and HTML Hex formats)
- input box reappears if invalid color input was entered
- added "/silent" switch to skip input box (clipboard data is used)
- added readme.txt

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

I enjoyed putting this together. It has more features than I planned on start but I think these features greatly improve usability. Because of the way it works and that r-g-b fields are mostly similar in different applications' color pickers, it works almost everywhere. For example I tried in FreeOffice, Photoshop, Microsoft Word, RJ TextEd, etc. Note that Photoshop has an option to copy color in hex format but you cannot copy RGB for example, but you can with PasteColor.


Top
 Profile  
 
 Post subject: Re: Portable Software that hasn't been developed?
PostPosted: Fri Sep 07, 2012 7:29 pm 
Offline
User avatar

Joined: Thu Aug 07, 2008 4:51 am
Posts: 2586
Nice work there, tproli (& guinness).

A quick comment concerning the readme file, you may want to add a disclaimer re. liability and maybe add a link to the discussion thread on TPFC.

_________________
bəʊɡɪ bəəs


Top
 Profile  
 
 Post subject: Re: Portable Software that hasn't been developed?
PostPosted: Fri Sep 07, 2012 11:37 pm 
Offline
User avatar

Joined: Sat Sep 09, 2006 10:14 am
Posts: 673
Location: Hungary
Thanks, readme file is updated (link is the same).

I added a feature that allows copy/paste values from arbitrary number of fields. This comes handy for example when copying CMYK color or anywhere where you need to copy/paste values from more than 3 fields. In this case no color conversion is made so it is mainly for copying plain text (e.g. form data).
Commas are used for separators so it will fail if an input field's value also has a comma. As it is not an issue for me I leave it as it is, perhaps I will revisit if someone requests.


Top
 Profile  
 
 Post subject: Re: PasteColor
PostPosted: Sun Sep 09, 2012 1:47 am 
Offline
User avatar

Joined: Sat Sep 09, 2006 10:14 am
Posts: 673
Location: Hungary
Mods: thanks for the new topic.

Another update:
  • active input field is remembered: if you start PasteColor and switch to another application, PasteColor will paste color to the original color picker (or application) instead of the currently active window.
  • if original color picker (or application) is closed, PasteColor won't paste anything
  • removed systray icon

With saving original window/control handlers enables PasteColor to work in Adobe Illustrator's panels for example.

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


Top
 Profile  
 
 Post subject: Re: PasteColor
PostPosted: Sun Sep 09, 2012 1:57 pm 
Offline
User avatar

Joined: Sat Sep 09, 2006 10:14 am
Posts: 673
Location: Hungary
Just switched from Send() to ControlSend() (and ControlGetText and ControlSetText) and its now super fast! :)

Download link updated.


Top
 Profile  
 
 Post subject: Re: PasteColor
PostPosted: Sun Sep 09, 2012 3:00 pm 
Offline
User avatar

Joined: Mon Aug 27, 2007 2:00 am
Posts: 3726
I had a quick look today and was going to say Send will get you into a lot of trouble.

_________________
Added 177 Applications: Portable and an AutoIt MVP
SoftwareSpot - Portable Apps


Top
 Profile  
 
 Post subject: Re: PasteColor
PostPosted: Mon Sep 10, 2012 4:31 am 
Offline
User avatar

Joined: Sat Sep 09, 2006 10:14 am
Posts: 673
Location: Hungary
Finally I got rid of sending TAB too and making the application even faster. I was testing and I thought it's not working because I saw the cursor not jumping to the next input control. In fact it did but it was too fast.

There's also a caveat. Now I activate the next control with ControlFocus() and in some applications the IDs are not one after the other, e.g. in Illustrator r-g-b is 11, 15, 17. I decided to leave it as it is: it works fine with Windows color picker, which was the main goal. It occassionally works in other applications, e.g. worked fine in Microsoft Word, RJ TextEd.


Top
 Profile  
 
 Post subject: Re: PasteColor
PostPosted: Tue Sep 11, 2012 6:01 am 
Offline
User avatar

Joined: Sat Sep 09, 2006 10:14 am
Posts: 673
Location: Hungary
It turned out that it is not working on Windows 7. Apparently it has issues on activating the color picker (and perhaps the control also).

If someone could take a look it would be great - I have no machine with Windows 7, unfortunately. AutoIt source is available in the zip:

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


Top
 Profile  
 
 Post subject: Re: PasteColor
PostPosted: Wed Sep 12, 2012 2:04 am 
Offline
User avatar

Joined: Sat Sep 09, 2006 10:14 am
Posts: 673
Location: Hungary
Nevermind, I've set up a virtualbox to track the issue. Interesting though that the active window (control ID) recognition works fine in XP but not on Win7.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 76 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group