Jump to content
xtrackx

Help Mouse or Keyboard pressed for x seconds or until...

Recommended Posts

Hi, I'm newbie or scar divi language.

 

All that I need to do, is :

-spacebar of left click of the mouse pressed for x seconds, or until a color green, go to red

-check every 30 seconds if a color is black, or white, then click on it when it's black

 

I have only 3 strings at the moment, who can help me?

 

[sCAR]program New;

begin

end.[/sCAR]

Edited by xtrackx
Link to comment
Share on other sites

There is a game, with a bar.

 

If you use spacebar, or left click of the mouse (pressed) the bar go up, if I remove my hand from keyboard/mouse the bar go down.

 

I must make this bar in the middle for 30 seconds fro win the game, pressing, and leaving my hand from the keyboard/mouse.

 

Every time that I win, I earn money, and I want to do a simple bot that play for me.

 

All that I need is to do a function in scar divi, that hold spacebar/leftmouseclick and check every second if the head of the bar is colored.

 

If yes, the bot "leave the pressing" of the spacebar/or-mouse-click and re-hold it after 3 seconds until the head of the bar is re-colored and...

Link to comment
Share on other sites

Now I don't have it, but it's a bar like this (I found it on google images)

 

ColorBar_Sample.JPG

 

You understod good what I want to do, and I know that is very easy, especially with scar divi.

 

If you want the exact image of the bar, I can switch in about 30 minutes computer, for do the screenshot, but it's not very important.

 

The bar is remi-round and horizontal, anz is in the middle green, and on the 2 heads yellow-red

 

But I don't know the codes in scar divi, because I don't know this language, do you have an idea?

Link to comment
Share on other sites

You need to target the game with SCAR's crosshairs buttonnewscriptgx5.png before you run the script!

 

Try this script:

 

NOTE: This only uses space bar, and hopefully the FindColor doesn't find those trees over there...it shouldn't...give it a try

 

[scar]

// hit CTRL + ALT + S to stop the script from anywhere!

 

program TestFishBot;

 

var

cWidth, cHeight: Integer;

 

procedure ScriptTerminate;

begin

SetColorspeed2Modifiers(0, 0);

ColorToleranceSpeed(1);

end;

 

procedure Loop;

var

x, y: Integer;

begin

ColorToleranceSpeed(2);

SetColorspeed2Modifiers(0.70, 2.41);

repeat

if not FindColorSpiralTol(CWidth div 2, cHeight div 2, x, y, 4107845, 0, 0, cWidth - 1, cHeight - 1, 5) then

PressVKeyEx(VK_SPACE, 30 + Random(85));

wait(100);

until ((GetKeyState(VK_CONTROL) and GetKeyState(VK_MENU) and GetKeyState(CharToVKey('s'))));

SetColorspeed2Modifiers(0, 0);

ColorToleranceSpeed(1);

end;

 

procedure SetupClient;

begin

GetClient.Activate;

GetBoxSize(GetClient.ImageArea, cWidth, cHeight);

end;

 

procedure MainLoop;

begin

ClearDebug;

SetupClient;

Loop;

end;

 

begin

MainLoop;

end.

 

[/scar]

Link to comment
Share on other sites

First of all, thanks a lot.

 

I got a problem.

 

The bot press the space every seconds I think, and the bar don't reach the "right head".

 

How can I do that the bot hold down the spacebar, until the color of the "right head coordinates" is red, and re-hold down it when the color of the "left head coordinates" is red?

 

Edit 1 : I tried to modify line 23 [sCAR]wait(100);[/sCAR] to [sCAR]wait(1000);[/sCAR] just for test, but I saw that if I compile, and I press F9, the bot don't works anymore.

 

I restored the value to 100, but I'm having the same problem, now I try to reeboot.

Edited by xtrackx
Link to comment
Share on other sites

I can change it for the "red heads" but try this one now:

 

[scar]

// hit CTRL + ALT + S to stop the script from anywhere!

 

program TestFishBot;

 

var

cWidth, cHeight: Integer;

 

procedure ScriptTerminate;

begin

ColorToleranceSpeed(1);

end;

 

procedure Loop;

var

x, y: Integer;

begin

ColorToleranceSpeed(2);

repeat

if not FindColorSpiralTol(CWidth div 2, cHeight div 2, x, y, 3649589, 0, 0, cWidth - 1, cHeight - 1, 0) then

PressVKeyEx(VK_SPACE, 30 + Random(85));

wait(100);

until ((GetKeyState(VK_CONTROL) and GetKeyState(VK_MENU) and GetKeyState(CharToVKey('s'))));

ColorToleranceSpeed(1);

end;

 

procedure SetupClient;

begin

GetClient.Activate;

