Jump to content
Sign in to follow this  
Turan Can

FMX Android Mouse pos X , Y and keyboard event

Recommended Posts

Hi All,

Does anyone know the equivalent of these 2 features in android?

I want to click on the X, Y coordinates I sent.

 

Windows vcl;

I've been using these on windows with no problems.

SetCursorPos

Mouse_Event

 

Android ??

event: JMotionEvent;


Form1.MouseMove([], Mouse.Left, Mouse.Top); 

 

 

Share this post


Link to post
Guest
On 11/25/2021 at 12:20 AM, Turan Can said:

Hi All,

Does anyone know the equivalent of these 2 features in android?

I want to click on the X, Y coordinates I sent.

 

Windows vcl;

I've been using these on windows with no problems.

SetCursorPos

Mouse_Event

 

Android ??

event: JMotionEvent;


Form1.MouseMove([], Mouse.Left, Mouse.Top); 

 

 

hi, its usage is shown below, it would be better if you add a short pause between mouse down and up event (sleep(ms)).

if your question is to click somewhere on the android screen rather than in the form (for example running as a background service) this will not work.

 

http://git.kngstr.com/KngStr/delphi-fixes/src/b80b30a708f89ee5e1bbc457af248e69869a2ad4/10.3.1/Fixes/FMX.Presentation.Android.pas

    if EventAction = TJMotionEvent.JavaClass.ACTION_DOWN then
    begin
      Form.MouseMove([ssTouch], TouchPoint.X, TouchPoint.Y);
      Form.MouseMove([], TouchPoint.X, TouchPoint.Y); // Require for correct IsMouseOver handle
      Form.MouseDown(TMouseButton.mbLeft, [ssLeft, ssTouch], TouchPoint.x, TouchPoint.y);
    end
    else 
    if EventAction = TJMotionEvent.JavaClass.ACTION_MOVE then
    begin
      ProcessMoveActiveGestures;
      Form.MouseMove([ssLeft, ssTouch], TouchPoint.x, TouchPoint.y)
    end
    else 
    if EventAction = TJMotionEvent.JavaClass.ACTION_CANCEL then
    begin
      FinishActiveGestures;
      Form.MouseUp(TMouseButton.mbLeft, [ssLeft, ssTouch], TouchPoint.x, TouchPoint.y, False);
      // In MouseUp the form can unload presentation!
      if Form <> nil then
        Form.MouseLeave;
    end
    else 
    if EventAction = TJMotionEvent.JavaClass.ACTION_UP then
    begin
      FinishActiveGestures;
      Form.MouseUp(TMouseButton.mbLeft, [ssLeft, ssTouch], TouchPoint.x, TouchPoint.y);
      // In MouseUp the form can unload presentation!
      if Form <> nil then
        Form.MouseLeave;
    end;

 

Share this post


Link to post

First of all thanks for the reply.


This only works in the open form.
I want to activate the mouse anywhere on the phone.

Share this post


Link to post

Mouse, Detection of mouse click
I need a sample code to post mosu as x, y.
Important: I want to click outside the form globally, not on the form.

So even if the form is running in the background, I want to click on a point I want.

 

function MousePos: TPointF;
var
MouseService: IFMXMouseService;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXMouseService, IInterface(MouseService)) then
Exit(MouseService.GetMousePos);
Result := PointF(0, 0);
end;

Share this post


Link to post

This has to be. Because remote desktop connection products will not work otherwise.
It has to be active with an authorization.

Share this post


Link to post

The RD runs as a UI-less service, right?  So it doesn't have a Window of its own and probably have special rights to capture the display activities and send events.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×