SRL Archive - Extensions

Appa for Simba - A Minimizeable WebClient


nielsie95

2012-05-15 15:02:57

Hey,

This is Appa, a WebClient plugin for SCAR and Simba. Almost three years after the initial release for SCAR comes the initial release for Simba. This plugin is a tweaked version, so no rewrite or port. This means it will only work on x86 Windows. It is still written in Delphi (whereas Simba is written in FreePascal), so I had to overcome some nasty differences between the two languages (hopefully everything still functions properly).

For more information, see the old thread.

Features:
  • Browse the web
  • Simulate mouse and keyboard events
  • Get page source
  • Adjust page source
  • Get screen contents when minimized
  • Block input (kind of useless, but fun :p)
  • Get/Set target in page (useful for flash applets)
  • Submit forms
  • Cookie support
  • Proxy support
  • Frame support

NOTE: the mouse and keyboard simulations do not work for JAVA applets. New versions of flash will also not work.
If you're having some annoying Just-in-time errors go to Internet Explorer and enable "Disable script debugging (other)".

Imports:

procedure SaveBitmapAsJPEG(const Bitmap, w, h, Compression: Integer; const FileName: AnsiString); //SCAR only
function PostHTTPFormData(const URL: AnsiString; const fieldNames, fieldValues, fileFieldNames, fileNames, fileContentType: TStringArray): AnsiString;

procedure appa_Hello(out Result: TStringArray; World: string);
function appa_SetProxy(IP: AnsiString; Port: Integer; ByPass: AnsiString): Boolean;
procedure appa_ShowForm;
function appa_Showing: Boolean;
procedure appa_CloseForm;
function appa_CurrentPage: AnsiString;
function appa_PageState: Integer;
function appa_PageLoaded: Boolean;
procedure appa_Navigate(const URL: AnsiString);

procedure appa_GetTargets(out Result: TStringArray);
procedure appa_SetTargetHandle(const h: Cardinal);
procedure appa_SetTargetFromPoint(const p: TPoint);
function appa_SetTargetName(const Name: AnsiString): Boolean;

procedure appa_KeyDown(const Key: Byte);
procedure appa_KeyUp(const Key: Byte);
procedure appa_SendKey(const Key: Byte);

procedure appa_MoveMouse(const x, y: Integer);
procedure appa_HoldMouse(const x, y: Integer; const Left: Boolean);
procedure appa_ReleaseMouse(const x, y: Integer; const Left: Boolean);

procedure appa_GetSize(out Width, Height: Integer);
procedure appa_SetSize(Width, Height: Integer);
procedure appa_CopyContentToBitmapDC(const bDC: Cardinal);
procedure appa_CopyContentToBitmap(const bIndex: Integer); //SCAR only

procedure appa_GetElements(out Result: TAppaElementArray);
procedure appa_GetForms(out Result: TAppaFormArray);
function appa_ElementAction(const elIndex: Integer; const act: TAppaElementAction; const Param: AnsiString): AnsiString;
function appa_FormElementAction(const FormIndex, elIndex: Integer; const act: TAppaElementAction; const Param: AnsiString): AnsiString;
procedure appa_SubmitForm(const Index: Integer);
procedure appa_ScrollTo(const x, y: Integer);

function appa_GetHTML: AnsiString;
function appa_GetCookies: AnsiString;
procedure appa_SetCookies(const Cookies: AnsiString);
procedure appa_Caption(const s: AnsiString);

function appa_GetFrameCount: Integer;
procedure appa_SetCurrentFrame(Frame: Integer; Nest: Boolean);
procedure appa_ResetFrameNest;

type
TAppaElement = record Box: TBox; innerText, innerHTML, outerHTML, ID, ClassName, Tag: AnsiString; end;
TAppaElementArray = array of TAppaElement;
TAppaFormElement = record outerHTML, ID, ClassName, Tag, Name, Value: AnsiString; end;
TAppaFormElementArray = array of TAppaFormElement;
TAppaForm = record Name, Action, Method: AnsiString; Elements: AppaFormElementArray; end;
TAppaFormArray = array of TAppaForm;
TAppaElementAction = (appa_ScrollIntoView, appa_Click, appa_SetInnerHTML, appa_SetOuterHTML, appa_GetAttribute, appa_SetAttribute, appa_RemoveAttribute, appa_SetValue);

The only thing that has changed to the API is that functions which previously returned an array, now return that array through an out parameter (this was needed to overcome the differences between Delphi and FPC).
Attached is a zip with a version for Simba and a version for SCAR. They both have the same imports, but CopyContentToBitmap and SaveBitmapAsJPEG will only work in SCAR. For CopyContent there's CopyContentToBitmapDC as alternative. This plugin requires Simba 0.99-rc5 or later.

~Nielsie95

Main

2012-05-15 15:04:31

Yes!!!!!!!!!!!!!

I ruv you!

Rezozo

2012-05-15 15:04:39

You Are a boss!

Frement

2012-05-15 15:15:10

I was wondering when you had the time and energy to do this :) Good job!

Runaway

2012-05-15 15:15:28

YES!

I've been waiting (today - release of Simba) years for this! :)

Wizzup?

2012-05-15 15:18:16

Nice work!

By the way, the only reason SaveBitmapAsJPEG is not supported on Simba is because Simba can already save bitmaps as .png and .jpg, just figured I should clarify that. :)

Kyle Undefined

2012-05-15 15:21:43

Oh sweet! I never played with this on SCAR, but I will on Simba. :)

Home

2012-05-15 15:34:29

Great Job Niels!

~Home

euphemism

2012-05-15 16:11:53

niels, you are a wonderful person. Thanks for all the effort you put into the community, or rather, the community's tools. ;)

Chris

2012-05-15 16:24:06

