Read-only archive of the All About Symbian forum (2001–2013) · About this archive

Sending event to other apps: Only some keys work...why?

6 replies · 3,994 views · Started 09 January 2003

Hi,

I have the following code:
[code:1]TInt sleep=70000;
User::After(sleep);
TWsEvent wsEvent;
TKeyEvent event;
event.iCode=EKeyLeftArrow;
for (TInt i=0;i<2;i++)
{
*(wsEvent.Key())=event;
wsEvent.SetType(EEventKey);
wsEvent.SetTimeNow();
wsSession.SendEventToWindowGroup(WgId, wsEvent);
}[/code:1]

In this example, my app send the LeftArrow-Event to the foreground app. (2 times!) Everything goes fine.

BUT:

Keys like EKeyNo, or the menu button DO NOT WORK. Can you tell me why? What did I do wrong?

C'Ya

-=[MastiX_MC]=-[/code]

I'm guessing here. Some keys react to the key down event and not the key event itself. Menu is an example of such an event (on the 9210 anyway). Try setting the event type to EEventKeyDown and not EEventKey.

Thx for that hint, but it didn't work.

What do mean, should I take iCode or iScanCode?

Or, do you know how to execute apps? For example the menu or the SMS-Prog?

Thx.

C'Ya

MastiX MC

The following code worked on my 9210 sdk. The menu appeared as if the menu key was pressed.

[code:1]TApaTask task(iEikonEnv->WsSession());
task.SetWgId(WgId);
task.SendKey(EKeyMenu, 0);[/code:1]

There are several ways to start an app. If you know the uid of the app, then the following code will work.
[code:1]CLinkApplication* linkapp = CLinkApplication::NewL();
CleanupStack::PushL(linkapp);
TUid uid = { 0x100053B3 };
linkapp->SetApplicationUidL(uid);
linkapp->StartLinkL(RApaLsSession::ESwitchFiles);
CleanupStack::PopAndDestroy(); // linkapp
[/code:1]

If you know the name of the app, then the following will start it.
[code:1]RApaLsSession* Als = new (ELeave) RApaLsSession;
CleanupStack::PushL(Als);
User::LeaveIfError(Als->Connect());
TThreadId threadid;
User::LeaveIfError(Als->StartDocument(_L("z:\\system\\apps\\mcentre\\mcentre.app"), threadid, RApaLsSession::ESwitchFiles));
CleanupStack::PopAndDestroy(); // Als[/code:1]

The examples will start the messaging app.

Hi guys,

if I send EKeyDevice3-event (used to be the joystickbutton!) to the foreground app (e.g. the main menu), it will not recognize it!!!

EKeyUp/down/left/rightArrow works!!!

I tried following codes till now:

#1:

TWsEvent wsEvent;
TKeyEvent event;
//event.iCode=EKeyLeftArrow;
event.iCode=aKeyEvent.iCode;

*(wsEvent.Key())=event;
wsEvent.SetType(EEventKeyDown);
wsEvent.SetTimeNow();
wsSession.SendEventToWindowGroup(WgId, wsEvent);

OR

#2:

TApaTask task(iEikonEnv->WsSession());
task.SetWgId(WgId);
task.SendKey(aKeyEvent.iCode,0);

D'you really don't know why only some keys work? I'm getting crazy... :cry: 😮

Bye.

Don't know the answer to your question. What are you trying to achieve? Maybe there is another way of doing it.

Hi ..

I am able to see the contacts by executing phonebook.app file in N7650 phone, after I tried with MIDUI.app which will redirected applications folder but not able to list the existing apps.. the following is code used for that ..

RApaLsSession* Als = new (ELeave) RApaLsSession;
CleanupStack::PushL(Als);
User::LeaveIfError(Als->Connect());
TThreadId threadid;
User::LeaveIfError(Als->StartDocument(_L("z:\\system\\apps\\midpui\\midpui.app"😉, threadid, RApaLsSession::ESwitchFiles));
CleanupStack::PopAndDestroy();

Can any body have an idea about this.. it will greatful if any body send the code / tips which will open apps directory.

Thanks
Haricharan

There are several ways to start an app. If you know the uid of the app, then the following code will work.
[code:1]CLinkApplication* linkapp = CLinkApplication::NewL();
CleanupStack::PushL(linkapp);
TUid uid = { 0x100053B3 };
[quote="cmatthee"]The following code worked on my 9210 sdk. The enu appeared as if the menu key was pressed.

[code]TApaTask task(iEikonEnv->WsSession());
task.SetWgId(WgId);
task.SendKey(EKeyMenu, 0);[/code]
linkapp->SetApplicationUidL(uid);
linkapp->StartLinkL(RApaLsSession::ESwitchFiles);
CleanupStack::PopAndDestroy(); // linkapp
[/code:1]

If you know the name of the app, then the following will start it.
[code:1]RApaLsSession* Als = new (ELeave) RApaLsSession;
CleanupStack::PushL(Als);
User::LeaveIfError(Als->Connect());
TThreadId threadid;
User::LeaveIfError(Als->StartDocument(_L("z:\\system\\apps\\mcentre\\mcentre.app"), threadid, RApaLsSession::ESwitchFiles));
CleanupStack::PopAndDestroy(); // Als[/code:1]

The examples will start the messaging app.[/quote]