Android Question Trigger the clipboard to let free his text (Simulate Pasting)

artsoft

Active Member
Licensed User
Longtime User
Yes, I know, a strange title - but it describes very well!!

I have the following scenario:


I put normal text into the clipboard on my smart device and I created an overlay window in my app. The overlay window (panel) has the permission to be located on top of all windows/items/etc. on screen. Realized as runtime permission! So far - so good!

So I can put all visible apps in the background (running there) by simply pressing the home button on my smart device and only my overlay windows remains on screen and is visible.

On this overlay window there is a bitmap and a button. So I am able to handle click events within this overlay window.

So I start now another app with a text input field and I click in this field. The software keyboard will displayed at once. To enter the clipboard text into this text field, I could simply make a "long click" in it and then choose "Insert" from system owned clipbard menu.

But, I dont want to go this way!!!
My goal is to click on my "overlay" button (means: button on the overlay window) in order to "trigger" the insertion of the clipboard text into this current text field.

Is there a way to implement such a "feature"???
Thankful for any help.

Best regards :)
 

drgottjr

Expert
Licensed User
Longtime User
it sounds like you are unaware that you can control the clipboard by code.
are you using the clipboard library? if there is text in the clipboard, you
can insert it anywhere you like. you are not limited to android's
clipboard functions (copy, paste).

clipboard.hasText
clipboard.getText
clipboard.setText
clipboard.clrText

what more do you need?
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
it sounds like you are unaware that you can control the clipboard by code.
are you using the clipboard library? if there is text in the clipboard, you
can insert it anywhere you like. you are not limited to android's
clipboard functions (copy, paste).

clipboard.hasText
clipboard.getText
clipboard.setText
clipboard.clrText

what more do you need?

Thanks for your response!

Of course, I am using the normal Clipboard lib in order to handle the clipboard and its text (if there is text).

clipboard.hasText
- this checks if there is text

clipboard.getText
- this provides the text into a string

clipboard.setText
- this sets the text into the clipboard

clipboard.clrText
- and this clears the clipboard

But unfortunately this doesn't answer my question.

In example, the MS Windows OS allows me to get the current windows handle of a text field from another app in order to set text into it from another windows app. And that's exactly what I need.

Please imagine: You have set text into the clipboard with your own Android app. Then you start another app with a text field and you want to insert the clipboard text into this "foreign" text input field ... but this insertion should be triggered by your own app. That's what I want to do.

I hope this is moire clear now.

Thanks again for your help.
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
This sort of thing is not normally possible.

However, it appears that you can do something like it through the Accessibility API.


Hi Andrew!

Yes, today I also saw some internet programmer articles regarding this Accessibility API. But it seems, that the working with and the handling of this API are not so easy.

I will continue to look for any solution with this API.
Do you know if there is already a B4A lib available for this API?

Thanks a lot for your tipp :)

Reagrds
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
This sort of thing is not normally possible.

However, it appears that you can do something like it through the Accessibility API.


Update:

I could find this here:


But I don't know on how to use it....
 
Upvote 0
Top