BenLand100
2007-07-01 19:38:38
First off, there is the question of how to provide mouse control. Since this is minimizable, all events, including focus, are delivered directly to the client, and other events are blocked (at least while event spoofing/blocking is enabled). I have two theroies on how to do this. One way (and the way that I have implemented) involves providing comprehensive mouse/key control, ie. you tell it to move to this position and the client (by way of my newest, and best, mouse algorithm) does it. That provides the following methods:
- SmartClickMouse(x,y: integer; left: boolean): TPoint
- SmartMoveMouse(x,y: integer): TPoint
- SmartDragMouse(x,y: integer): TPoint
- SmartSendKeys(text: String);
- SmartSendKey(code, mills: Integer);
A) No worry about bad events sent to the client
B) Provides high level functionality plus a new algorithm
C) Its the way I've made it so far and will make a quicker release ;)
Disadvantages:
A) All current mouse methods would need to be overridden (Which is not to hard)
B) When sending a key, like an arrow key, you can't do other stuff while its sending
Now, that method is my favourite, and most likely what I will go with, but there is another option. I could provide only low level support for mouse/key functions. Which would be essentialy the same as Scar's low level mouse/key stuff, ie. MoveMouse, HoldMouse, KeyDown, etc.
Advantages:
A) Could replace all exiting low level methods with an include listed before all others overriding Scar's methods
B) Lets you do stuff while holding a key (only reason for holding a mouse would be dragging, which is covered in the last one)
Disadvantages:
A) Hard to control focus on my end.
B) Possible false events caused by not releasing keys/mouse
C) Not having the new algorithm which works almost 100% in java.
So, your feedback on that would be appreciated. Now, about the image, I'm sure most of you will ask how similar it is to just targeting the screen, and I would answer: "Exactly the same." As you know, scar provides a way to set the target bitmap for all color searching functions. So, when using this, no changes to any color related methods will be needed. I've noticed a *slight* preformance increase while using this client since its not rendering to the screen directly, but most of that is counteracted by the background communication. Below are two scripts (which won't work without the rest of it) that give examples of how to use Smart. One is a simple login script, the other gives you a window to see the image from the client in scar (via the debug screen). Think of this as a gift to you scar purists who do not wish to use KYAB, as the two are not compatible… :sasmokin:
ScarScript:By Drunkenoldma [LEFT]program SmartExample; var x, y: integer; {** * Makes the Image created by the client the target of Scar * Note: In Scars older than Divi, this does not change the * result of GetColor. So, upgrade to Divi for that. *} procedure SmartSetTarget; var Smart_Bitmap: Integer; begin //Create a new Bitmap Smart_Bitmap:= BitmapFromString(765,503,''); //Set the Canvas DC to the Java DC GetBitmapCanvas(Smart_Bitmap).Handle:= SmartGetJavaDC; //Tell Scar to target that DC (Only coppies the DC) SetTargetBitmap(Smart_Bitmap); //Free the bitmap since we no longer need it FreeBitmap(Smart_Bitmap); end; {** * Note: Mouse procedures may be off by one pixel, but never * by more than one, ie. never +1,+1 only +1,0 sometimes. * This will be that way and you'll just have to deal with it. * All mouse procedures return where they actualy clicked. *} procedure SmartLogin(user, pass: String); begin //Make sure you add randomness. ie., don't do this SmartClickMouse(450,295,true); wait(1000+Random(500)); //Always use Chr(10) for enter, Chr(13) is NewLine //They ARE different… SmartSendKeys(user+Chr(10)+pass); wait(500+Random(250)); SmartClickMouse(300,320,true); //Wait for the big red button while not(findColor(x,y,584,270,290,500,380)) do wait(100); SmartClickMouse(350,325,true); end; {** * SmartSetupLink is persistant through scripts, so the setup * method only changes something if the postfix is different. * If you get a MessageBox saying a scar is already connected, * that means that either another scar is currently running, * or that another scar did not close its connection. If the * other scar no longer needs this connection, just click yes * and it will reset and take over. Otherwise, it throws an * exception and terminates the script. *} begin //Tells the plugin to connect to the Smart at 'at1' //Only does this if it isn't already, ie it was done //at an earlier time/last script. SmartSetupLink('Smart'); SmartSetTarget; SmartLogin('Name','Pass'); end. [/LEFT]
ScarScript:By Drunkenoldma [LEFT]program SmartImagePipe; {** * Makes the Image created by the client the target of Scar * Note: In Scars older than Divi, this does not change the * result of GetColor. So, upgrade to Divi for that. *} procedure SmartSetTarget; var Smart_Bitmap: Integer; begin //Create a new Bitmap Smart_Bitmap:= BitmapFromString(765,503,''); //Set the Canvas DC to the Java DC GetBitmapCanvas(Smart_Bitmap).Handle:= SmartGetJavaDC; //Tell Scar to target that DC (Only coppies the DC) SetTargetBitmap(Smart_Bitmap); //Free the bitmap since we no longer need it FreeBitmap(Smart_Bitmap); end; begin SmartSetupLink('at1'); SmartSetTarget; DisplayDebugImgWindow(765,503); repeat //Controlls the frame rate. Lower it for a smoother picture Wait(200); //Since the target is set, its now the client canvas. CopyCanvas(GetClientCanvas,GetDebugCanvas,0,0,765,503,0,0,765,503); until False; end. [/LEFT]
By the way, Smart stands for "Scar Minimizing Autoing Resource Thing" in case you were interested ;)
Also, all that is holding back the release are the finishing touches, your feedback, and documentation (depending on whether or not its open source).
In adition to that, I've found that if you make threads with a vague title, people are more prone to read it ;)
EDIT: WHY IS IT SO HARD TO EDIT A POST WITH SCAR TAGS!!!
Smart Beta Release 1 - 16 views
Smart Beta Release 2 - 16 views