OMG
YOU ARE BOSSSS xD
I have a script for scar which safes the bitmap from Appa in scar and uses sockets to interact with Simba, Simba does the most interesting colour dtm and bitmap finding stuff and sends stuff back…
This will make everything easyer and faster!
This is AWESOME!

Narcle

2012-05-15 16:48:45

AHHH! I love you nielsie <3

Flight

2012-05-15 21:16:39

I've been waiting a long, long time for this. Thank you so very much, Nielsie. :)

Chris

2012-05-16 09:48:17

How do I include this?
In Scar, I used {$L Appa.dll}, this gives me: Exception in Script: Unknown compiler directives at 2:16
And {$I Appa.dll} doesnt work either :s

Flight

2012-05-16 10:03:38


{$loadlib Appa_Simba}

Chris

2012-05-16 10:05:29

From: Flight

{$loadlib Appa_Simba}


Thanks :)

Edit: I've got a new question :s
When I use that loadlib and I press a "." anywhere, it immediately gives an error:
Something went wrong in Simba. If you press OK, Simba will try to save your scripts and then close. (Recommended) See *Path*\ErrorLog_16-05-12_*time*.txt for more information.
Did anyone else get this before?

Edit2: Another question :$
It is possible to use CopyContentToBitmapDC as alternative, but how does this work? I don't know what a cardinal is, but is it possible to convert it to an integer and use it as a normal bitmap to release some color finding functions on it?

Narcle

2012-05-16 13:07:13

@Chris
Was having same problem, you need Simba 0.99.

Chris

2012-05-16 13:14:18

From: Narcle
@Chris
Was having same problem, you need Simba 0.99.


I have installed 0.99-rc5 from: 'http://villavu.com/forum/showthread.php?t=82275' before using it, just like Nielsie95 said in the topic.

NexPB

2012-05-16 13:22:12

Great job on this!

nielsie95

2012-05-16 13:34:18

From: Chris
Thanks :)

Edit: I've got a new question :s
When I use that loadlib and I press a "." anywhere, it immediately gives an error:
Something went wrong in Simba. If you press OK, Simba will try to save your scripts and then close. (Recommended) See *Path*\ErrorLog_16-05-12_*time*.txt for more information.
Did anyone else get this before?

Edit2: Another question :$
It is possible to use CopyContentToBitmapDC as alternative, but how does this work? I don't know what a cardinal is, but is it possible to convert it to an integer and use it as a normal bitmap to release some color finding functions on it?


I'm not sure why the code completion crashes, but I think it is a bug in Simba. Here's how to use CopyContentToBitmapDC:


Target := TBitmap.Create;
Target.Width := TargetSize.x;
Target.Height := TargetSize.y;
Target.Canvas.FloodFill(0, 0, 255, 0); //Do something with the canvas to make sure it is prepared
appa_CopyContentToBitmapDC(Target.Canvas.Handle);

And to load it in a regular bitmap:

bmp := CreateBitmap(TargetSize.x, TargetSize.y);
getMufasaBitmap(bmp).LoadFromTBitmap(Target);

It's not the greatest solution, but it works for now.

Narcle

2012-05-16 13:36:08

Ah yeah, code completion was crashing so I just turned it off while I tested it real quick.

Chris

2012-05-16 15:50:44

Aha thank you so much, Nielsie95 and Narcle
I will try it tomorrow, might have some more questions.
Great release!

Flight

2012-05-16 20:03:48

I used a different approach to grab the client as a bitmap. If any of you remember Home's work on an Appa include, you'll need to do the same thing here. I've been working on this lately:


procedure appa_UpdateBitmap;
var
w,h: Integer;
p: TPoint;
begin
if (not appa_Showing) then
Exit;
Appa_GetSize(w, h);
p := Point(w, h);
if (p.x <> TargetSize.x) or (p.y <> TargetSize.y) then
begin
if (Target > 0) then
begin
try
FreeBitmap(Target);
except
end;
end;
Target := BitmapFromClient(0, 0, w-1, h-1);
TargetSize := p;
SetTargetBitmap(Target);
end;
appa_CopyContentToBitmapDC(Target);
end;

function appa_GetColor(x, y: Integer): Integer;
begin
appa_UpdateBitmap;
Result := GetColor(Client.x1 + x, Client.y1 + y);
end;

Oh yeah, you'll want to define this globally:

var
Client: TBox;
Target: Integer;
TargetSize: TPoint;

Chris

2012-05-17 05:30:45

So I can use it exactly the same as the other CopyContentToBitmap? Nice. :)

Flight

2012-05-18 23:34:42

nielsie95, I'm wondering why appa_KeyDown and appa_KeyUp both do the same thing: press a specific key? Did you do this on purpose? It sure makes capitalizing characters a pain…

nielsie95

2012-05-19 04:24:53

That was also in issue in the previous versions of Appa. They do not do the same thing, but Windows Explorer seems to think otherwise :p
I might have an idea about the cause, so I'll take a look at it later.

Wizzup?

2012-05-19 09:33:17

From: Chris
OMG
YOU ARE BOSSSS xD
I have a script for scar which safes the bitmap from Appa in scar and uses sockets to interact with Simba, Simba does the most interesting colour dtm and bitmap finding stuff and sends stuff back…
This will make everything easyer and faster!
This is AWESOME!


That's a pretty amazing script you have there buddy. :D
[/OffTopic]

bg5

2012-05-19 12:10:49

Thanks, you are amazing , I will look for flash game to try it.

btw.
What do you think about adding appa_GetMousePos(var x ,y : integer); ?

Chris

2012-05-19 12:38:05

Thanks Wizzup, I learned quite much while making it :)

Hmm.. Appa sometimes randomly closes :s
When I use Appa_ShowForm directly after Appa_Showing returned false, it will show the last page it was on.
When Im browsing with it myself, it also happens sometimes.. I click on an URL, it tries to navigate for half a second and then appa disappears…
Any ideas?

