Page 1 of 1

Android: reading keyboard leftovers

Posted: Thu Jan 07, 2021 9:17 pm
by simon.schvartzman
Hi all, I wonder if it would be possible to read Android's keyboard buffer in order to gain access to was entered by another App.

Just to make myself clear I may be facing the challenge to develop an Android App that would read a barcode scanner, according to the handheld vendor they use a keyboard wedge approach
What is a keyboard wedge?

A keyboard wedge is an application that can acquire data and send it directly in the keyboard buffer, just as if it was typed on a virtual keyboard.
Any thoughts?

Thanks

Re: Android: reading keyboard leftovers

Posted: Fri Jan 08, 2021 8:20 am
by bangkok
simon.schvartzman wrote:
Thu Jan 07, 2021 9:17 pm
Hi all, I wonder if it would be possible to read Android's keyboard buffer in order to gain access to was entered by another App.

Just to make myself clear I may be facing the challenge to develop an Android App that would read a barcode scanner, according to the handheld vendor they use a keyboard wedge approach
Very simple :

-create an android native text field
-use a script inside like this :
on returnkey

put the text of me into tText

answer "Barcode decoded "&tText

end returnkey
You need to program your barcode scanner, so it adds a CR (carriage return) at the end of each scan.

After that, it's like you said : a keyboard

-you scan a barcode
-the scanner will send the "text" directly into your field
-the CR special character will fire an action (your script)

(of course the field has to be selected, AKA with insertion point inside it).

I use this scheme in several apps.

Re: Android: reading keyboard leftovers

Posted: Fri Jan 08, 2021 2:40 pm
by simon.schvartzman
@bangkok, many thanks for you useful and straightforward contribution. This is going to be very valuable to me!

Regards

Re: Android: reading keyboard leftovers

Posted: Sat Mar 20, 2021 7:55 pm
by simon.schvartzman
@bangkok, your suggestion is working fine but now I have another chanllenge.

I'd like data to be inputed only by trigering the scanner but as it is know the keyboard is visible when the field has the focus. Do you know any way to hide the keybaord and still be able to receive data coming from the scanner which as you know is emulating a keyboard...

Many thanks for any suggestions.

Re: Android: reading keyboard leftovers

Posted: Sun Mar 21, 2021 2:22 am
by bangkok
Hélas, no. I haven't found a way to bypass the logic :

-in order to catch the data sent by the barcode reader the field must have the focus
-and the focus displays the virtual keyboard. Always !

This could be solved in the future... We need a command to hide the virtual keyboard.

That could be a solution
-focus on the field
-keyboard is displayed
-hide immediately the keyboard (with message openfield for instance or keyboardActivated)

But the best solution would be to make "android" compatible the commands keyDown , rawKeyDown etc.

Code: Select all

on keyDown theKey 
  if theKey is not a number then beep
  else pass keyDown
end keyDown
This is what is use for desktop apps linked to a barcode scanner. No need to have a field with focus.

The characters "typed" by the barcode scanner are sent directly to the card, and intercepted with keyDown.

Re: Android: reading keyboard leftovers

Posted: Sun Mar 21, 2021 3:42 am
by simon.schvartzman
Hi @bankok, I really appreciate your suggestions but I'm afraid l need more help
That could be a solution
-focus on the field
-keyboard is displayed
-hide immediately the keyboard (with message openfield for instance or keyboardActivated)
which command should I use to hide the keyboard?

Code: Select all

on keyDown theKey 
  if theKey is not a number then beep
  else pass keyDown
end keyDown
keyDown isn't fired on Android...

Re: Android: reading keyboard leftovers

Posted: Mon Mar 22, 2021 3:02 am
by bangkok
This could be solved in the future... We need a command to hide the virtual keyboard.


It's a wish.
;-)

I know that keyDown doesn't work on Android.

But it might in the future.