PDA

View Full Version : How do I run "two" processes at once?



solarwind
10-26-2006, 09:04 PM
Hi, I'm trying to create J.E.S.S.I, my secret project. So far, it's going really smoothly.

I have one question though. I have a function that is really random and creates nice mouse movements. It also clicks and moves away and almost constantly moves the mouse. But when the mouse is being moved, my procedure is always being used. I also need to do other things like find colours and such while my mouse is moving at the same time. How do I do this? If this is possible, it will be a really big step in my project.

I Pick Axes
10-26-2006, 09:30 PM
Using current procedures, you can't. But you could make your own procedure that could do the job.

lardmaster
10-26-2006, 09:31 PM
i think it is something like "settimeoutexception(seconds:integer, nameofcommand:string);

search for "set timeout"

I Pick Axes
10-26-2006, 09:32 PM
All that does is make something terminate if it's gone on too long.

Boreas
10-26-2006, 09:34 PM
Moving one pixel then getcolor, then repeat would be the next best thing.

solarwind
10-26-2006, 09:58 PM
Using current procedures, you can't. But you could make your own procedure that could do the job.

Hmmm.... I would want to make my own procedures. But how?

I Pick Axes
10-26-2006, 09:59 PM
What are you making anyways? Usually you move your mouse to click or hover and that changes the screen anyways, invalidating your FindColor.

solarwind
10-26-2006, 10:01 PM
My idea is to always keep the mouse moving to seem like a human. (Well, almost always). But when you're always moving the mouse, you cant be doing anything else (like, searching colours, dtms or bitmaps). I want to be able to do both of those things at once.

lardmaster
10-26-2006, 10:22 PM
yeah, i remeber seeing a post about how someone had figured out how to do it, maybee if you wait they will post here

Yakman
10-26-2006, 10:29 PM
i think one way could be to ThreadSafeCall the procedure, it doesnt have to be called that way but its the only way you can let the scripter specify the procedure, something like this