momotron

2012-05-23 06:12:42

omg appa for simba!!!! Why did it take me so long to find this!

stuartroad

2012-05-23 06:31:36

Does anyone care to elaborate to as exactly what this is? :|

momotron

2012-05-23 07:35:54

On OP there's a link that says other threads, click on them.

Chris

2012-05-23 07:56:24

From: stuartroad
Does anyone care to elaborate to as exactly what this is? :|


We have SMART to automate RuneScape minimized, and now APPA to automate anything through the browser minimized, APPA is a browser which you can handle through Simba basically

But does anyone know what could cause APPA to disappear? I use Appa_ShowForm in the beginning, and if I call Appa_ShowForm again after Appa_Showing returned false, which happens after some browsing, it will show up again with the last page it was on. But after some seconds it will disappear again and I have no idea why.

dogtoy12

2012-05-23 11:00:13

So why is this useful for anything that SMART cannot do? It can automate anything in a browser? Oooooh could this possibly work for private servers?

Flight

2012-05-23 12:09:31

From: dogtoy12
So why is this useful for anything that SMART cannot do? It can automate anything in a browser? Oooooh could this possibly work for private servers?


SMART is limited to Runescape, Simba is not. Appa does for a web browser what SMART does for Runescape.

dogtoy12

2012-05-23 13:15:22

Thank you very much for explaining rep+
Three words to creator, I. love. You.

dogtoy12

2012-05-23 13:53:14

"NOTE: the mouse and keyboard simulations do not work for JAVA applets. New versions of flash will also not work.
If you're having some annoying Just-in-time errors go to Internet Explorer and enable "Disable script debugging (other)"."
So this would not be of any use to a private server or runescape itself? Also if anyone could provide an alternative/idea of how to get something similar to "SMART" for a runescape private server? (soulsplit) thank you

Dgby714

2012-05-24 10:58:00

From: Flight
procedure appa_UpdateBitmap;
var
w,h: Integer;
p: TPoint;
begin
if (not appa_Showing) then
Exit;
Appa_GetSize(w, h);
p := Point(w, h);
if (p.x <> TargetSize.x) or (p.y <> TargetSize.y) then
begin
if (Target > 0) then
begin
try
FreeBitmap(Target);
except
end;
end;
Target := BitmapFromClient(0, 0, w-1, h-1);
TargetSize := p;
SetTargetBitmap(Target);
end;
appa_CopyContentToBitmapDC(Target);
end;


procedure appa_UpdateBitmap;
var
w1, h1, w2, h2: Integer;
begin
if (not appa_Showing) then
Exit;
Appa_GetSize(w1, h1);

if (Target = 0) then
Target := CreateBitmap(w1, h1);

GetBitmapSize(Target, w2, h2);

if ((w1 <> w2) or (h1 <> h2)) then
SetBitmapSize(Target, w1, h1);

appa_CopyContentToBitmapDC(Target);
end;

nielsie95

2012-05-24 11:13:34

You have to pass a DC (see my example) :)

Dgby714

2012-05-24 11:58:15

From: nielsie95
You have to pass a DC (see my example) :)


Is this better?

procedure appa_UpdateBitmap();
var
w1, h1, w2, h2: Integer;
Bitmap: TBitmap;
begin
if (not (appa_Showing())) then
Exit;

appa_GetSize(w1, h1);

if (Target = 0) then
Target := CreateBitmap(w1, h1);

GetBitmapSize(Target, w2, h2);

if ((w1 <> w2) or (h1 <> h2)) then
SetBitmapSize(Target, w1, h1);

Bitmap := GetMufasaBitmap(Target).ToTBitmap();
try
appa_CopyContentToBitmapDC(Bitmap.Canvas.Handle);
GetMufasaBitmap(Target).LoadFromTBitmap(Bitmap);
finally
Bitmap.Free;
end;

SetTargetBitmap(Target);
end;

nielsie95

2012-05-24 13:29:11

You should only free the bitmap if you are sure it is assigned, so you'd have to move the assignment out of the try block ;)

Dgby714

2012-05-25 10:31:10

From: nielsie95
You should only free the bitmap if you are sure it is assigned, so you'd have to move the assignment out of the try block ;)


Ooops =P

Chris

2012-05-25 11:08:04

From: Dgby714
Ooops =P


I have tried your appa_UpdateBitmap procedure, but it doesnt work.
Im using the functions this way:
function appa_GetColor(x, y: Integer): Integer;
begin
appa_UpdateBitmap;
Result := GetColor(Client.x1 + x, Client.y1 + y)
end;

Dgby714

2012-05-26 08:15:37

From: Chris
I have tried your appa_UpdateBitmap procedure, but it doesnt work.
Im using the functions this way:
function appa_GetColor(x, y: Integer): Integer;
begin
appa_UpdateBitmap;
Result := GetColor(Client.x1 + x, Client.y1 + y)
end;


Updated it, I forgot the "SetTargetBitmap(Target);" =P

Flight

2012-05-26 08:54:28

From: Dgby714
Updated it, I forgot the "SetTargetBitmap(Target);" =P


I like yours better. Thanks for the help, Dg.

Chris

2012-05-27 17:33:48

From: Dgby714
Updated it, I forgot the "SetTargetBitmap(Target);" =P


Ye I noticed that and tried it again after adding that line, it still didnt work.
Im not too much online with this beatifull weather here in Holland, but if I have some time tomorrow I will make a basic script to check if its something else in my script or my settings.

nielsie95

2012-05-28 03:29:34

You have to somehow "activate" the canvas. For example, try adding this right before CopyContentToBitmapDC:

Bitmap.Canvas.Pixels[0, 0] := 0;

