×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    1

    Advice to simulate long key press from application?

    Hi all,

    I've been trying to simulate a long press of the hash (#) key, from the applicatoin (C++ application) for S60 Nokia phones.

    To simulate the 'simple' # key is quite easy, but when try to simulate the long # press, I can success. I've been trying to play with keydown and keyup and delays, but no way.
    Also, I've been looking for a possible code for the long #, but I can't found it.

    If you could give me any advice regarding this issue, I would be very pleased. Thank you very much!

    Roger

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169
    Hi have you tried setting the repeats in downevents ?

    yucca

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    36

    answer?

    did you find an answer to this, roger?

    thanks.

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    36

    answer

    i just got this to work in case others need to do the same:

    TApaTaskList tlist(iEikonEnv->WsSession());
    TApaTask app(tlist.FindApp(_L("Phone")));

    TKeyEvent key;
    key.iModifiers = 0;
    key.iRepeats = 0;
    key.iCode = '1';
    key.iScanCode = '1';

    app.SendKey(key);
    key.iRepeats = 1;
    app.SendKey(key);
    app.SendKey(key);
    app.SendKey(key);
    app.SendKey(key);

  5. #5
    Regular Contributor
    Join Date
    May 2004
    Location
    NRW/ Germany
    Posts
    188
    Hi ajaykapur,

    I've tried your code and it works fine.
    I've only got the problem, that the key isn't released any more.
    I've used this part of your code:

    TApaTaskList tlist(iEikonEnv->WsSession());
    TApaTask app(tlist.FindApp(_L("Phone")));

    TKeyEvent key;
    key.iModifiers = 0;
    key.iRepeats = 0;
    key.iCode = '1';
    key.iScanCode = '1';

    app.SendKey(key);

    Can you please tell me, what I have to do to release the key again?

    Thanks

    Arne

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    36
    i'm not sure i understand your question, can you explain a little more.

    There are also key up and key down events that can be sent to an app, but they cannot be sent with the SendKey function. the appropriate function is in the window server classes.

  7. #7
    Regular Contributor
    Join Date
    May 2004
    Location
    NRW/ Germany
    Posts
    188
    I'm trying to explain:

    With your code I'm able to simulate a key press. The app presses the "1".
    The problem is that the app keeps on pressing the key. I need the app to stop pressing the key again.

    Thanks

    Arne

  8. #8
    Registered User
    Join Date
    Jul 2003
    Posts
    15

    Re: Advice to simulate long key press from application?

    Hi,

    I have a related problem.

    I want to send numeric characters (0-9) to the application/view/dialog in focus using the sequence described above.

    This works fine when numeric mode is selected for the control/editor in focus, but when alphabetic mode is selected the numeric character I send is exchanged with the first alphabetic character on the corresponding keypad key (e.g. '2' is changed to 'a').

    I can't send multiple key events to simulate multiple key presses for numeric characters, because this will not work in numeric mode. Is it possible to check what character mode that is selected for the control/editor in focus?

    Instead I try to simulate multiple key presses by using TKeyEvent::iRepeats. But this only works for the first numeric character I send. Then the control/editor blocks all following numeric characters. If the control/editor lose and gain focus it accepts another numeric character...

    This is the code sequence I use:

    TApaTask clientTask(CCoeEnv::Static()->WsSession());
    clientTask.SetWgId(CCoeEnv::Static()->WsSession().GetFocusWindowGroup());

    TKeyEvent keyEvent;
    keyEvent.iCode = 0;
    keyEvent.iScanCode = 0;
    keyEvent.iRepeats = 0;
    keyEvent.iModifiers = 0;
    clientTask.SendKey(keyEvent); // simulate key down event, same behavior without this...

    keyEvent.iCode = '2'; // the numeric character code
    keyEvent.iScanCode = 0; // same behavior with EStdKeyNkp2 and '2'
    keyEvent.iModifiers = 0; // same behavior with EModifierKeypad
    keyEvent.iRepeats = 5; // blocks after first character if > 0 (gets an 'a' if 0)
    clientTask.SendKey(keyEvent); // numeric character key event

    keyEvent.iCode = 0;
    keyEvent.iScanCode = 0;
    keyEvent.iRepeats = 0;
    keyEvent.iModifiers = 0;
    clientTask.SendKey(keyEvent); // simulate key up event, same behavior without this...


    Is there anyone that knows how to do this?

  9. #9
    Registered User
    Join Date
    Nov 2006
    Posts
    3

    Re: Advice to simulate long key press from application?

    hii all,

    i have related issue , i wana simulate button/key press on mobile without actually pressing the button , plz if possible anyone can post the whole source code of simulating button app. as i am new to symbian c++ programing

    thanks
    mayur

  10. #10
    Registered User
    Join Date
    Nov 2006
    Posts
    20

    Re: Advice to simulate long key press from application?

    hi to all i m newble in all i want to know that can i Simulate key press in game application

    i read from some posts that in game application CdirectScreenAccess is used and SendKey and SimulateKey method is used in case of WindowServer

    so please reply me soon its very criticle for me......

    thanks in advance

  11. #11
    Registered User
    Join Date
    Jul 2003
    Posts
    15

    Re: Advice to simulate long key press from application?

    Hi,
    I used this to solve my problem:

    TKeyEvent keyEvent;
    keyEvent.iCode = aCode;
    keyEvent.iScanCode = 0;
    keyEvent.iModifiers = 0;
    keyEvent.iRepeats = 0;
    TWsEvent wsEvent;
    *(wsEvent.Key()) = keyEvent;
    wsEvent.SetType(EEventKeyDown); // repeate with EEventKey and EEventKeyUp
    wsEvent.SetTimeNow();
    CCoeEnv::Static()->WsSession().SendEventToWindowGroup(CCoeEnv::Static()->WsSession().GetFocusWindowGroup(), wsEvent);

  12. #12
    Registered User
    Join Date
    Nov 2006
    Posts
    20

    Re: Advice to simulate long key press from application?

    Quote Originally Posted by samsharma
    hi to all i m newble in all i want to know that can i Simulate key press in game application

    i read from some posts that in game application CdirectScreenAccess is used and SendKey and SimulateKey method is used in case of WindowServer

    so please reply me soon its very criticle for me......

    thanks in advance
    can u please tell me how can i simulate Key Press in game APllication or we can say that
    is there any way to Simulate a key press into CdirectAccessscreen Mode

    Plz reply me

    Thanks in Advance []

Posting Permissions

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