Page 1 of 1

Color_Finder

Posted: Sat Jun 24, 2006 11:49 am
by yrret
PB 4.0 comes with a nice tool named Color Picker, which works with the IDE.
But I sometimes needed a small program that I could be able to use as a
stand alone with out the IDE . I also needed a program in which I could
choose external colors. I found ColorsHexer by CSprengel : Date: 20. June
2003, but it lacked the features I needed. So I added several new features
which I needed and renamed from ColorsHexer to Color_Finder, and so this
is the results. (Help screen shown)

Image

Notes:
Source is included and is well commented.
Mind you some may laugh at some of the code as I'm just starting
using PureBasic, but the program seems to work fine on my XP pro
machine.

It is important to put the color_Finder.exe, color_Finder.bmp and color_bars.bmp in the
same directory, as Color_Finder.exe needs to load them.

http://d.turboupload.com/d/722013/Color_Finder.zip.html

Posted: Sat Jun 24, 2006 2:35 pm
by rsts
Nice. Thanks for sharing it.

If you're interested in additional improvements, a feature I find useful is to get the color value of a point I select on the "windows" screen. A program called "color pic" comes to mind as an example (not PB as far as I know).

It would involve some additional api calls and I'm not sure exactly how much complexity it would add. This is not a criticism of your program, merely an idea for a possible improvement.

If you decide not to, I may play with it when I finish the project I'm on now.

Anyway, thanks again for sharing the program.

cheers

Posted: Sat Jun 24, 2006 7:39 pm
by yrret
rsts wrote:If you're interested in additional improvements, a feature I find useful is to get the color value of a point I select on the "windows" screen. A program called "color pic" comes to mind as an example (not PB as far as I know).


That's what the Ext Color Button is for. Just left click on it and move your mouse over the color you wish to capture,
while looking at the color bar in the programs window. When you get the color you want, just left click the mouse again.
You can grab any color with your mouse this way, anywhere on your screen.
:D :D :D

Posted: Sat Jun 24, 2006 8:17 pm
by rsts
:oops:

Guess I should have looked closer. :lol:

Nice tool :)

cheers

Posted: Sat Jun 24, 2006 10:33 pm
by thefool
Nice tool, but i have to comment out the delay(400) if i want the program to run at a decent speed!

Posted: Sun Jun 25, 2006 5:20 am
by yrret
The Delay(400) was added so you could single click the arrow buttons one number at a time for fine tuning. eg: starting at 56, 57, 57, 59 with three > clicks.
If you hold the left mouse button down, it goes to default and bypasses the Delay(400) and speeds right up.
With out the Delay(400), single clicking might jump 2 to 5 numbers each click depending on how fast you click.
Try just clicking on an arrow button , and then try holding the button down, and you will see what I mean. The count starts slow, and then quickly speeds right up.
Try a smaller delay value if you like. It's just that the value of 400 seem to work best with my 56 year old fingers. :wink:

Code: Select all

     Select m
         Case 1   ;used to allow one mouse button click entry.
            Delay(400)
         
         Default  ;used to speed movement if mouse button is held down.
      
      EndSelect

;  (and it is used with:)

  i=IsLeftPressed()
  ;Debug "i = "+Str(i)
  ;i = 32768 when left mouse button is down and goes to 0 when up.
  ;Use to select the button the mouse is over   
  ;to cause it to perform what you want it to do.
  
  If i>0 
      m=m+1
  EndIf
   If i=0 
      m=0
  EndIf

Posted: Sun Jun 25, 2006 11:52 am
by thefool
If i move the window, the whole program is taking ages to refresh!

Posted: Sun Jun 25, 2006 2:53 pm
by yrret
Regarding the Delay(400) comment earlier. There is something else that I just thought of that could be a factor. And that is your system mouse settings. Some like to change their system mouse settings button response time to faster or slower. I don't with XP, but I use to with win98. That would have an effect on that part of the program, and changing that delay value would probably be needed.

thefool wrote:
If i move the window, the whole program is taking ages to refresh!
At reading your reply, I immediately tried moving the window while using the various features of the program with out any ill effects. There was no slow down, and every thing worked as normal. I'm using XP Pro, with several other programs running at the same time. The only time that I would see 'everything' slow down, was when I was running my anti virus program which took close to 100% of my CPU time while running, and that would be expected. Also if I could ask. What platform are you using? I don't have Win98 anymore so I can't test on that platform. There maybe some features that allow it to run better in XP then with win 98.

Does any one else have this problem ?

At least I have provided the complete 'commented' source, so anyone can experiment if they want to try something different. As I am new to purebasic and just learning. Perhaps some could post better ideas of how to do some parts in a better way. For example, one thing I couldn't solve was when using the buttons that move all three slides. Only the top number (red) would update during the moving. The lower green and blue numbers would always update after releasing the mouse button. If I switched the order around, in example putting green first. Then the green one would be the only number that would update during the moving. The rest would always update after releasing the mouse button. It would appear to me that they should all update like the first one in line does, as it's using the same code approach. :?:
It's a minor thing because the end results is achieved, but I'm just curious as to why the other two would behave that way in the program. You would think that they should all update at the same time.

Code: Select all

         Case 26           ; ButtonGadget #26   "all bars <If>0
               If green>0
                  If blue>0
                     red=red-1
                     green=green-1
                     blue=blue-1
                     ;This should cause all three numbers to change, but only the first
                     ;number, red in this case, changes until you release the mouse button.
                     ;Then they all change to their correct values.
                     SetGadgetText(2, Str(red))
                     SetGadgetState(1,red)
                     
                     SetGadgetText(12, Str(green))
                     SetGadgetState(11,green)
                     
                     SetGadgetText(22, Str(blue))
                     SetGadgetState(21,blue)
                     i=0
                  EndIf
               EndIf
            EndIf         
                 
         
         Case 27           ; ButtonGadget #27   "all bars >"
            If red<255
               If green<255
                  If blue<255
                     red=red+1
                     green=green+1
                     blue=blue+1
                     ;As above.  This should cause all three numbers to change, but
                     ;only the first number changes until you release the mouse button.
                     ;Then they all change to their correct values.
                     SetGadgetText(2, Str(red))
                     SetGadgetState(1,red)
                     
                     SetGadgetText(12, Str(green))
                     SetGadgetState(11,green)
                     
                     SetGadgetText(22, Str(blue))
                     SetGadgetState(21,blue)
                     i=0
                  EndIf
               EndIf
            EndIf 

Posted: Thu Jun 29, 2006 2:13 am
by yrret
I'm curious. Could anybody give me an idea why it works that way, or is it a bug :?:
As mentioned in my the last message. The thing I couldn't solve was when using the buttons that move all three slides. Only the top number (red) would update during the moving. The lower green and blue numbers would always update after releasing the mouse button. It would appear to me that they should all update like the first one in line does, as it's using the same code approach. I could even switch them around and the one that was listed first would be to only one to update during the moving.
Any ideas :?: Thank you for your time.