I uploaded a new version. In this version I added appa_SendKey, which sends a character (and handles shift/control). I also adjusted appa_KeyDown/appa_KeyUp to do what they are supposed to do. If you want to send a character, make sure you use SendKey (also make sure you are blocking input while running).

Chris

2012-05-28 11:36:43

From: nielsie95
You have to somehow "activate" the canvas. For example, try adding this right before CopyContentToBitmapDC:

Bitmap.Canvas.Pixels[0, 0] := 0;

I uploaded a new version. In this version I added appa_SendKey, which sends a character (and handles shift/control). I also adjusted appa_KeyDown/appa_KeyUp to do what they are supposed to do. If you want to send a character, make sure you use SendKey (also make sure you are blocking input while running).


Thanks, that solved it :)
And I had a problem where Appa would disappear, but Ive edited the wait time after using Appa_SetCookies(); and that solved it. After that function it would use Appa_FindColorTolerance();.. Might be some kind of bug.

And Im using:
function appa_NavigateTo(URL: string; TimeOut: Integer): Boolean;
var
t: Integer;
begin
Result := False;
if (not appa_Showing) then
Exit;
if (URL <> '') then
appa_Navigate(URL);
t := GetSystemTime + TimeOut;
while (not appa_PageLoaded) and appa_Showing and (GetSystemTime > t) do
Wait(250);

Result := appa_PageState >= 3;
end;

But this doesnt wait until the new page is showing, how do I make it wait untill the page is loaded and showing so that Appa_UpdateBitmap right after it will give the new page?


Edit:
If my script sends the key 'o', (appa_SendKey(GetKeyCode('o'));) while I hold ctrl myself because Im just working on my pc, Appa will see it like ctrl + o which gives the "open" screen causing Appa to stop.
I do have Block Input enabled. Is there a way to avoid this? (except not using ctrl) ^^

bg5

2012-05-28 19:19:01

I set Flash applet as target , but APPA returns bitmap of whole window. My code:
http://pastebin.com/gGWsLTai

it's because flash version ( 11.2.202.235) ?To what version should i downgrade Flash?

nielsie95

2012-05-29 03:41:32

From: Chris
Thanks, that solved it :)
And I had a problem where Appa would disappear, but Ive edited the wait time after using Appa_SetCookies(); and that solved it. After that function it would use Appa_FindColorTolerance();.. Might be some kind of bug.

But this doesnt wait until the new page is showing, how do I make it wait untill the page is loaded and showing so that Appa_UpdateBitmap right after it will give the new page?

Edit:
If my script sends the key 'o', (appa_SendKey(GetKeyCode('o'));) while I hold ctrl myself because Im just working on my pc, Appa will see it like ctrl + o which gives the "open" screen causing Appa to stop.
I do have Block Input enabled. Is there a way to avoid this? (except not using ctrl) ^^

Unfortunately, I can't give more information on the page state than I'm currently giving. That ctrl + o sounds very annoying indeed, but I'm not sure how to fix it.

From: beginner5
I set Flash applet as target , but APPA returns bitmap of whole window. My code:
http://pastebin.com/gGWsLTai

it's because flash version ( 11.2.202.235) ?To what version should i downgrade Flash?

See the example in my previous thread. It will always return a bitmap of the whole window, but you can get the client offset.

Chris

2012-05-29 05:22:51

Ok, one last thing:
When I get a JavaScript alert, It wont be in able to click it away. It causes an access violation error. I wont be in able to click it away neither because I have block input on and cant turn it off as the alert stays in front of Appa. Turning JavaScript off works, but the game I am using the script for uses JavaScript so I cant do anything with JavaScript disabled. Would it be possible to add a procedure like: Appa_JavaScript(Enable:Boolean); to enable/disable it?
Everything else works perfect! (Y)

nielsie95

2012-05-29 06:12:18

You can't enable JavaScript halfway. It's either on or off during page rendering. Or isn't that what you mean?

Chris

2012-05-29 06:47:27

No thats not what I mean. In IE, you can disable JS in the options. If I disable JS and then navigate to the page showing an alert then the alert wont show up but the other non-JS stuff will only be shown. If I then enable it and go to another page then everything will be normal and I wont get the access violation error is what I thought

nielsie95

2012-06-02 17:03:58

It's worth considering. I don't think I'll look into it any time soon, though.

Chris

2012-06-04 14:18:38

Ok, a more annoying problem is Appa sometimes disappearing. It seems to happen when Appa_Navigate is called but it sometimes runs for ~ 10 minutes and sometimes it happens after 10 seconds.
Yesterday I had my script paused after it ran for 3 minutes. 15 seconds after pausing the script and without touching Simba or Appa, Appa disappeared…
It seems to happen on pages which are using JavaScript, Ill collect some more information :s

Velvet Glam

2012-06-07 12:40:51

From: Chris
Ok, a more annoying problem is Appa sometimes disappearing. It seems to happen when Appa_Navigate is called but it sometimes runs for ~ 10 minutes and sometimes it happens after 10 seconds.
Yesterday I had my script paused after it ran for 3 minutes. 15 seconds after pausing the script and without touching Simba or Appa, Appa disappeared…
It seems to happen on pages which are using JavaScript, Ill collect some more information :s


What website are you navigating to?

ALSO: this is the best thing to hit simba

Chris

2012-06-07 13:16:09

From: Velvet Glam
What website are you navigating to?

ALSO: this is the best thing to hit simba


I am not going to post it here, if an SRL Member+ wants to look into it, pm me.
I dont want people in the game to google 'GAMENAME + script' and get this as result ;)

Velvet Glam

2012-06-07 14:50:32

From: Chris
I am not going to post it here, if an SRL Member+ wants to look into it, pm me.
I dont want people in the game to google 'GAMENAME + script' and get this as result ;)


