Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor
Accepted Solution

EventInjector

I am trying this code that I found here. Looked nice.

 

            EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(
                    KeyCodeEvent.KEY_DOWN,( char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD);
            EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(
                    KeyCodeEvent.KEY_UP,(char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD);
            EventInjector.invokeEvent(pressEndKey);
            Thread.sleep(50);
            EventInjector.invokeEvent(releaseEndKey);
            Thread.sleep(50);
            EventInjector.invokeEvent(pressEndKey);
            Thread.sleep(50);
            EventInjector.invokeEvent(releaseEndKey);
            Thread.sleep(50);

 

gives me a bunch of error messages. like:

 

cannot find symbol  keypad

 

Inconvertible types found   keypad.KEY_END

 

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: EventInjector

Maybe you should import net.rim.device.api.ui.Keypad

Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: EventInjector

importing

 

import net.rim.device.api.ui.Keypad;

 

did not help, unfortunately

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
johnbibs
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800
My Carrier: Globe Telecom

Re: EventInjector

[ Edited ]

try importing 

 

import net.rim.device.api.system.EventInjector;

 

import net.rim.device.api.system.EventInjector.KeyCodeEvent;

import net.rim.device.api.system.KeypadListener;

import net.rim.device.api.ui.Keypad;

 

Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: EventInjector

have thrown in lots of import and tried various permutations, currently these (some for other purposes):

 

import net.rim.blackberry.api.mail.*;
import net.rim.blackberry.api.mail.event.*;
import net.rim.device.api.system.*;

import net.rim.blackberry.api.phone.*;
import net.rim.blackberry.api.phone.Phone;

import net.rim.device.api.system.EventInjector;
import net.rim.device.api.system.EventInjector.KeyCodeEvent;
import net.rim.device.api.system.KeypadListener;
import net.rim.device.api.ui.Keypad;

import net.rim.device.api.system.EventInjector.*;
import net.rim.device.api.system.EventInjector.KeyCodeEvent.*;
import net.rim.device.api.system.KeypadListener.*;
import net.rim.device.api.ui.Keypad.*; 

 

the code is still:

 

            EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(
                    KeyCodeEvent.KEY_DOWN,(char)keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD);
                   
            EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(
                    KeyCodeEvent.KEY_UP,(char)keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD);
                   
            EventInjector.invokeEvent(pressEndKey);
            Thread.sleep(50);
            EventInjector.invokeEvent(releaseEndKey);
            Thread.sleep(50);
            EventInjector.invokeEvent(pressEndKey);
            Thread.sleep(50);
            EventInjector.invokeEvent(releaseEndKey);
            Thread.sleep(50);

 

here are errormessages

 

cannot find symbol
symbol  : variable keypad

 

 inconvertible types
found   : keypad.KEY_END
required: char
                    KeyCodeEvent.KEY_UP,(char)keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD);

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
johnbibs
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800
My Carrier: Globe Telecom

Re: EventInjector

I'm not sure if this is just a typo error but your keypad.KEY_END should be Keypad.KEY_END? 

 

 

Please use plain text.
Developer
ingvar_e
Posts: 551
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: EventInjector, solved

Finally solved!

 your keypad.KEY_END should be Keypad.KEY_END?

 

Posting code that compiles correctly and with imports that work for anyone else trying this code

 

import net.rim.blackberry.api.mail.*;
import net.rim.blackberry.api.mail.event.*;
import net.rim.device.api.system.*;
import net.rim.blackberry.api.phone.*;
import net.rim.blackberry.api.phone.Phone;
//import net.rim.device.api.system.EventInjector;
import net.rim.device.api.system.EventInjector.KeyCodeEvent;
//import net.rim.device.api.system.KeypadListener;
import net.rim.device.api.ui.Keypad;

 

--------
            EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(
                    KeyCodeEvent.KEY_DOWN,(char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD);
                   
            EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(
                    KeyCodeEvent.KEY_UP,(char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD);
                   
            EventInjector.invokeEvent(pressEndKey);
            Thread.sleep(50);
            EventInjector.invokeEvent(releaseEndKey);
            Thread.sleep(50);
            EventInjector.invokeEvent(pressEndKey);
            Thread.sleep(50);
            EventInjector.invokeEvent(releaseEndKey);
            Thread.sleep(50);

 

---------

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Please use plain text.
Developer
dankolix
Posts: 100
Registered: ‎06-21-2010
My Device: Not Specified

Re: EventInjector, solved

the code you posted whidh was supposed to work, did not work for me. Am getting some "cannot find symbol" errors from these lines

 

        EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(
        KeyCodeEvent.KEY_DOWN,(char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD);
                   
        EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(
        KeyCodeEvent.KEY_UP,(char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD);

 

 

The actual error messge is:

 

java:49: cannot find symbol
symbol  : constructor KeyCodeEvent(int,char,int)
location: class net.rim.device.api.system.EventInjector.KeyCodeEvent
        EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(
                                                 ^
C:\Blackberry\BB4_3Wspace\BB4_3ProjectFolder\EventReciever.java:52: cannot find symbol
symbol  : constructor KeyCodeEvent(int,char,int)
location: class net.rim.device.api.system.EventInjector.KeyCodeEvent
        EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(
                                                   ^

 

any help appreciated..cheers

 

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: EventInjector, solved

dankolix please open your own threads and refrain from posting in already solved threads.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.