Jump to content
SN222

GetColor output always -1

Recommended Posts

Hi there,

 

The GetColor function gives me always -1.

Here is a short sample program to make sure that there is no other mistake:

 

program New;

var x,y,c:integer;

 

begin

x:=-405

y:=122

c:=GetColor(x,y)

writeln(inttostr©)

end.

 

At this position it should be 4502785, I picked it with the picking tool before.

Wiki says: 'The function returns -1 if the coordinates are outside of the client's boundaries.', but that's not true since I pressed that button with the cross air.

 

Thx for helping.

Link to comment
Share on other sites

Okay, I did this and still getting -1. :\

 

program New;
var x,y,c:integer;

begin
x:=-405
y:=122
GetClient.Activate;
wait(1000)
c:=GetColor(x,y)
writeln(inttostr(c))
end.

 

Successfully compiled (31.4256 ms)

-1

Successfully executed (1015.8109 ms)

Link to comment
Share on other sites

Okay, I did this and still getting -1. :\

 

program New;
var x,y,c:integer;

begin
x:=-405
y:=122
GetClient.Activate;
wait(1000)
c:=GetColor(x,y)
writeln(inttostr(c))
end.

 

Successfully compiled (31.4256 ms)

-1

Successfully executed (1015.8109 ms)

Have you tried using GetColor for some other things, do you get same problems? Or is that problem there only with this particular game(?)?

 

I once had similar problems with color picking, I think it was either antivirus or firewall blocking access from SCAR to screen.. Can't remember which one.

 

-Jani

 

- - - Updated - - -

 

Hold on...

 

You are picking color from:

 

x:=-405
y:=122

 

x = -405, why?

I think that could be your problem.

Link to comment
Share on other sites

No, I tried the GetColor function for the first time. It does not work in my program, so I tried it in that sample above. There it does not work either.

 

I tried to switch off the antivirus program, but I still get -1.

 

EDIT:

 

Yeah? But it's the position relative to that crossair button in SCAR Divi.

I have my SCAR in the right corner, so when I go to the left with my mouse and pick the coordinates, they are negative relative to my SCAR window.

Edited by SN222
Link to comment
Share on other sites

No, I tried the GetColor function for the first time. It does not work in my program, so I tried it in that sample above. There it does not work either.

 

I tried to switch off the antivirus program, but I still get -1.

Fix your x-coordinate, that is the problem. You are using negative x-coordinate (-405).
Link to comment
Share on other sites

Sorry, see edit above. :)

EDIT: Worked, but why? ^^

 

So the GetColor function uses the resolution of the screen (the pixels) as coordinates?

Why not the clickmouse function?

 

Thank you so much. :)

Edited by SN222
Link to comment
Share on other sites

Sorry, see edit above. :)

EDIT: Worked, but why? ^^

 

So the GetColor function uses the resolution of the screen (the pixels) as coordinates?

Why not the clickmouse function?

 

Thank you so much. :)

Yeah, sadly I have no idea why it doesn't work with negatives (even if that negative coordinate is still inside the screen area!), where as colorpicker does... But yeah, I think this is something Freddy has to give an answer for, he is the only one who knows.

It definitely would be great to have those color functions work outside targeted client aswell, hmm... ..maybe it's a bug? :|

Link to comment
Share on other sites

GetColor and all other color related functions, pull the color data from the device context of the window in the event that you're using a regular window client. The device context is essentially where the window draws itself to, but it's window-specific, so the device context of window A won't contain any content from window B. If you want the content of every window, you have to use the device context of the desktop. Of coruse, if you do this, the window(s) you're targeting with the color functions must be on top, where as with the regular device context approach, the only requirement is that they are not minimized. If you want to use this approach, you can try this code: http://forums.scar-divi.com/showthread.php?1860-Client-Problem&p=11476&viewfull=1#post11476

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...