Android Question Is there a way to simulate a click?

Rorry

Member
Licensed User
Longtime User
Hi,
how can i simulate a click (touch event) on my own application at a specific X Y point on the screen.

Thanks.
 

Informatix

Expert
Licensed User
Longtime User
The donationware version of the Gesture Detector library can do this (with CreateMotionEvent and PassTouchEventTo).
 
Upvote 0

Rorry

Member
Licensed User
Longtime User
Thank you informatix.

It sounds good. I'll donate you soon what i can for this useful library

thanks everyone for help.
 
Upvote 0

Rorry

Member
Licensed User
Longtime User
Pretty good idea eric. didnt think about that.

but when i try :
B4X:
webview1.LoadUrl("javascript:document.elementFromPoint(250, 250)).click();")

i get this error : Uncaught TypeError: Object #<HTMLEmbedElement> has no method 'click' in null (Line: 1)

any idea? thx
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I never used a webview since I started writing code in B4A so I won't be of great help here.
And AFAIK, GD solved the problem of Rorry.
In PassTouchEvent, GD dispatches the motion event to another view. There's no wizardry. It's a thing that can be done in Java.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Thank you for your donation.

What the D means in "GD" for the Gestures library ?
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
that a move can also be done with your GD library (e.g. by using ACTION_MOVE), which also does not work.
Without CreateMotionEvent, I don't see how you can generate a move with the library.

Is it possible to use GD to simulate a MOVE action by code? If so, please don't reply with a simple "yes" but tell me how to do it.
Set the action parameter of CreateMotionEvent to Action_Move and generate at least two moves (in case the scrolling function does not take into account the initial position of Action_Down).
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I'm amazed that you have to simulate all these operations with a webview. There's no function to scroll a webview? To select and click on a link?

Not with a simple webview. With webviewextras library you have part of this features

flingScroll(webView1 As WebView, vx As Int, vy As Int)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…