SRL Archive - OSR Help

Making my first script (help)


Rawrasaurus

2012-01-31 13:30:56

EDIT: This problem is solved, I have another one though, please check my latest post on this thread.

So I decided to try and make my first script.

What this will do is, when you start on the 'View Advertisements' page on neobux (a paid to click site) it will find the purple advertisements, click on it, then click the red verification dot and then wait for the ad to load and finally cross the page.

So far I am stuck at trying to get the script to click the red dot, as I am getting a compiling erorr.

program Neobux;

procedure ClickAd;
var
x, y:Integer;
begin
if FindColorSpiralTolerance(x, y, 15470554, 236, 221, 848, 348, 10) then
begin
MoveMouse(x, y);
ClickMouse(x, y, 1);
Wait(500);
end;

procedure Verify;
var
x, y:Integer;
begin
if FindColorSpiralTolerance (x, y, 225, 236, 221, 848, 348, 10) then
begin
MoveMouse(x, y);
ClickMouse(x, y, 1);
end;

begin
ClickAd;
Wait(500);
Verify;
end.

The error I get:

[Error] (15:1): Identifier expected at line 14
Compiling failed.



I'm probably making a huge mess of this and this is my very first attempt at programming, so I welcome any constructive criticism about code formatting etc etc. Going on the site might help you understand my problem easier.

Script in its current form :)

program Neobux;

procedure ClickAd;
var
x, y:Integer;
begin
if FindColorSpiralTolerance(x, y, 148131368, 248, 219, 913, 839, 30) or
FindColorSpiralTolerance(x, y, 45056, 248, 219, 913, 839, 30) then
begin
MoveMouse(x, y);
ClickMouse(x, y, 1);
Wait(500);
end;
end;

procedure Verify;
var
x, y:Integer;
begin
if FindColorSpiralTolerance (x, y, 225, 248, 219, 913, 839, 30) then
begin;
MoveMouse(x, y);
ClickMouse(x, y, 1);
end;
end;

procedure ClosePage;
begin
KeyDown(17);
KeyDown(87);
wait(30);
KeyUp(87);
KeyUp(17);
end;

procedure Browser;
var
x:Integer;
begin
OpenWebPage('http://www.neobux.com/m/v/');
activateclient;
end;

begin
Browser;
Wait(5000)
ClickAd;
Wait(500);
Verify;
Wait(20000);
ClosePage;
end.

Inception

2012-01-31 13:36:09

You forgot an end; after ClickAd. Also, after Verify.

Rawrasaurus

2012-01-31 13:49:41

From: Inception
You forgot an end; after ClickAd. Also, after Verify.


Which lines?

Inception

2012-01-31 13:54:37

13 and 23.

NickMystre

2012-01-31 13:54:38

program Neobux;

procedure ClickAd;
var
x, y:Integer;
begin
if FindColorSpiralTolerance(x, y, 15470554, 236, 221, 848, 348, 10) then
begin
MoveMouse(x, y);
ClickMouse(x, y, 1);
Wait(500);
end;
end; // HERE ....

procedure Verify;
var
x, y:Integer;
begin
if FindColorSpiralTolerance (x, y, 225, 236, 221, 848, 348, 10) then
begin
MoveMouse(x, y);
ClickMouse(x, y, 1);
end;
end; // ... AND HERE!

begin
ClickAd;
Wait(500);
Verify;
end.

Rawrasaurus

2012-01-31 15:01:13

Alright thanks I got it working perfectly :)

Another question I have, is it possible to make Simba open a web URL and then select that window as the focus client?

EDIT: The goal is to literally make it all happen in one click 'Start' :)

Rawrasaurus

2012-01-31 15:31:41

I also desperately need to know how to close a tab (Hotkey Ctrl + W) without using co-ordinates (as tab locations change and get smaller when you open a lot). Is there a way to tell the script to hold Ctrl and press W?

Rawrasaurus

2012-01-31 16:48:34

Got those problems solved. New problem.

[Error] (6:11): Semicolon (';') expected at line 5
Compiling failed.

program Neobux;

