System.PixelColor

It just won't work for me :(

Sunday, February 22, 2009 by vAIp33r | Discussion: DesktopX

I've been looking into System.PixelColor option and I just can't make it work correctly.

This is the script I'm using:

 

Code: vb
  1. hexcolor = Hex(System.PixelColor(System.CursorX, System.CursorY))
  2. red = Right(hexcolor, 2)
  3. green = Mid(hexcolor, 2,2)
  4. blue = Left(hexcolor, 2)
  5.     'I added these Ifs because sometimes red, green or blue return "" and that doesn't really work
  6.     If red="" Then
  7.         red=0
  8.     End If
  9.     If green="" Then
  10.         green=0
  11.     End If
  12.     If blue="" Then
  13.         blue=0
  14.     End If
  15. DesktopX.Object("-1/-1").TextColor = RGB(CLng("&H" & red),CLng("&H" & green),CLng("&H" & blue))

(it is basically just a bit retouched rudamentary script from https://www.stardock.com/products/desktopx/documentation/scripting/system_namespace.asp)

It's on a timer so it loops and it actually changes number values but they are not correct. If anyone has any idea why this won't work please, don't be shy

Tiggz
Reply #1 Sunday, February 22, 2009 1:16 PM

Hi, you don't need to convert it to and from hex, just using

 

Code: vbscript
  1. object.textcolor = system.PixelColor(system.CursorX,system.cursorY)

 

works  fine

 

Unless you're trying to do something else I'm not aware of.

RomanDA
Reply #2 Sunday, February 22, 2009 1:35 PM

this was the script in the "color picker" widget that comes with DX (or did)

 

Code: vbscript
  1.    x = System.CursorX
  2.    y = System.CursorY
  3.    color = System.PixelColor(x, y)
  4.    hexcolor = Hex(color)
  5.    red = Right(hexcolor, 2)
  6.    green = Right(left(hexcolor, 4), 2)
  7.    blue = Left(hexcolor, 2)
  8.    Object.Text = CStr(CLng("&H" & red)) & ", " & CStr(CLng("&H" & green)) & ", " & CStr(CLng("&H" & blue))
  9.    DesktopX.Object("dx_color_sample").TextColor = RGB(CLng("&H" & red),CLng("&H" & green),CLng("&H" & blue))

In the above example the name of the object is "dx_color_sample"

---

Im curious how this is working:

Code: vbscript
  1. DesktopX. Object (" -1/-1 ").TextColor

the "-1/-1" SHOULD be the NAME of the object you want to change the text color of, did you name the object -1/-1?

 

 

vAIp33r
Reply #3 Sunday, February 22, 2009 4:04 PM

Yeah I named it -1/-1 since I'll be using a multitude of little objects and I decided to name them after their relative coordinates.

 

Just C/P your example and it works like it should THANKS A BUNCH!

10 internets to you, ehm I mean +1 karma

 

@Tiggz

I didn't know that works too, unfortunately I need R G and B values separated. Thanks for your reply tho

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01