12-10-2010 05:34 AM
I have and requirement to inject key events and touch events (if touch screen is available) in blackberry devices from Java program. I am able to do it successfully using the EventInjector API.
But in case of touch screen devices, such as storm, when the on-screen key board is visible then the EventInjector API is failing to inject those key events i.e. when I use the following code over the on-screen keyboard no event is injected. The code is as below:
EventInjector.TouchEvent downEvent = new EventInjector.TouchEvent(TouchEvent.DOWN, coordinates, coordinates, -1, -1, -1); //Touch the screen
EventInjector.TouchEvent clickEvent = new EventInjector.TouchEvent(TouchEvent.CLICK, coordinates, coordinates, -1, -1, -1); //Click the screen
EventInjector.TouchEvent unclickEvent = new EventInjector.TouchEvent(TouchEvent.UNCLICK, coordinates, coordinates, -1, -1, -1); //Unlick the screen
EventInjector.TouchEvent upEvent = new EventInjector.TouchEvent(TouchEvent.UP, coordinates, coordinates, -1, -1, -1); //Lift finger from the screen
// Invoke the touch events
I have ensured that the co-ordinates above is corresponding to a particular key in the on-screen. But when the on-screen key board is not visible the above code is working fine for any other components in the device screen.
So requesting your valuable feedback whether the EventInjector API can be used to inject touch event over the on-screen key board or not. If it is not possible then is there any workarround to achieve this?
Thanks and Regards
12-13-2010 03:21 PM
Are you seeing constant failures when injecting key events or just on specific screens?
Event injection is no supported on every screen or application. Event injection is not permitted on any security related screen.
12-14-2010 02:37 AM
No, my observation is that EventInjector is working fine in most of the screens except for some applications (like BB Calculator, I guess the app prevents to do it), but it is always failing when the on-screen keyboard is visbile and I can not inject event over that on-screen key board.
For example consider an application having a screen containing a button and textbox. I am always able to inject event on these components, when the on-screen keyboard is visble below the above controls I am still able to inject event to the above controls but the part of the screen where the on-screen keyboard is visible the event injector is not working.
So I have doubt whether the on-screen keyboard is not allowing to inject event over it for any reason or not.
12-14-2010 01:42 PM
The Calculator application does not support event injection.
You should be able to inject key events into a textbox (or any field that supports text input). This should work regardless of whether or not the on screen keyboard is shown and is the recommended approach to injecting characters.
12-15-2010 08:37 AM
Thanks MSohm for your feedback,
So as per your feedback in case of text boxes and other controls I can inject events regardless of whether on-screen keyboard is visible or not, I have tested the same and the result is as per your comments.
But, when the on-screen keyboard is visible and the menu button is pressed, in this case some part of the menu button falls over the on-screen keyboard. When I am injecting event over the menu items which falls over the on-screen keyboard it is not working. But the same is working when the on-screen keyboard is not visible.
So please provide your valuable feedback whether I can inject event on menu items which is falling over the on-screen keyboard.
12-15-2010 09:25 AM
You should be able to inject touch events on the menu. What BlackBerry Smartphone model and BlackBerry device software version are you testing on? You can find this under Options, About on the BlackBerry Smartphone.
12-15-2010 11:06 AM
I created an application with an EditField that displayed the virtual keyboard, brought up the menu and was able to have another application inject the event into the menu. I used the same code you have above to inject the events.
I was testing using the same BlackBerry model and device software version.
Are you seeing this in a specific application or in all applications?
12-16-2010 12:49 AM
Hello MSohm, thanks a lot for spending time on this.
Yes I can see the behavior in all the applications, i.e. irrespective of application I am not able to inject event over menu when the on-screen keyboard is visible (i.e. the part of the menu which is over the on-screen keyboard.
Since you have already have a working code it will be great help if you can post your code (if possible) so that I can check the difference with mine. Actually my code is a huge one (part of a project) and so I can post the same here
12-17-2010 12:02 PM
The code I used is almost identical to what you have above. I placed mine in a TimerTask that was executed by an application running in the background. Where are you injecting your events from?