SRL Archive - OSR Help

How can I click the center of an object


farkid

2013-04-30 07:20:05

This is a simple flash game. The point is to click the center of the circle.
After each click the circle moves x length left until it hits the wall then x length right until the wall, then repeats. The length it moves isn't always the same. I'm trying to make the script click the center every click but don't know how to go about making it happen.
The code i'm using now
[ATTACH=CONFIG]21009[/ATTACH]

program Button;

Procedure Click;
var x,y:integer;
begin;
If FindColorSpiralTolerance(x,y,25800,21,205,450,235,1)Then
Begin
MoveMouse(x,y);
Wait(5000)
ClickMouse(x,y,1);
End;
End;

Begin
repeat
Click
until(false)
end.

Shuttleu

2013-04-30 07:48:19

try this
program Button;

Procedure Click;
var ThePoints:TPointArray;
begin;
If FindColorsTolerance(ThePoints,25800,21,205,450,235,1)Then
Begin
MoveMouse(ThePoints[High(ThePoints)/2].x,ThePoints[High(ThePoints)/2].y);
Wait(5000)
ClickMouse(ThePoints[High(ThePoints)/2].x,ThePoints[High(ThePoints)/2].y,1);
End;
End;

Begin
repeat
Click
until(false)
end.

~shut

farkid

2013-04-30 07:56:49

From: Shuttleu
try this
program Button;

Procedure Click;
var ThePoints:TPointArray;
begin;
If FindColorsTolerance(ThePoints,25800,21,205,450,235,1)Then
Begin
MoveMouse(ThePoints[High(ThePoints)/2].x,ThePoints[High(ThePoints)/2].y);
Wait(5000)
ClickMouse(ThePoints[High(ThePoints)/2].x,ThePoints[High(ThePoints)/2].y,1);
End;
End;

Begin
repeat
Click
until(false)
end.

~shut


nope :\ Thanks for trying:)

farkid

2013-04-30 08:02:34

From: Shuttleu
try this
~shut


By ATTEMPTING to read what you wrote (I am new) this code is assuming the box is around the circle correct? But the box is around the whole light gray oval. If I made the box around the circle then once the circle moves out of the box the script would stop right?

Sin

2013-04-30 08:05:34

Look into 'MiddleBox'.

farkid

2013-04-30 08:10:34

From: Sin
Look into 'MiddleBox'.


Ok I looked it up, it looks like it returns the coordinates of the middle of the box.
But how would I get a box to continuously follow the Circle as it moves after every
click thus the center would be moving.

Shuttleu

2013-04-30 08:21:03

maybe overkill, but how about this
program Button;

function CenterOfCircle(ThePoints: TPointArray): TPoint;
var i, x1, y1, x2, y2:integer;
begin
x1:= ThePoints[0].x;
y1:= ThePoints[0].y;
for i:=0 to High(ThePoints) do
begin
if ThePoints[i].x < x1 then
x1:= ThePoints[i].x;
if ThePoints[i].x > x2 then
x2:= ThePoints[i].x;
if ThePoints[i].y < y1 then
y1:= ThePoints[i].y;
if ThePoints[i].y > y2 then
y2:= ThePoints[i].y;
end;
result:= Point(((x2-x1)/2)+x1, ((y2-y1)/2)+y1);
end;

procedure Click;
var ThePoints:TPointArray;
var Thecenter: TPoint;
begin;
if FindColorsTolerance(ThePoints,25800,21,35,499,292,2) then
begin
TheCenter:= CenterOfCircle(ThePoints);
MoveMouse(TheCenter.x,TheCenter.y);
Wait(5000)
ClickMouse(TheCenter.x,TheCenter.y,1);
end;
end;

begin
repeat
Click
until(false)
end.

~shut

samerdl

2013-04-30 08:34:55

What game is that?

farkid

2013-04-30 08:35:14

From: Shuttleu
maybe overkill, but how about this

~shut

Holy :eek: I wont be able to understand this one :p
This script is very close. It clicks the center the first time but after the circle moves once(after first click) it is a little bit off the center but it continues to be the same distance off the center. This was just a small script i was try to do to practice scripting but it looks a bit advanced for me lol :). I appreciate the help.

farkid

2013-04-30 08:36:24

The game in on kongregate called Anti-idle its a minigame you buy inside the game after about 5mins of playing.
http://www.kongregate.com/games/Tukkun/anti-idle-the-game?acomplete=antii

Shuttleu

2013-04-30 09:20:25

perfected

program Button;

function CenterOfCircle(ThePoints: TPointArray): TPoint;
var i, x1, y1, x2, y2:integer;
begin
x1:= ThePoints[0].x;
y1:= ThePoints[0].y;
for i:=0 to High(ThePoints) do
begin
if ThePoints[i].x < x1 then
x1:= ThePoints[i].x;
if ThePoints[i].x > x2 then
x2:= ThePoints[i].x;
if ThePoints[i].y < y1 then
y1:= ThePoints[i].y;
if ThePoints[i].y > y2 then
y2:= ThePoints[i].y;
end;
result:= Point(((x2-x1)/2)+x1, ((y2-y1)/2)+y1);
end;

procedure Click;
var ThePoints:TPointArray;
var Thecenter: TPoint;
begin;
if FindColorsTolerance(ThePoints,25800,213,172,699,376,2) then
begin
TheCenter:= CenterOfCircle(ThePoints);
MoveMouse(TheCenter.x,TheCenter.y);
ClickMouse(TheCenter.x,TheCenter.y,1);
end;
end;

begin
repeat
Click;
Wait(250);
until(false)
end.

~shut

EDIT: after running for a couple of mins

farkid

2013-04-30 09:35:14

Impressive :) I hope you enjoyed the challenge haha.
It looks like I need to take on some easier challenges to practice and learn.

westkevin12

2013-05-01 08:08:51

From: farkid
Impressive :) I hope you enjoyed the challenge haha.
It looks like I need to take on some easier challenges to practice and learn.


my first script was a hello world script :) then i made a cow killer that would soo get you banned these days lol it just found the exact colour on a cow and clicked 500 million miles an hour in an endless loop and i couldn't stop it didn't know how had to turn my comp off, this was before s.m.a.r.t where it controlled your mouse, i think i tried to make a bolt fletcher after that it worked good for 2 weeks till it got me banned. X D anyways hopefully i gave you some ideas on a script to make.