Posting Key Event, it works but...

Login to reply to this topic.
Tue, 2005-03-15 09:39
Joined: 2004-11-20
Forum posts: 67
Hi all,
I have written a class to post some keyEvents, it has a public method to do it,

now I want to post a string of keys,  i.e.  01234567891, the length of this string is 11,
the first ten of digist are posted successfully but the last digit can't be posted without any error,...
I just see 0123456789 on screen, the last digit (1) can't be posted,

Why? is there any buffer?

here is my public method of KeyPoster ActiveObject :

++++++++++++++++++++
void CKeyEventPoster::StartPostingKeyEvents(TUint aCode, TInt aModifier, TInt aRepeat, TInt aScanCode )
{

   TWsEvent event;
   TInt iForegroundWinGroup = iWsSession.GetFocusWindowGroup();

        event.SetType(EEventKeyDown);
        event.SetTimeNow();
        event.Key()->iCode = aCode;
        event.Key()->iModifiers = aModifier;
        event.Key()->iRepeats = aRepeat;
        event.Key()->iScanCode = aScanCode;
        iWsSession.SendEventToWindowGroup(iForegroundWinGroup, event);

        event.SetType(EEventKey);
        event.SetTimeNow();
        event.Key()->iCode = aCode;
        event.Key()->iModifiers = aModifier;
        event.Key()->iRepeats = aRepeat;
        event.Key()->iScanCode = aScanCode;
        iWsSession.SendEventToWindowGroup(iForegroundWinGroup, event);

        event.SetType(EEventKeyUp);
        event.SetTimeNow();
        event.Key()->iCode = aCode;
        event.Key()->iModifiers = aModifier;
        event.Key()->iRepeats = aRepeat;
        event.Key()->iScanCode = aScanCode;
        iWsSession.SendEventToWindowGroup(iForegroundWinGroup, event);
}
+++++++++++++++

and I call it in this way:

               iKeyEventPoster -> StartPostingKeyEvents('0' ,0, 0, EStdKeyNull);
               iKeyEventPoster -> StartPostingKeyEvents('1' ,0, 0, EStdKeyNull);
               iKeyEventPoster -> StartPostingKeyEvents('2' ,0, 0, EStdKeyNull);
               iKeyEventPoster -> StartPostingKeyEvents('3' ,0, 0, EStdKeyNull);
               iKeyEventPoster -> StartPostingKeyEvents('4' ,0, 0, EStdKeyNull);
               iKeyEventPoster -> StartPostingKeyEvents('5' ,0, 0, EStdKeyNull);
               iKeyEventPoster -> StartPostingKeyEvents('6' ,0, 0, EStdKeyNull);
               iKeyEventPoster -> StartPostingKeyEvents('7' ,0, 0, EStdKeyNull);
               iKeyEventPoster -> StartPostingKeyEvents('8' ,0, 0, EStdKeyNull);
               iKeyEventPoster -> StartPostingKeyEvents('9' ,0, 0,
EStdKeyNull);
              iKeyEventPoster -> StartPostingKeyEvents('1' ,0, 0,
EStdKeyNull);


++++++++++++++++++++
the red line doesn't work,...
Why?

Wed, 2005-03-16 07:52
Joined: 2004-11-20
Forum posts: 67
Posting Key Event, it works but...
I used iWsSession.Connect and iWsSession.Close,
before and after of keyPoseting event replace of in ConstructL and Destructor,

Now the problem solved,
Tnx
Tue, 2005-06-07 08:33
Joined: 2004-08-26
Forum posts: 34
Re: Posting Key Event, it works but...
To the original poster.. Just out of curiousity, did you first try using RWsSession::SimulateKeyEvent(TKeyEvent)?

For quality Symbian idling, join #symbian at irc.freenode.net

Thu, 2006-01-05 21:26
Joined: 2005-12-16
Forum posts: 47
Re: Posting Key Event, it works but...
simulatekeyevent for sure had to be flushed under my circumstances, could not get it to work any other way!

this works fine:
Task.SendKey(backKeyEvent);
no flushing needed, nor could i find a way to flush if needed in api

this did nothing:
ws.SimulateKeyEvent(backKeyEvent);

until i corrected it like this:
ws.SimulateKeyEvent(backKeyEvent);
ws.Flush();

There is also an autoflush function that might work, just found it...
TBool SetAutoFlush(TBool aState);
Sets a session's auto-flush state.

If auto-flush is set to ETrue, the window server buffer is flushed immediately anything is put into it, instead of waiting until it becomes full. This setting is normally used only in a debugging environment.

If the auto-flush state is EFalse, the window server buffer is flushed normally.




grant it, i was sending several keys mind you!

also, ws.SimulateKeyEvent states in api's that it is only for testing purposes only.  I was hesitent to use it, as it...
A.  sends keys anywhere and everywhere, could prove disastrous
B.  is unreliable because of A
C.  ?May? impede code signing because it is for "testing purposes" only?

Jay Glass
Phoenix, AZ. USA
http://IChiBanComputers.Com

  • Login to reply to this topic.