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

Last active application

1 replies · 1,580 views · Started 24 October 2004

Hello,

Sorry if the question is too lame, but i start to code my first Symbian application just few days ago and i'm not so familiar with this OS still...

I have an application, which is called by CaptureKey. I need to know the application, which was active, when the keypress of my capture key occurs :

If i use this code, i can get the window group, but i need the application as a TApaTask :
TKeyResponse CMyAppUi::HandleKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType )
{
if ( aType == EEventKeyDown && aKeyEvent.iScanCode == hotKeyCode )
{
focusID = CCoeEnv::Static()->WsSession().GetFocusWindowGroup();
}
}

Something like this (here i assume, that the Notes application was active, but i need the real one :
TKeyResponse CMyAppUi::HandleKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType )
{
if ( aType == EEventKeyDown && aKeyEvent.iScanCode == hotKeyCode )
{
TApaTaskList tasklist(CCoeEnv::Static()->WsSession());
TApaTask *mytask = new (ELeave) TApaTask( tasklist.FindApp( _L("Notepad"😉 ) );
}
}

Jordan

OK, I found the solution 😊

// Create an emtpy task
TApaTask clientTask( CCoeEnv::Static()->WsSession() );
// Associate the task with the active window group (with the KBD focus)
clientTask.SetWgId( CCoeEnv::Static()->WsSession().GetFocusWindowGroup() );

That's it, if someone needs similar functionality...