Send me a PM with it, I am looking for something to code in simba :)

Chris

2012-06-07 16:04:00

Im sorry but I wont. Appa keeps disappearing so it wont work for you to write something for it.
Ill give one hint ;)
hint: Its a pretty large mafia game. Not going to say more about it

LordJashin

2012-06-24 17:54:08

Couldn't get appa_CurrentPage; or appa_GetHTML; to work.


Is appa_FormElementAction broke? What am I doing wrong, this actually does what its supposed to do but then it STOPS right after the appa_FormElementAction, it doesn't do anything after that. Forms still open and sitting there.

appa_GetForms(Forms);
for i := 0 to high(Forms[1].Elements) do
if Lowercase(Forms[1].Elements[i].outerHTML) = LowerCase('<INPUT id=loginForm_default_input_username class=loginForm_default_input type=text name=loginForm_default_username>') then
begin
appa_FormElementAction(1, i, appa_SetValue, Players[0].Login);
WriteLn('Fuckin bullshit');
end;
appa_CloseForm;

nielsie95

2012-06-27 10:25:04

From: Chris
Im sorry but I wont. Appa keeps disappearing so it wont work for you to write something for it.
Ill give one hint ;)
hint: Its a pretty large mafia game. Not going to say more about it

I can't really reproduce this.. Is it really random or does it happen after certain commands?

From: LordJashin
Couldn't get appa_CurrentPage; or appa_GetHTML; to work.


Is appa_FormElementAction broke? What am I doing wrong, this actually does what its supposed to do but then it STOPS right after the appa_FormElementAction, it doesn't do anything after that. Forms still open and sitting there.

appa_GetForms(Forms);
for i := 0 to high(Forms[1].Elements) do
if Lowercase(Forms[1].Elements[i].outerHTML) = LowerCase('<INPUT id=loginForm_default_input_username class=loginForm_default_input type=text name=loginForm_default_username>') then
begin
appa_FormElementAction(1, i, appa_SetValue, Players[0].Login);
WriteLn('Fuckin bullshit');
end;
appa_CloseForm;


Could you give me some small scripts to reproduce these errors?

Chris

2012-06-27 12:26:08

I have made a little script which reproduces it, Ill pm it you now.

LordJashin

2012-06-27 14:16:10

There:

Note: If it says out of range, then the page didn't load or w/e so just try again.

procedure SF_SetupAPPA;
var
Forms: TAppaFormArray;
I: Integer;
begin
appa_ShowForm;
wait(2000);
appa_Navigate('seafight.com');
wait(5000);
appa_GetForms(Forms);
for i := 0 to high(Forms[1].Elements) do
if Lowercase(Forms[1].Elements[i].outerHTML) = LowerCase('<INPUT id=loginForm_default_input_username class=loginForm_default_input type=text name=loginForm_default_username>') then
begin
appa_FormElementAction(1, i, appa_SetValue, 'Testing');
WriteLn('tested');
end;
appa_CloseForm;
end;

begin
SF_SetupAPPA;
end.

nielsie95

2012-06-27 14:36:46

I had to change the string to '<INPUT id=loginForm_default_input_username class=loginForm_default_input name=loginForm_default_username type=text>' to make sure it got to the FormElementAction, but it did work on both Simba and SCAR. appa_CurrentPage and appa_GetHTML also seem to return the correct results.

Not sure what could be causing your problems, but if I cannot reproduce it, it will be pretty hard to fix. Does Simba output any information in the console? What version of Windows/IE are you using? And do you have administrator rights?

Can anyone else test the above scripts?

LordJashin

2012-06-27 15:58:18

From: nielsie95
I had to change the string to '<INPUT id=loginForm_default_input_username class=loginForm_default_input name=loginForm_default_username type=text>' to make sure it got to the FormElementAction, but it did work on both Simba and SCAR. appa_CurrentPage and appa_GetHTML also seem to return the correct results.

Not sure what could be causing your problems, but if I cannot reproduce it, it will be pretty hard to fix. Does Simba output any information in the console? What version of Windows/IE are you using? And do you have administrator rights?

Can anyone else test the above scripts?


Windows XP 32bit, I.E. 8.

SCAR:

Line 1: Internal Error
[PS] An internal error occurred while running

Simba: Is there any packages you need to get for Lazarus?

EDIT: ..\..\Units\MMLAddon\mmlpsthread.pas(96,12) Fatal: Can't find unit lpparser used by mmlpsthread

LordJashin

2012-06-27 16:59:54

Odd this seems to work for Simba 99rc6:


program aaa;
{.loadlib APPA}
procedure SF_SetupAPPA;
var
Forms: TAppaFormArray;
I: Integer;
begin
appa_ShowForm;
wait(2000);
appa_Navigate('seafight.com');
wait(5000);
appa_GetForms(Forms);
for i := 0 to high(Forms[1].Elements) do
if Lowercase(Forms[1].Elements[i].outerHTML) = LowerCase('<INPUT id=loginForm_default_input_username class=loginForm_default_input type=text name=loginForm_default_username>') then
begin
appa_FormElementAction(1, i, appa_SetValue, 'Testing');
WriteLn('tested');
end;
wait(5000);
appa_CloseForm;
end;

begin
SF_SetupAPPA;
end.

Just fine too. Why doesn't this work on SCAR…

nielsie95

2012-06-27 18:42:31

From: LordJashin
Windows XP 32bit, I.E. 8.

SCAR:

Line 1: Internal Error
[PS] An internal error occurred while running

Simba: Is there any packages you need to get for Lazarus?

EDIT: ..\..\Units\MMLAddon\mmlpsthread.pas(96,12) Fatal: Can't find unit lpparser used by mmlpsthread

Also check out the submodules.

