System.PixelColor

It just won't work for me :(

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 :pout:

4,729 views 3 replies
Reply #1 Top

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.

Reply #2 Top

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.<span style="color: #0000ff;">Object</span>("<span style="color: #8b0000;">-1/-1</span>").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?

 

 

+1 Loading…
Reply #3 Top

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 :)