SRL Archive - RS3 Help

Clicking when found a certain color inside a TBOX?


headykiss

2014-05-03 23:00:34

Currently I have a script that will hover inside a TBOX, wait, then click, after a certain time has passed. I am looking for a way to only click when it is hovering a certain pixel color.

For example, I will be using it in context of:
...
. Clicks a ladder up
. As soon as it clicks, mouse hovers inside a new TBOX,
(Color inside TBOX will change when player has reached the next floor),
. Clicks with mouse as soon as selected pixel color is found inside TBOX

If anyone has any tips for how I can do this, it would be greatly appreciated!
Note, I have only learnt how to make scripts a few hours ago, my first script is based upon absolute X/Y TBOX positioning, I haven't yet coded any parts of my script to rely on colors. Also, I don't know my way around properly yet! I browse through the lib files for anything that could help me do this, but haven't found anything yet!

Thank you (:

riwu

2014-05-03 23:08:25


GetMousePos(x, y);
if GetColor(x, y) = CERTAIN_COLOR then
fastClick(MOUSE_LEFT);

this will make it click when the current mouse position's color = CERTAIN_COLOR.

Frement

2014-05-03 23:09:01

PixelShift detects when colors inside a box change. Maybe you could use that?

Ian

2014-05-03 23:09:18

You can use getColor to get the color of a specific pixel, or countColorTolerance to count how many of a color (with tolerance) is in a box.

Documentation for those is here http://docs.villavu.com/simba/scriptref/colourfinding.html

P1ng

2014-05-04 07:21:05

Currently using something like this in my guild miner.

function isInMine(): Boolean;
begin
{writeLn(countColorTolerance(329478, minimap.getBounds, 30));{}
result := countColorTolerance(329478, minimap.getBounds, 30) > 10000;
end;

at the end of my climbing ladder function I have…

  t := getSystemTime + randomRange(5000, 8000);
while getSystemTime < t do
begin
if isInMine then
exit(True);
end;

then i have my procedure to walk over to the rocks

headykiss

2014-05-04 08:13:36

Thanks for all your help! I managed to code this for myself:


procedure click_craft();
var
x, y: integer;
begin
begin
repeat
wait(randomRange(100,110));
until
(findColorTolerance(x, y, 13669638, 400, 435, 460, 455, 9));
end;
fastClick(MOUSE_LEFT);
wait(randomRange(100,110));
end;

I set it up so it would click the blue interfaces which appear when you attempt to craft something! Probably not the most ground breaking code you've ever seen, but this is a great breakthrough for me! (:

P1ng

2014-05-05 01:34:42

Perhaps try adding in a failsafe of some sort. I like to use timers, like so…

procedure click_craft();
var
x, y, t: integer;
begin
t := getSystemTime + randomRange(10000, 15000);
while getSystemTime < t do
begin
if (findColorTolerance(x, y, 13669638, 400, 435, 460, 455, 9)) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;
end;

masterBB

2014-05-05 06:59:24

Alternative for what p1ng posted.

procedure click_craft();
var
x, y: integer;
stopWatch: TTimeMarker;
begin
stopWatch.start();
while(not(findColorTolerance(x, y, 13669638, 400, 435, 460, 455, 9)) and stopWatch.getTime() < 10000) do
wait(randomRange(100,110));
fastClick(MOUSE_LEFT);
end;

P1ng

2014-05-05 08:02:07

From: masterBB
Alternative for what p1ng posted.

procedure click_craft();
var
x, y: integer;
stopWatch: TTimeMarker;
begin
stopWatch.start();
while(not(findColorTolerance(x, y, 13669638, 400, 435, 460, 455, 9)) and stopWatch.getTime() < 10000) do
wait(randomRange(100,110));
fastClick(MOUSE_LEFT);
end;


While that is good, it will click whether it finds the colour or not if the timeout is reached.

masterBB

2014-05-05 13:35:57

oh, yeah, my bad. Shouldn't post code without thinking ;)