From: LordJashin
Odd this seems to work for Simba 99rc6:


program aaa;
{.loadlib APPA}
procedure SF_SetupAPPA;
var
Forms: TAppaFormArray;
I: Integer;
begin
appa_ShowForm;
wait(2000);
appa_Navigate('seafight.com');
wait(5000);
appa_GetForms(Forms);
for i := 0 to high(Forms[1].Elements) do
if Lowercase(Forms[1].Elements[i].outerHTML) = LowerCase('<INPUT id=loginForm_default_input_username class=loginForm_default_input type=text name=loginForm_default_username>') then
begin
appa_FormElementAction(1, i, appa_SetValue, 'Testing');
WriteLn('tested');
end;
wait(5000);
appa_CloseForm;
end;

begin
SF_SetupAPPA;
end.

Just fine too. Why doesn't this work on SCAR…

Maybe it has to do with the version of SCAR. I tested with a pretty old version (3.20d) and Freddy made some changes to the plugin system after that, if I recall correctly.

LordJashin

2012-06-27 22:29:18

Well I know how it works. He fixed it totally in 3.33 "The error with scar not being able to register functions was a bug in the type exporting routine in scar 3.32 its fixed in scar 3.33 b".

The link to Freddy's example plugin: http://svn.scar-divi.com/scar_shellutils/

Some of Freddy's comments on it here: http://forums.scar-divi.com/showthread.php?1224-Type-exporting-in-Plugins

oo Legacy stuff here, has the most stuff: http://svn.scar-divi.com/samples/libraries/legacy/delphi/

You have to include the SCARLibSetup everywhere. ShadowRecon made a plugin for SCAR his is located here if you want to look at how he did it.

Maybe I should go download SCAR 3.22 portable again and try that lols. I could also play some MastaMario.


Edit: 6/29/12 - I can't get this to work on either of the DLL's old scar one, and new. So I guess I'll do everything with Simba.

Le Jingle

2012-07-22 18:33:51

Both of what I'm mentioning have been mentioned, but I didn't see reply's to the comments;

1. Is there anywhere to see appa's source or is that a no-go?
2. Any chance on adding "procedure appa_GetMousePos(var x: LongInt; vary: LongInt);"?

I'm having a blast with flash game stuffs, hopefully can create a decent full flash-game type thingy. :>

Cheers

Flight

2012-07-26 12:26:13

Nielsie, I've a couple of questions and I'm not sure how difficult each would be.

First off, would it be possible in the future to have a canvas included with Appa for painting and such? I'd sure like to have a printed cursor like we see in SMART.

The second question is kinda difficult to explain. I'm not sure the exact name but Appa uses modules or the API from Internet Explorer, yes? Would it be possible to use Firefox or Chrome instead?

Le Jingle

2012-07-26 13:08:30

From: Home
Hey is it possible, that we could get the source :) Because would be great if it could use Firefox Engine :) ( So it can be converted to use Simba too ) :)


~Home


From: Smartzkid
The code would probably be so different that it would make more sense to start over.


http://villavu.com/forum/showthread.php?t=45534

Chris

2012-10-18 09:21:16

This is worth a bump.

My only problem is that it can't click on a JS alert and thus can't close it..

rj

2012-10-29 16:17:40

so wait… it can't run java or flash applications? LMFAO I reallllly dont mean to be a straight up asshole, THEN WHATS THE POINT?

Yago

2012-10-29 18:06:34

From: rjj95
so wait… it can't run java or flash applications? LMFAO I reallllly dont mean to be a straight up asshole, THEN WHATS THE POINT?


You can web browse… If anything, just run a VM

Chris

2012-10-30 07:58:38

From: rjj95
so wait… it can't run java or flash applications? LMFAO I reallllly dont mean to be a straight up asshole, THEN WHATS THE POINT?


There are other things you can do on the internet, other than java/flash games.

xtrapsp

2012-11-16 07:39:43

I'm not sure if you are aware but appa_SubmitForm Doesn't seem to work…

edit:

is it possible to make it click a HTML element rather than an x,y location?


KingKong

2012-11-19 01:48:38

villavu.com/forum/showpost.php?p=1129323&postcount=2

night fox6928

2012-12-14 20:27:01

where do i save it to?

Chris

2013-02-14 04:47:34

I've found a bug with appa_GetHTML,
Running this will give me an Access violation ('Access violation at address 056D1B88 in module 'Appa_Simba.dll'. Read of address 00000000.')
Apparently, when appa_GetHTML is called while the page is being parsed, it'll error.
Since my script can't exactly know when the page is loaded, I get this error once every 1-2 hours.

If you have some time, could you please have a look at it?

program new;       {$loadlib Appa_Simba.dll}

procedure appa_NavigateTo(URL: string; TimeOut: Integer);
begin
if (not appa_Showing) then
Exit;
if (URL <> '') then
appa_Navigate(URL);
end;

procedure Test;
var
Page: string;
i: Integer;
begin
if not(appa_Showing) then
begin
appa_ShowForm;
appa_SetSize(500, 600);
end;
appa_NavigateTo('google.com', 10000);
repeat
inc(i);
Page := appa_GetHTML;
Writeln('Try #' + inttostr(i));
until False;
end;

begin
Test;
end.

nielsie95

2013-02-26 05:06:36

Use PageState/PageLoaded in appa_NavigateTo to wait while loading. I have an example appa_NavigateTo in the first post of the old thread :)

Smurfz

2013-02-26 14:53:03

Is there anyway to use this to get Elements/set values of Flash, like a website that just has an object swf that is flash

Chris

2013-02-26 19:21:10

Yes, that solves the problem in the script I posted, though when my script clicks on a button that links to a new page, and that page redirects you to another page.. Then when my script tries to get the HTML, it errors.