procedure MouseProcedure(x,y,rx,ry:integer; proname:string; args:TVariantArray;)
begin
//...
//...
repeat
movemouse(.....
threadsafecall(procname,args)
until( MouseIsAtDestination );
end;


it would be used like this



var p: TVariantArray;
begin
setarraylength(p,6);
p[0] := bmpRock; //the bitmap of a rock
p[1] := x; //the variable x
p[2] := y;
p[3] := 5;//the parimieters x1,y1,x2,y2
p[4] := 6;
p[7] := 454;
p[8] := 553;
MouseProcedure(x,y,5,5,'FindBitmapIn',p);


that wouldnt acctualy work, what would the procedure do if it finds the bitmap, but it shows how it might work

solarwind
10-26-2006, 10:54 PM
yeah, i remeber seeing a post about how someone had figured out how to do it, maybee if you wait they will post here

Thanks, I'll wait.

Boreas
10-27-2006, 03:47 AM
Hmmm.... I would want to make my own procedures. But how?
I said in my other post.

Kinda like a deck of cards being rifle shuffled just before the bridge, interweaved. You would need to write you own mouse procedure or disect another one so that it's like many movemouse's that go 1 pixel at a time each. Inbetween this mouse movements you have your color/bitmaps/dtms. You would have to figure out how much you can shove between them while still keeping the fluidity of movement (for example take a flipbook, if you go too slow it looks like strobe lighting if you know what I mean). To do that, set mousespeed to sometthing you like then, then

mmouse(10,20,0,0);
a:=getsystemtime;
mmouse(10,30,0,0);
b:=getsystemtime;
writeln(inttostr((b-a)/10)+' milsecs per pixel');

Then do

a:=getsystemtime;
for i:= 1 to 1000;
getcolor(random(100),random(100));
b:=getsystemtime;
writeln(inttostr((b-a)/1000)+' milsecs per getcolor')

(Eventually you'll have to make this auto calibrate for any machine)

Now you know how many getcolors you can put between the movemouse. Then you have to make the mouse procedure change the coords of the movemouses so that it moves in the righ path and make the getcolors use different points.

This is a lot of work. You would be better off doing what lardmaster and Yakman said.

You would also have to put in something so that it doesn't search where the mouse is for either method.

solarwind
10-27-2006, 03:51 AM
Thanks a lot for taking the time to explain to me. SCAR is slow enough already. That would make it way too slow to be of any use.

solarwind
10-27-2006, 03:57 AM
i think one way could be to ThreadSafeCall the procedure, it doesnt have to be called that way but its the only way you can let the scripter specify the procedure, something like this



procedure MouseProcedure(x,y,rx,ry:integer; proname:string; args:TVariantArray;)
begin
//...
//...
repeat
movemouse(.....
threadsafecall(procname,args)
until( MouseIsAtDestination );
end;


it would be used like this



var p: TVariantArray;
begin
setarraylength(p,6);
p[0] := bmpRock; //the bitmap of a rock
p[1] := x; //the variable x
p[2] := y;
p[3] := 5;//the parimieters x1,y1,x2,y2
p[4] := 6;
p[7] := 454;
p[8] := 553;
MouseProcedure(x,y,5,5,'FindBitmapIn',p);


that wouldnt acctualy work, what would the procedure do if it finds the bitmap, but it shows how it might work

Thanks a lot. However, when I click on your signature, it gives me an error.

Boreas
10-27-2006, 04:56 AM
Thanks a lot for taking the time to explain to me. SCAR is slow enough already. That would make it way too slow to be of any use.

How would it make it slow?

I just did some rough calculations and estimate that you could do about 60,000 getcolors during the time the mouse moves around the screen for 3 seconds. Thats about a third of all the pixels on the main screen.

Wizzup?
10-27-2006, 08:25 AM
You could use 2 scars at the same time, and let 1 SCAR do all the color searching and let him send co ordinates using SendInterScarMessage. ;)

XxKanexX
10-27-2006, 10:07 AM
You could use 2 scars at the same time, and let 1 SCAR do all the color searching and let him send co ordinates using SendInterScarMessage. ;)
him? How sexist!

bobert5696
10-27-2006, 03:29 PM
lol :) i dont think it would be possible to do it anyother way then 2 scar applets, since your making it for iBot aswell, to to ruler or geno, and see if they could add somethingk like that to iBot