procedure OpenWebPage([url]http://www.neobux.com/m/v/);[/url]

procedure ClickAd;
var
x, y:Integer;
begin
if FindColorSpiralTolerance(x, y, 43008, 248, 219, 913, 839, 10) then
begin
MoveMouse(x, y);
ClickMouse(x, y, 1);
Wait(500);
end;
end;

procedure Verify;
var
x, y:Integer;
begin
if FindColorSpiralTolerance (x, y, 225, 236, 221, 913, 839, 30) then
begin;
MoveMouse(x, y);
ClickMouse(x, y, 1);
end;
end;

procedure ClosePage;
begin
MoveMouse(1770, -47);
ClickMouse(1770, -47, 1);
end;

begin
OpenWebPage;
ClickAd;
Wait(500);
Verify;
Wait(20000);
end.

bg5

2012-02-01 01:40:07

From: Rawrasaurus
I also desperately need to know how to close a tab (Hotkey Ctrl + W) without using co-ordinates (as tab locations change and get smaller when you open a lot). Is there a way to tell the script to hold Ctrl and press W?


  Keydown(17); //ctrl
KeyDown(72); //h
wait(30);
Keyup(17);
Keyup(72);

Keycodes: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes

Rawrasaurus

2012-02-01 03:14:11

From: beginner5
  Keydown(17); //ctrl
KeyDown(72); //h
wait(30);
Keyup(17);
Keyup(72);

Keycodes: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes


If I put that into a new script, like:

program Close;

procedure Terminate;
begin
KeyDown(17);
KeyDown(72);
wait(30);
KeyUp(17);
KeyUp(72);
end;

begin
Terminate;
end.

If I set the client to Google Chrome, that should in theory work, right? For some reason it just says:

Compiled successfully in 47 ms.
Successfully executed.

Yet nothing happens.

NickMystre

2012-02-01 05:01:42

From: Rawrasaurus
Got those problems solved. New problem.

[Error] (6:11): Semicolon (';') expected at line 5
Compiling failed.



This is the offending piece of code.

procedure OpenWebPage([url]http://www.neobux.com/m/v/);[/url]

Your OpenWebPage procedure needs to look something like this …

procedure SomeThingOrOther;
var
x:Integer (if required)
begin
OpenWebPage('http://www.neobux.com/m/v/');
end;

Rawrasaurus

2012-02-01 05:51:59

From: NickMystre
This is the offending piece of code.

procedure OpenWebPage([url]http://www.neobux.com/m/v/);[/url]

Your OpenWebPage procedure needs to look something like this …

procedure SomeThingOrOther;
var
x:Integer (if required)
begin
OpenWebPage('http://www.neobux.com/m/v/');
end;


Thanks I will try that when I get in. Can you check my most recent post on this thread and try and offer a solution for that too?

Thanks a lot.

NickMystre

2012-02-01 06:17:55

From: Rawrasaurus
Thanks I will try that when I get in. Can you check my most recent post on this thread and try and offer a solution for that too?

Thanks a lot.


TBH, I do not know the OpenWebPage procedure or function and what it's arguments should be but if you move the last '' inside the bracket ')' then it also looks to be a possible option.

Mind you, IMO - would you not use the tags when it's your intention to present to the reader the option of just clicking on the link to navigate to the webpage ? The argument for OpenWebPage is probably just http://www.neobux.com/m/v/

What do you think ?

Rawrasaurus

2012-02-01 10:50:29

From: NickMystre
TBH, I do not know the OpenWebPage procedure or function and what it's arguments should be but if you move the last '' inside the bracket ')' then it also looks to be a possible option.

Mind you, IMO - would you not use the tags when it's your intention to present to the reader the option of just clicking on the link to navigate to the webpage ? The argument for OpenWebPage is probably just http://www.neobux.com/m/v/

What do you think ?


Yeah, the URL seems to have been included automatically when I put it in
 tags. The actual script didn't/doesn't contain [url]

New problem! :) Here is the code so far:

[simba]program Neobux;

procedure ClickAd;
var
x, y:Integer;
begin
if FindColorSpiralTolerance(x, y, 148131368, 248, 219, 913, 839, 30) or
FindColorSpiralTolerance(x, y, 45056, 248, 219, 913, 839, 30) then
begin
MoveMouse(x, y);
ClickMouse(x, y, 1);
Wait(500);
end;
end;

procedure Verify;
var
x, y:Integer;
begin
if FindColorSpiralTolerance (x, y, 225, 248, 219, 913, 839, 30) then
begin;
MoveMouse(x, y);
ClickMouse(x, y, 1);
end;
end;

procedure ClosePage;
begin
MoveMouse(1770, -47);
ClickMouse(1770, -47, 1);
end;

procedure Browser;
var
x:Integer;
begin
OpenWebPage('http://www.neobux.com/m/v/');
end;

begin
Browser;
Wait(5000)
ClickAd;
Wait(500);
Verify;
Wait(20000);
end.

It seems that after doing the Browser procedure and waiting 5000ms, it will then try to find the colours in the simba client instead. So obviously I need to make it target the client that is the new webpage.

What do I need to do to make it select a certain client and then continue the script? Thanks :)

EDIT: Here's what I'm getting now..

[Hint] (36:2): Variable 'X' never used at line 35
Compiled successfully in 62 ms.
Exception: Range check error at line 7

bg5

2012-02-01 18:18:38

From: Rawrasaurus
If I put that into a new script, like:

program Close;

procedure Terminate;
begin
KeyDown(17);
KeyDown(72);
wait(30);
KeyUp(17);
KeyUp(72);
end;

begin
Terminate;
end.

If I set the client to Google Chrome, that should in theory work, right? For some reason it just says:

Compiled successfully in 47 ms.
Successfully executed.

Yet nothing happens.


You need to activate client always if you work on browser (you don't need it it SMART)
begin
activateclient;
Terminate;
end;

Rawrasaurus

2012-02-05 08:32:11

Here is the script now:

program Neobux;

procedure ClickAd;
var
x, y:Integer;
begin
if FindColorSpiralTolerance(x, y, 148131368, 248, 219, 913, 839, 30) or
FindColorSpiralTolerance(x, y, 45056, 248, 219, 913, 839, 30) then
begin
MoveMouse(x, y);
ClickMouse(x, y, 1);
Wait(500);
end;
end;

procedure Verify;
var
x, y:Integer;
begin
if FindColorSpiralTolerance (x, y, 225, 248, 219, 913, 839, 30) then
begin;
MoveMouse(x, y);
ClickMouse(x, y, 1);
end;
end;

procedure ClosePage;
begin
KeyDown(17);
KeyDown(87);
wait(30);
KeyUp(87);
KeyUp(17);
end;

procedure Browser;
var
x:Integer;
begin
OpenWebPage('http://www.neobux.com/m/v/');
activateclient;
end;

begin
Browser;
Wait(5000)
ClickAd;
Wait(500);
Verify;
Wait(20000);
ClosePage;
end.

I'm getting

Error: Exception: Failed to execute  "http://www.neobux.com/m/v/" : 87 at line 40

help :O

bg5

2012-02-06 22:34:28

Try to run simba as administrator.

Anyway script will not work ,because you open new browser window ,which is not choosen as client by default. After you open game window you need to set it as target. This might help:
http://docs.wizzup.org/simba/scriptref/window.html#getprocesses