Same thing when it clicks on a button.
Try this out:
program new; {$loadlib Appa_Simba.dll}


procedure WaitForPage;
var
t: Integer;
begin
t := GetSystemTime + 10000; // The page sometimes doesn't load fully
while (not appa_PageLoaded) and appa_Showing and (GetSystemTime < t)do
Wait(10); // With 250, it could also finish on the same state,
// so with the same error.
end;

procedure appa_NavigateTo(URL: string; TimeOut: Integer);
begin
if (not appa_Showing) then
Exit;
if (URL <> '') then
appa_Navigate(URL);
WaitForPage;
end;

procedure TestSubmit;
{var
f: TAppaFormArray;
foo, bar: Integer;}
begin
{appa_GetForms(f);
for foo := High(f) downto 0 do
for bar := 0 to High(f[foo].Elements) do
writeln('#' + inttostr(bar) + f[foo].Elements[bar].Name);
}
appa_FormElementAction(1, 2, appa_SetValue, 'email');
appa_FormElementAction(1, 3, appa_SetValue, 'password');
appa_SubmitForm(1);
end;

procedure Test;
var
i: Integer;
begin
if not(appa_Showing) then
begin
appa_ShowForm;
appa_SetSize(500, 600);
end;

appa_NavigateTo('https://www.yola.com/login', 10000);
wait(300 + random(200));
appa_scrollto(342, 260);
TestSubmit;
WaitForPage;

for i := 0 to 50 do
begin
wait(10);
appa_GetHTML;
Writeln(inttostr(appa_PageState) + ' Try #' + inttostr(i));
end;
end;

begin
Test;
end.

I don't have a clue about what you can do in Delphi, but I was thinking about this kind of function:

function Appa_GetHTML(out HTML: string): Boolean; // Returns whether the HTML was successfully taken or not

Smurfz

2013-02-27 14:35:51

@Chris

as far as I know you cannot do your TestSubmit;, without having appa_GetForms(f); uncommented that could be giving you errors

also for the getHTML just do a if HTML = '' then…

Chris

2013-02-27 18:26:10

From: Smurfz
@Chris

as far as I know you cannot do your TestSubmit;, without having appa_GetForms(f); uncommented that could be giving you errors

also for the getHTML just do a if HTML = '' then…


The Appa_GetForms was only needed to see what the Form and the Element Index' are, I then copied those to the Appa_FormElementAction procedures.
That procedure only needs those index' and won't give errors in my script.

The thing about Appa_GetHTML is that it gives Appa an access violation when I call it on the wrong moment. I thought that maybe nielsie can do some fancy stuff in the plugin, basically something like this:
DelphiFunction Appa_GetHTML(out Html: string): Boolean;
var
IE: TINTERNETEXPLORER;
begin
Result := True;
IE := GetFancyIECoreStoof;
try
Html := IE.PageInfo.HTML;
except
Result := False;
end;
end;
Instead of this:
DelphiFunction Appa_GetHTML: string;
begin
Result := GetFancyIECoreStoof.PageInfo.HTML;
end;
Though I don't know how your plugin works or what you could do to solve the problem :p
(A)

Narcle

2013-04-23 12:28:29

Anyone know the newest version of Flash this works with?

stata

2013-08-27 14:41:00

Working for me with a game that uses flash 8

riwu

2013-10-29 04:09:13

@nielsie95
A few bugs:
When blocking input, appa_KeyDown/Up cannot be sent through the form.
appa_SendKey() works but it types slow…(you added a wait in it?)

When not blocking input, appa_SendKey() would actually type twice (eg. appa_SendKey(VK_1) would type '1' twice).

I have this annoying pop up that comes up once in a while
which does not occur if i leave my computer alone overnight, hence it must be due to something that i typed while in other window (or just as i switch to the form) that get transmitted to the form somehow, so blocking input would fix the problem. Any idea what keys trigger that popup though?


Other than these, the app is amazing! Another great work nielsie :)

bg5

2013-10-29 09:16:39

From: riwu
@nielsie95
A few bugs:
When blocking input, appa_KeyDown/Up cannot be sent through the form.
appa_SendKey() works but it types slow…(you added a wait in it?)



Weird ,in my appa there is no function appa_SendKey(). Don't you use .simba include?
However, there are appa_KeyDown() and appa_KeyUp() functions, which both works exactly as SendKey. So if I had function like:

procedure SendKey(key:byte);
begin
appa_KeyDown(key); // prints key
wait();
appa_KeyUp(key); // prints key
end;

it would always print key twice.

Also, I don't have issue with blocking input, but for flash games direct keyboard input doesn't work at all (except - it can write on nested label of flash.text.TextField class).

riwu

2013-10-29 10:13:26

From: bg5
Weird ,in my appa there is no function appa_SendKey(). Don't you use .simba include?
However, there are appa_KeyDown() and appa_KeyUp() functions, which both works exactly as SendKey. So if I had function like:

procedure SendKey(key:byte);
begin
appa_KeyDown(key); // prints key
wait();
appa_KeyUp(key); // prints key
end;

it would always print key twice.

Also, I don't have issue with blocking input, but for flash games direct keyboard input doesn't work at all (except - it can write on nested label of flash.text.TextField class).

Hmm do you have the latest version?
The built-in SendKeys() won't allow u to alt tab (it will type in whichever window that has keyboard focus).

Does appa_KeyDown/Up work for you when u have block input ticked?

EDIT: weird appa_KeyDown(VK_BACK) works with input blocked, but VK_1, VK_A etc don't work when input is blocked.

bg5

2013-10-29 19:24:36

From: riwu
Hmm do you have the latest version?
The built-in SendKeys() won't allow u to alt tab (it will type in whichever window that has keyboard focus).

Does appa_KeyDown/Up work for you when u have block input ticked?