GetBoxSize(GetClient.ImageArea, cWidth, cHeight);

end;

 

procedure MainLoop;

begin

ClearDebug;

SetupClient;

Loop;

end;

 

begin

MainLoop;

end.

[/scar]

Link to comment
Share on other sites

Thanks again.

 

Don't works yet.

 

The bot press the spacebar fast, but don't hold down it.

 

In line 20 I red

 

[sCAR]PressVKeyEx(VK_SPACE, 30 + Random(85));

wait(100);[/sCAR]

 

but I'm not sure if should be modified or not.

 

Can it be a resolution problem?

 

I have 1152 x 864 and the window "not scrolled but in top" as the first screenshot.

Link to comment
Share on other sites

Kk try this...u just want it to hold spacebar down:

 

I can change it for the "red heads" but try this one now:

 

[scar]

// hit CTRL + ALT + S to stop the script from anywhere!

 

program TestFishBot;

 

var

cWidth, cHeight: Integer;

keydownbool: Boolean;

procedure ScriptTerminate;

begin

ColorToleranceSpeed(1);

if keydownbool then

VKeyUp(VK_SPACE);

end;

 

procedure Loop;

var

x, y: Integer;

begin

ColorToleranceSpeed(2);

repeat

if not FindColorSpiralTol(CWidth div 2, cHeight div 2, x, y, 3649589, 0, 0, cWidth - 1, cHeight - 1, 0) then

begin

VKeyDown(VK_SPACE);

keydownbool := true;

end;

wait(100);

until ((GetKeyState(VK_CONTROL) and GetKeyState(VK_MENU) and GetKeyState(CharToVKey('s'))));

ColorToleranceSpeed(1);

end;

 

procedure SetupClient;

begin

GetClient.Activate;

GetBoxSize(GetClient.ImageArea, cWidth, cHeight);

end;

 

procedure MainLoop;

begin

ClearDebug;

SetupClient;

Loop;

end;

 

begin

MainLoop;

end.

[/scar]

Link to comment
Share on other sites

Are you sure that the bot "don't press anymore the bar" when the right red head is on?

 

Probably the algorithm is good... I don't know...

 

Edit 1 : Are you sure that you picked the exact color?

 

It's the only one logic reason for the bad working of the bot.

 

Edit 2 : Or the timer... for example if the bot check every second the color can skip it because 1 second is too much...?

Edited by xtrackx
Link to comment
Share on other sites

Well, what its supposed to do is SPAM Spacebar until the color is found. Once the color is found it is supposed to stop.

 

No errors with those scripts I posted. Just firefox or something messes up. Try it with internet explorer maybe......

 

If you have OSI (File->Includes Manager). Then go to Tool->Explore->Includes open up the OSI folder and then open up the Tools folder. There is a tool called Auto Color Aid, and that is what I've been using. It's been working perfectly for me up until now on this case. Which gives reason for me to believe it is a client problem...

 

I'll test this more thoroughly later, busy atm

Link to comment
Share on other sites

kk try this:

 

[scar]

// hit CTRL + ALT + S to stop the script from anywhere!

 

program TestFishBot;

 

var

cWidth, cHeight: Integer;

keydownbool: Boolean;

procedure ScriptTerminate;

begin

ColorToleranceSpeed(1);

if keydownbool then

VKeyUp(VK_SPACE);

end;

 

procedure Loop;

var

x, y: Integer;

begin

ColorToleranceSpeed(2);

repeat

if not FindColorSpiralTol(CWidth div 2, cHeight div 2, x, y, 3649589, 0, 0, cWidth - 1, cHeight - 1, 0) then

begin

VKeyDown(VK_SPACE);

keydownbool := true;

end;

wait(500);

if keydownbool then

begin

VKeyUp(VK_SPACE);

keydownbool := false;

end;

until ((GetKeyState(VK_CONTROL) and GetKeyState(VK_MENU) and GetKeyState(CharToVKey('s'))));

ColorToleranceSpeed(1);

end;

 

procedure SetupClient;

begin

GetClient.Activate;

GetBoxSize(GetClient.ImageArea, cWidth, cHeight);

end;

 

procedure MainLoop;

begin

ClearDebug;

SetupClient;

Loop;

end;

 

begin

MainLoop;

end.

[/scar]

Link to comment
Share on other sites

Same problem, don't leave the spacebar.

 

What resolution do you have?

 

Edit 1 : I tried to take the coordinates manually without success.

 

I toke color 2450676 at (554; 416)

 

I put it in line 21, but I'm not sure...

 

[sCAR] if not FindColorSpiralTol(CWidth div 2, cHeight div 2, x, y, 2450676, 554, 416, cWidth - 1, cHeight - 1, 0) then

[/sCAR]

Edited by xtrackx
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...