×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    16

    Run A Program to Capture All Keys

    Hi Guys,

    Is it possible to develop an application using C++, so that this program will keep running as foreground, and capture EVERY SINGLE KEY pressed by the user?

    I meant, I had given a few tries on java MIDlet aiming to acheive that, but Java just not able to capture a certain set of keys, e.g., when either Menu Key or End Key is pressed, the Java program will jump to background, needs to be switched back to foreground manually by the user (which we don't want).

    I had reached a few other discussion forum, seems C++ should be able to provide more control over the phone. Therefore I am kinda guessing C++ might be able to do what i want. Since i'm not an experienced C++ programmer, every single move i do in C++ will take me a big effort, so before giving a try myself, I would really want to hear from you guys and see if it's possible to run C++ app to capture ALL KEYS.

    Thanks for any comments/replies guys!
    BR,

    Jack Xie

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    16

    Re: Run A Program to Capture All Keys

    Sorry, I think I need to give you guys more info:
    I am using phone: N70
    i.e.
    Operating System: Symbian OS v8.1a
    Developer Platform: S60 2nd Edition, Feature Pack 3

    Cheers!
    BR,

    Jack Xie

  3. #3
    Super Contributor
    Join Date
    May 2003
    Location
    Vancouver, Canada
    Posts
    985

    Re: Run A Program to Capture All Keys

    Yes, it is possible to do that in C++. Just search this forum and you will find some discussions. This one is an example, http://discussion.forum.nokia.com/fo...ght=capturekey.

    Just a small note, if you are targetting S60 3rd Edition, there is a little additional step because you have to go to Symbian Signed. The reason is because a program like this needs a capability, called SwEvent. In order to distribute application with this capability, you need to go to Symbian Signed program. It costs a few hundred bucks.

    If you are planning to distribute your application as freeware or open source, you can use special route, which is free of charge.

    Antony

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Run A Program to Capture All Keys

    the target seems to be 2nd edition FP3, so no symbian signed required. With capture keys you would need to define each key separately, easier way is to make focusing screen, (doesn't need to fill whole screen) and just capture windows server even'ts, then you would get them all very easily.

    yucca

  5. #5
    Regular Contributor
    Join Date
    Jan 2004
    Location
    Braunschweig, Germany
    Posts
    345

    Re: Run A Program to Capture All Keys

    It seems that the application is ment to always be in the foreground, so most key events should be received by this application anyway. It should be necessary to take special care of the keys which would send the application to the background. The mentioned example should give enough information how to do that.

    Bernd

  6. #6
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: Run A Program to Capture All Keys

    hi,

    This will be a helpful resource to u....

    http://db.cs.helsinki.fi/~mraento/lx...apture.cpp#025

    Regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    16

    Re: Run A Program to Capture All Keys

    Wow, thanks for those replies guys!

    Regarding the URL provided by Mateen Maldar, I have got confused about how I should capture the key events.

    AFAIK, there are two ways to do so?

    1. Implement an AppUi calss to extend CEikAppUi, so that we have function HandleKeyEventL to capture key events, or

    2. We can implement a Container calss to extend CCoeControl, so that we can have a function OfferKeyEventL to capture key events.

    Am I right about we can choose either to implement capture key events?

    If I am correct, what are the differences between they two? When I should use HandleKeyEventL and when I should use OfferKeyEventL ?

    Now after reading Mateen Maldar's link, i got even more confused, what is the CaptureKeyL function? Is it a more native function, only this one can be native enough to capture ALL KEYS?

    Sorry, my questions above might sound stupid, I am completely new to Symbian, and kinda new to C++ . I have been using Java, and my boss suddenly put me into this

    OK, thanks in advance for your replies/comments.
    BR,

    Jack Xie

  8. #8
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Run A Program to Capture All Keys

    basically if you are using applications framework (i.e. your application has application, document, appui classes) then you could capture keys easily with AppUi's HandleKeyEventL or with containers offerkey, but only when your application has focus.

    Also, you could implement a windows se3rve observer without application framework, bu utilizing RWsSession for capturing events, anyway, also then you would need to have focus on your application.

    Then if you want to capture keys while your applciations doesn't have a focus, you could use RWindowGroup's CaptureKey to do so.

    In all cases if you want to key events to be usable also by other application, you would need to forward them. That would be easiest with keycapturing, since you could just pass them to the currently focused application, for exapmle by doing something like this:

    TInt wgId = iWsSession.GetFocusWindowGroup();
    iWsSession.SendEventToWindowGroup(wgId, event);

    yucca

  9. #9
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: Run A Program to Capture All Keys

    hi jackie.

    Well i didn't want anyone to get confused.. There is quite a simple for capturing using

    RWindowGroup ....

    and yucca was also saying the same

    http://www.cs.helsinki.fi/u/mraento/...eycapture.html

    Regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  10. #10
    Registered User
    Join Date
    May 2006
    Posts
    16

    Smile Re: Run A Program to Capture All Keys

    Yo, thanks for all the suggestion, thanks for all the replies, guys. You guys are giving me a lot usuful information.

    Currently, i'm using CEikAppUi::HandleKeyEventL to capture most of the keys, but still not sure how to catch special keys like End Key and Menu Key. but i think i will do some more study on it, meanwhile, thanks a lot for your reply guys! It's been really appreciated!
    BR,

    Jack Xie

  11. #11
    Regular Contributor
    Join Date
    Jan 2004
    Location
    Braunschweig, Germany
    Posts
    345

    Re: Run A Program to Capture All Keys

    You have to use CaptureKeyL to get the special keys as well. When you search the forum for this keyword, you will find a lot of useful information about this.

    If you plan to use this for different devices, it might get tricky because the different devices also have a different set of keys.

    Bernd

  12. #12
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: Run A Program to Capture All Keys

    A further alternative would be using the anim dll classes. Check RAnim in the sdk(there's also an example in it IIRC)

  13. #13
    Registered User
    Join Date
    May 2006
    Posts
    16

    Re: Run A Program to Capture All Keys

    OK, it comes a conclusion: I can't capture ALL KEYS using the Application Framework (Document, AppUi, Container etc). Instead, i do need to develop an application without that framework, so that I can invoke CapturekeyL, which is powerful enough to capture EVERY SINGLE KEY?

    .... sorry, i got lost from here then. So far all i know about symbian c++ programming is using Carbide.c++ to create a HelloWorld project, which then sits in the Application Framework.

    A guide to develop an application without that framework will be very appreciated.

    Thanks!
    BR,

    Jack Xie

  14. #14
    Regular Contributor
    Join Date
    Jan 2004
    Location
    Braunschweig, Germany
    Posts
    345

    Re: Run A Program to Capture All Keys

    You can develop this application in several ways. I assume that your application will do something else that just capturing all keys and doing nothing with it.

    So the conclusion is to develop a normal application with the usual framework (Document, AppUi, Container etc). This application will receive most of the key events because that is the way a normal application running in the foreground works.

    Some special keys are handled by the System and the events are not passed to the application. The On/Off key for example. To get events for them as well you have to use CapturekeyL additionally.

    Bernd

Similar Threads

  1. Replies: 4
    Last Post: 2006-07-04, 13:54
  2. background program capture key input
    By jackxie in forum Mobile Java General
    Replies: 1
    Last Post: 2006-07-03, 16:26
  3. Replies: 0
    Last Post: 2004-03-30, 00:13
  4. Can not run file manager program
    By agsapt in forum Symbian
    Replies: 0
    Last Post: 2002-08-27, 07:37
  5. i cannot run any java program in 9200 SDK
    By chili_fi in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2002-08-12, 23:34

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×