EDIT: weird appa_KeyDown(VK_BACK) works with input blocked, but VK_1, VK_A etc don't work when input is blocked.


Well, I used old APPA from this thread. I've downloaded current version and it has appa_SendKey indeed. My old version has functions like below.
[ATTACH=CONFIG]22353[/ATTACH]
[ATTACH=CONFIG]22354[/ATTACH]

Yes KeyDown/Up works with blocked input (any key), however as I said, it's bugged and both works like SendKey, so you can't hold key down to use combination like alt-tab.

For what you need alt-tab? Maybe it can be done another way.


I've attached my old APPA if you were curious about it.
[ATTACH]22355[/ATTACH]

Chris

2013-10-30 06:17:04

From: riwu
@nielsie95
A few bugs:
When blocking input, appa_KeyDown/Up cannot be sent through the form.
appa_SendKey() works but it types slow…(you added a wait in it?)

When not blocking input, appa_SendKey() would actually type twice (eg. appa_SendKey(VK_1) would type '1' twice).

I have this annoying pop up that comes up once in a while
which does not occur if i leave my computer alone overnight, hence it must be due to something that i typed while in other window (or just as i switch to the form) that get transmitted to the form somehow, so blocking input would fix the problem. Any idea what keys trigger that popup though?


Other than these, the app is amazing! Another great work nielsie :)


The pop-up occurs when you type something like Ctrl + S or Ctrl + D. When Appa types the S or D while you hold Ctrl yourself, it will be sent as ctrl + S/D. Even, for some reason, when you have block input on.


E:
I used this:
procedure TypeKeyz(Text:string);
var i:integer;
begin
for i := 1 to (Length(Text)) do
begin
Wait(30 + Random(20));
if IsKeyDown(17) then // 17 = ctrl button
repeat
writeln('Waiting until the control key is up.');
wait(100);
until not(IsKeyDown(17));
appa_KeyDown(GetKeyCode(Text[i]));
wait(20 + random(15));
//appa_KeyUp(GetKeyCode(Text[i]));
end;
end;
But I still had some of those pop-ups once in a while, which completely block Appa.
appa_KeyUp is commented out because the KeyDown and KeyUp both acted like PressKey.

lilkittenz2

2014-01-11 17:25:15

I have a few questions. I remember using functions like Appa_FindColor and Appa_CountColor along with other searching functions specific to the Appa client. Whatever happened to these? Simba's regular FindColor function works on the Appa client in the background, as long as it isn't minimized (I have no idea why the regular FindColor function is usable in the background like this when there are other windows blocking it.)

On a friends computer the regular color search functions do not work with Appa in the background. If a window is in front of the Appa client simba does not find the colors/bitmaps on his computer. I am stumped as to why those functions work in the background of my computer but not his. We both have the most recent versions of Simba and Appa.

One last problem. When I tell my script to wait until appa_PageLoaded is true, it never does. Is this feature broken? Is there another way to check if the page has loaded on Appa?

bg5

2014-01-11 20:50:18

From: lilkittenz2
I have a few questions. I remember using functions like Appa_FindColor and Appa_CountColor along with other searching functions specific to the Appa client. Whatever happened to these?


Propably you were using some include. The only APPA function relating with color finding is to make screenshot of it's own window and send it to simba.

Simba's regular FindColor function works on the Appa client in the background, as long as it isn't minimized (I have no idea why the regular FindColor function is usable in the background like this when there are other windows blocking it.)


Any regular client (which you select by puting Simba's cross on it) should have accesible image while in background. I have no idea why on your friend's computer it doesn't work.

One last problem. When I tell my script to wait until appa_PageLoaded is true, it never does. Is this feature broken? Is there another way to check if the page has loaded on Appa?


For me it's broken too. I think you can make it with javascript (as well as a lot of other features!).

http://villavu.com/forum/showthread.php?t=106479

lilkittenz2

2014-01-12 01:20:57

Thank you for the help. It was an include that I was using before. I'm assuming you are referring to appa_CopyContentToBitmap. I've never used that function before but I'm working on figuring it out as I type this.

I'd like to be able to make stuff like that for appa with javascript, unfortunately I'm still very much a newbie at scripting.

Clarity

2014-09-23 12:48:40

I have tried to use this to access certain webpages but am denied because the browser is out of date. How would one change the browser used to a more recent one?

nielsie95

2014-09-23 13:47:26

Update Internet Explorer through Windows Update.

Clarity

2014-09-23 14:28:43

From: nielsie95
Update Internet Explorer through Windows Update.

Already tried this, when opening the webpage via Internet Explorer (no appa) it loads fine with no error.

bg5

2014-09-23 14:32:22

From: nielsie95
Update Internet Explorer through Windows Update.


Hey nielsie,

would it be possible to fix that bug, in which appa_KeyDown and appa_KeyUp both works like PressKey ? Many flash games uses keyboard to control and this bug makes usage of APPA very limited in those cases.

StevenV

2014-12-22 09:33:43

So i've started using appa for a flash game.
In the game certain menu open when you put the mouse on it. But when appa puts it's mouse on it, nothing happens.
Is there a way to let it activate the trigger?

thx

riwu

2014-12-22 20:11:24

From: StevenV
So i've started using appa for a flash game.
In the game certain menu open when you put the mouse on it. But when appa puts it's mouse on it, nothing happens.
Is there a way to let it activate the trigger?

thx


NOTE: the mouse and keyboard simulations do not work for JAVA applets. New versions of flash will also not work.

So unless ur game supports older versions of flash, u cannot use the mouse simulations for it.

StevenV

2014-12-23 05:06:45

all the other thing it does fine. But it's just when it moves his mouse on the item the popup menu doesn't show.

But if i install an older flash version it might work?
Wich flash version should i use then?