Boreas
10-27-2006, 04:22 PM
My bad!!! SCAR sees under the mouse pointer. Just watch out for clicking, hovering (that's only on the gametab so searching on MS should be fine) and the uptext changes.

lardmaster
10-27-2006, 07:05 PM
well, i guess this will be one of the things in JESSI that might only be in the IBOT version

Boreas
10-27-2006, 07:12 PM
Yea, it's tricky with SCAR, but IMO worth pursuing. I'm going to work on an example of a 'helper' script for stuff like this.

Edit: Protoype done, only has 1 procedure atm (its for bank booth finding)

bbankf.scar goes in includes
helper.scar is the slave, run that first
yellow.scar is the bankfiner run that after, follow instructions inside

Worked on it all day, pretty proud of it even though it only works at port phasmatys and draynor atm.

solarwind
10-28-2006, 04:59 PM
Great, this is excellent. My prototype looks similar. I think this should be the future of SCAR, multi threading. Imagine how nicely this would run on a dual core or a quad core. I'll defiantly include this in JESSI. Just like that *snap*, almost all lag gone and I can move the mouse while checking and other stuff. Thanks for the prototype.

This has a great potential to not get detected.

Edit: Only got a little lag while the map is turning. I'll try to fix the script.

Edit: Fixed, no lag.

Yakman
10-28-2006, 05:13 PM
there was an include for SCAR which had one SCAR checking for randoms and the other acctually autoing, i think it was called WAAMP or something, you get it if you press File -> Download Includes in SCAR.

also, thanks for telling me about my sig, it should work now :D

solarwind
10-28-2006, 05:20 PM
Thanks, my multi threading prototype is coming along nicely.
Currently, this is what it can do...

Script A:
- Moves mouse and clicks.
- Randomly moves mouse 90% - 95% of the time.
- Makes random clicks on the main screen 5% of the time.
- Makes random clicks in inventory 10% of the time.

Script B:
- Finds colours of goblin on main screen and reports back to Script A
- Continues to find colours and ques them up in a rapid and dynamic queing array.

- MAKES SURE SCRIPT A DOES NOT CLICK ON GOBLINS ALREADY BEING FOUGHT BY OTHER PLAYERS (this is the sickest part), I'll try to complete it quickly for an alpha.

It does this by using findcolorspiraltolerence and stores the blue "0" colours and the red hits in the array (their co ordinates) Dynamically updates as you move.

Thanks all for your help.



Also, I'm having trouble with my SCAR. When I launch my DTM editor, It looks like this: (see next post) for screenshot.

Boreas
10-28-2006, 05:27 PM
@ Yakman-Thanks, it was before my time (started after everything but SRL was outdated) so I never looked it at. Just did, it gave me some ideas to make it more functional. Like having an id for status, another for commands, etc.

@solarwind-Try setting the crosshairs right before dtm editor

solarwind
10-28-2006, 05:35 PM
Edit: Posting picture...
http://img325.imageshack.us/img325/1628/screen2vs5.jpg (http://imageshack.us)

Boreas
10-28-2006, 05:45 PM
Are you using linux with wine?

solarwind
10-28-2006, 05:49 PM
@ Yakman-Thanks, it was before my time (started after everything but SRL was outdated) so I never looked it at. Just did, it gave me some ideas to make it more functional. Like having an id for status, another for commands, etc.

@solarwind-Try setting the crosshairs right before dtm editor

What do you mean right before? (problem screenshot above)

solarwind
10-28-2006, 05:50 PM
Are you using linux with wine?

No, this is on shit windows.

Boreas
10-28-2006, 05:59 PM
I'm stumped, never seen it do that. I can't not see the tools even when I try.

solarwind
10-28-2006, 06:37 PM
Another screen shot. When I resized, it still looks the same.

http://img111.imageshack.us/img111/1148/screen3fr9.th.jpg (http://img111.imageshack.us/my.php?image=screen3fr9.jpg)

Anyway... Back to the topic..

Boreas
10-29-2006, 05:43 AM
I'm an idiot. I can't believe this didn't hit me until now. The helper script should move the mouse and the main script does everything else. This way the script helper would only need to be able translate string ISM's into mouse function parameters, and have a few mouse functions. It can even move the mouse the whole time like a human. I can't think of any other uses for this besides having the mouse move while doing something else. If there is then tell me and I'll rethink it. This way, once there's enough mouse functions to sastify (almost) every need the scripter won't need to write and distribute a copy especially for a certain a script. It's 130 am now so I'll start rewriting tommorow. I'm gonna set up the messaging, parameter reading and then make it work with the bankfinder again. Then I'll let you see it so you can write mouse functions for it.

Stuff to include:
move from one place to the other
move around like a bored human but not in MS/MM/Gametab
move around in area
move around until countflag
gametab anti ban (examine item etc)

Anything else you want supported?
(I'm not going to write all of these (unless I need one for a script and noone else has made it), but I need to make sure that they can be added later smoothly.)

I can't wait to see a script using mousehelper!

solarwind
10-30-2006, 04:26 AM
No, but the real important thing is minimizing lag. Remember, you're running SCAR ALONGSIDE runescape. Runescape itself takes up over 50% of CPU time. We need to aim for effency. Boreas, I'll work with you to develop a multi SCAR script after we have the base layed out. Maybe we can make the first ever multi-SCARed bone picker/buryer. It can work near the chaos temple or whatever near the lvl 20 giants in the wildy in a calm world. Bone pickers are easy to make. Eh, how 'bout it? It'll be wicked.

Boreas
10-30-2006, 05:44 AM
As you can see from my sig I have a lot of stuff I want to do. Once you've got a release version of JESSI out and I've got a release version of MouseHelper out I'll see if I can squeeze in a bone picker. Of course I'll start implenting it into my all scripts, once I get around to doing them lol.


MouseHelper Update:

I'm developing MouseHelper as a utility script, like an include, so that any scripter can have the freedom to use it how they want.

Scripts can be written so that they require MouseHelper: [MHR] or so that MouseHelper is supported: [MHS]. In [MHS] scripts the user sets a boolean to true if they have MouseHelper and want to use it. If they set it to false then script uses alternative methods. As you can see the latter is more work for the scripter and more choice for the user.

MouseHelper and the main script call set up procs in the beggining which communicate with each other to make sure everything is cool. (finished it just now, works awesome)

MouseHelperInclude contains functions and procedures that are designed to interact with functions and procedures in MouseHelper. It is included by the main script. Scripters can use these functions and procedures to interact with MouseHelper or they can write their own. Since I don't care how long MouseHelper gets, it contains everything it needs (besides SRL which it includes), however I didn't want the scripters to have to put a whole bunch of stuff in the main scripts proc and func section so I made an include.

I am using several different ISM Id's to keep things organized.

I am trying to keep it as noob friendly as possible for the people that have trouble setting up 1 SCAR.

I'm going to get the layout all done, write some basic procedures (like being able to terminate MouseHelper from the mainscript, sending coords, setting mousespeed, etc), plus 1 starter procedure that moves the mouse from place to another (need it for my bankfinder), maybe write instructions, and then I will beta release. Then people can check it out and write procedures for it like in the list in my last post. Then I'll add those in.

solarwind
10-31-2006, 01:55 AM
As you can see from my sig I have a lot of stuff I want to do. Once you've got a release version of JESSI out and I've got a release version of MouseHelper out I'll see if I can squeeze in a bone picker. Of course I'll start implenting it into my all scripts, once I get around to doing them lol.


MouseHelper Update:

I'm developing MouseHelper as a utility script, like an include, so that any scripter can have the freedom to use it how they want.

Scripts can be written so that they require MouseHelper: [MHR] or so that MouseHelper is supported: [MHS]. In [MHS] scripts the user sets a boolean to true if they have MouseHelper and want to use it. If they set it to false then script uses alternative methods. As you can see the latter is more work for the scripter and more choice for the user.

MouseHelper and the main script call set up procs in the beggining which communicate with each other to make sure everything is cool. (finished it just now, works awesome)

MouseHelperInclude contains functions and procedures that are designed to interact with functions and procedures in MouseHelper. It is included by the main script. Scripters can use these functions and procedures to interact with MouseHelper or they can write their own. Since I don't care how long MouseHelper gets, it contains everything it needs (besides SRL which it includes), however I didn't want the scripters to have to put a whole bunch of stuff in the main scripts proc and func section so I made an include.

I am using several different ISM Id's to keep things organized.

I am trying to keep it as noob friendly as possible for the people that have trouble setting up 1 SCAR.

I'm going to get the layout all done, write some basic procedures (like being able to terminate MouseHelper from the mainscript, sending coords, setting mousespeed, etc), plus 1 starter procedure that moves the mouse from place to another (need it for my bankfinder), maybe write instructions, and then I will beta release. Then people can check it out and write procedures for it like in the list in my last post. Then I'll add those in.

Yo, if you don't mind, send me dat bad boy and I'll merge my stuff into yours if you don't mind. thanks.

Boreas
10-31-2006, 03:54 AM
I will when I get some more done.