Registriert seit: 10. Nov 2013
83 Beiträge
|
AW: How draw password on remote smartphone with mouse?
1. Sep 2018, 17:38
Considering the last suggestion i made this following code in my project but generates a exception on Android code:
Zitat:
java.lang.IllegalStateException: Attempting to add too many strokes to a gesture
in this line:
Code:
gestureBuilder.addStroke(new GestureDescription.StrokeDescription(path, 100, time));
Delphi-Quellcode:
private
{ Private declarations }
fDown: Boolean;
fPO: TPoint;
public
{ Public declarations }
end;
...
procedure TForm2.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Index, XTouch, YTouch, RXCoord, RYCoord: Integer;
List: TStrings;
RScreen, MoveTo: String;
begin
Index := Form1.ListView1.ItemIndex;
if Index = -1 then
Exit;
List := TStringList.Create;
RScreen := Form1.ListView1.Selected.SubItems[6]; // Remote screen resolution
try
ExtractStrings(['x'], [], PChar(RScreen), List); // Ex: my smartphone is 1920x1080
RYCoord := StrToInt(List[0]); // 1920 (height)
RXCoord := StrToInt(List[1]); // 1080 (width)
finally
List.Free;
end;
XTouch := Round((X / Image1.Width) * RXCoord);
YTouch := Round((Y / Image1.Height) * RYCoord);
fPO := Point(XTouch, YTouch);
MoveTo := 'moveto';
fDown := true;
Form1.ServerSocket1.Socket.Connections[Index].SendText(format('mouseswipescreen%d<|>%d<|>%s'#13#10, [fPO.X, fPO.Y, MoveTo]));
end;
procedure TForm2.Image1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
Index, XTouch, YTouch, RXCoord, RYCoord: Integer;
List: TStrings;
RScreen, SwipeTo: String;
begin
Index := Form1.ListView1.ItemIndex;
if Index = -1 then
Exit;
List := TStringList.Create;
RScreen := Form1.ListView1.Selected.SubItems[6]; // Remote screen resolution
try
ExtractStrings(['x'], [], PChar(RScreen), List); // Ex: my smartphone is 1920x1080
RYCoord := StrToInt(List[0]); // 1920 (height)
RXCoord := StrToInt(List[1]); // 1080 (width)
finally
List.Free;
end;
XTouch := Round((X / Image1.Width) * RXCoord);
YTouch := Round((Y / Image1.Height) * RYCoord);
if fDown then
begin
SwipeTo := 'swipeto';
Form1.ServerSocket1.Socket.Connections[Index].SendText(format('mouseswipescreen%d<|>%d<|>%s'#13#10, [fPO.X, fPO.Y, SwipeTo]));
fPO := Point(XTouch, YTouch);
end;
end;
procedure TForm2.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if fDown then
fDown := false;
end;
Android:
Code:
if (xline.contains("swipescreen")) {
String coordenates = xline.replace("swipescreen", "");
String[] tokens = coordenates.split(Pattern.quote("<|>"));
float x = parseFloat(tokens[0]);
float y = parseFloat(tokens[1]);
String cmd = tokens[2];
MyAccessibility.instance.Swipte((int) x, (int) y, 50, cmd);
}
Code:
GestureDescription.Builder gestureBuilder;
Path path;
public void Swipte(int x, int y, int time, String command) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
System.out.println(" ======= Swipte =======");
if (command.equalsIgnoreCase("moveto")) {
gestureBuilder = new GestureDescription.Builder();
path = new Path();
path.moveTo(x, y);
} else if (command.equalsIgnoreCase("swipeto")) {
path.lineTo(x, y);
gestureBuilder.addStroke(new GestureDescription.StrokeDescription(path, 100, time));
dispatchGesture(gestureBuilder.build(), new GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
System.out.println("SWIPTE Gesture Completed :D");
super.onCompleted(gestureDescription);
}
}, null);
}
}
}
}
Geändert von flashcoder ( 2. Sep 2018 um 02:21 Uhr)
|