SRL Archive - Help and Support

Using Appa to click a image


xtrapsp

2012-11-16 10:41:14

Hey guys,

So I'm trying to get my head around using APPA to click a submit button as appa_SubmitForm(i); didnt work.


One of the solutions I came up with was reclicking the last field and hitting enter. But that didn't work:

          'age': begin appa_FormElementAction(i, a, appa_SendKey, '36' ); writeln('Pressing Enter');end;

and nor does

          'age': begin appa_FormElementAction(i, a, appa_SendKey(36) ); writeln('Pressing Enter');end;


So I resulted to image finding… (Through bitmaps). However… that wouldn't work with the client.



any ideas?

KingKong

2012-11-19 01:47:30

take a look at sahi or selenium theyre both web automation tools

Chris

2012-11-19 07:10:05

Can't you just click on it?
I'm using this function:

procedure MyMouse(a, b: integer; e: boolean);
begin
wait(50 + random(25));
appa_MoveMouse(a, b);
wait(50 + random(50));
appa_HoldMouse(a, b, e);
wait(65 + random(70)); // Wait times aren't really needed though
appa_ReleaseMouse(a, b, e);
wait(50 + random(25));
end;

Or am I understanding you wrong?

Edit:
Just read on the "Appa for Simba" thread that you'd rather not click on an x, y location.
Bitmap finding should be possible using these functions:
var
Client: TBox;
Target: Integer;

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();
Bitmap.Canvas.Pixels[0, 0] := 0;
try
appa_CopyContentToBitmapDC(Bitmap.Canvas.Handle);
GetMufasaBitmap(Target).LoadFromTBitmap(Bitmap);
finally
Bitmap.Free;
end;

SetTargetBitmap(Target);
end;

function appa_FindBitmapIn(bmp: Integer; var x, y: Integer; xs, ys, xe, ye: Integer):boolean;
begin
appa_UpdateBitmap;
Result := FindBitmapIn(bmp, x, y, Client.x1 + xs, Client.y1 + ys, Client.x1 + xe, Client.x1 + ye);
end;

xtrapsp

2012-11-19 08:58:46

Thank you Chris :)